Wearable Sensor for Measurement of Gait Walking and Running Motion

In this work, we developed a smart wearable device for gait speed measurement with dual wireless communication on the feet by using an inertia measurement unit (IMU) sensor. To discover step counts and speed information, pitch and yaw angles were calculated successfully from IMU signals using a Kalman filter and a moving average algorithm. Walking step counts were calculated using the sensor; the results demonstrated almost zero errors and averaged more than 90% accuracy in walking and running measurements. The observable speed for two-foot indication and adapted variation can be implemented on the sensor to gauge walking and running speeds for different subjects. Step counts and the swing frequency were tested and compared with results over a treadmill using a commercial chip in the insole of a shoe. Experimental results were validated using fast Fourier transform from the acquired pitch angle history. The pitch and yaw angles of users’ tibias can be used as controllable monitoring tags for personal health information in the future.


Introduction
A gait cycle is the most characteristic repetitive pattern of walking or running movement.Walking, jogging, and running are popular leisure activities for people pursuing fitness.To monitor their physical performance, people often use wearable devices with inertia measurement units (IMUs) when performing these activities.The most popular IMUs have three-dimensional acceleration and gyroscopic sensors.Various devices have 6-axis IMUs with magnetic sensors aligned on three axes to detect heading.Information about walking or running can be taken from numerous wearable devices, such as smart phones, smart watches, and embedded chip insole shoes.
Step counts and running speed can be displayed in real time through a mobile phone or an application (app).A study identified step counts with an IMU acceleration sensor (1) for users who carried their smartphones arbitrarily while walking.A swaying device with a precise IMU correction can be used for step counting and gait analysis.Several step counting methods, including use of smart insole sensors (2) with textile pressure arrays, nine-axis IMUs, and Bluetooth low-energy wireless transmission modules, have been proposed.An insole was equipped with a six-axis IMU and force sensor resistor for gait and posture analyses. (3)An integrated system for gait analysis was developed using an IMU on top of a shoe and a forced sensitivity resistor sensor in the insole of the shoe. (4)peed information can be realized or mimicked using averaged step length.
Step length estimation was developed more than 20 years ago, and its earliest application was in gait analysis.For step length estimation, a three-axis accelerometer was attached to the lower lumbar spine.Mathematical models were devised from empirical data for step length and step counts; these models were compared with each other. (5)Acceleration, angular rate, and magnet field sensor data were used to train and put into context a probabilistic classification model for step length estimation for a device that was attached to a user's center of mass. (6)An indoor localization device was placed on the ankle of a user; this device used an IMU with a magnetometer and could determine displacement by estimating the user's leg length by using the equation of motion of a simple pendulum. (7)tep counting and step length estimation through ambulatory monitoring experiments can be used for the analysis of gait variations such as stationary posture, walking, walking sideways, climbing and descending stairs, and running. (6)One study obtained walking features from an IMU that was placed on the instep of a user's foot; the heel-off, toe-off, heel-strike, and foot-flat states were determined; the results held considerable promise for applications in rehabilitation, sport medicine, and health monitoring. (8)Another study used an IMU mounted on a running subject's back for biofeedback. (9)Wavelet and autocorrelation-based algorithms were used for walking and jogging characterization by using two triaxial accelerometers located at the center of the body. (10)The accuracy of the characterizations was determined by the kurtosis threshold.
In this study, the sensing device was an IMU.To calculate the step count and step frequency of the real-time motion, the device monitored the position of a pedestrian ankle but was mounted on the instep of the shoe.This was a prototype; similar modules can be expected in future smart insole sensors with two-foot speed features.Step frequency can be obtained by dividing the target unit of time by the time duration between each step.The number of walking or running steps associated with every time step can be estimated; the speed can be verified in real time using algorithms.Experimental results indicated that the walking or running steps could be counted effectively using the proposed algorithm by manipulating signals from a single IMU first.The IMU data were filtered through a Kalman filter (KF), which calculated the swaying of the pitch angle for walking or running.A threshold algorithm was designed and each user obtained an independent threshold setting.This improved the accuracy of individual step count.The outcome step frequency or speed was calculated and compared with existing commercial exercise equipment.
A direct visual representation of the user's speed is displayed by the proposed wearable device, which allows the user or observer to obtain real-time speed information without using a mobile phone.Moreover, we validated the proposed method's calculation of the step frequency of the user by using a fast Fourier transform (FFT).This research intends to enable general clinicians and primary care sports medicine physicians to perform a basic analysis of a patient's normal walking and running gait and to recognize common gait abnormalities.For example, genu varus and genu valgus are the most common lower limb abnormities, especially in Asian people.
The apparatus for a new wearable sensing device is illustrated in the following section.Detailed explanations for the step counts and frequency calculations are given in Sect.3. Experimentation involving a commercial chip insole shoe with the proposed apparatus on a treadmill is described in Sect. 4. Experimental results are included in Sect. 5.

Apparatus
The flow chart for determining step count, heading direction, and speed from an IMU is illustrated in Fig. 1.With the height of the subject's information setting, we can use the value of height minus 100 cm as the step length estimation.Then, the walking speed is estimated by multiplying the step length estimation with the step count.
The system hardware architecture is illustrated in Fig. 2. One part of the apparatus was the master terminal, which was attached to one foot; the other part was the slave terminal, which was attached to the other foot.These two terminals communicate with each other.The master terminal consisted of an Arduino (MEGA 2560, with 7-20 V, 50 mA and 3.3 V for sensors), six-axis accelerometers (MPU-6050), a Bluetooth module (HC-05), a wireless transceiver module (NRF-24L01), and a light-emitting diode (LED).The master terminal was mainly used for acceleration sensing, signal filtering, calculating the pitch angle of the tibia's swing, performing a step counting algorithm, Bluetooth communication, transmitting real-time signals, and displaying light.The slave terminal consisted of another Arduino MEGA2560, another NRF24L01, and an LED.This slave terminal was used to receive real-time signals from the master terminal and to display speed information.The Arduino board was placed on top of the instep of a shoe.The speed display interface of an app was used on a mobile phone, and signals could be transmitted to the mobile phone through the Bluetooth module or stored in chip memory.The user's walking and running on the treadmill generated speed, distance, and step count information.The walking or running speed calculated through the proposed method was simultaneously compared with information from the wearable apparatus, information from the treadmill, and information from existing commercial chip shoes.

Data Processing
The signal processing with a sampling rate of 40 Hz can be divided into four parts.The first part was to convert the original six-axis accelerometer and gyro of IMU signal into a pitch angle for step counts and a yaw angle for turns.The second part involved individual calibration offsets for step counts.The third part involved establishing the threshold, and the fourth part was the algorithm calculating step counting, step frequency, and turning from the correlations of pitch and yaw angles.The data processing can be described as follows.

Kalman filter and moving average methods
A KF combines the least-squares method and state-space representation in the recursive solution of linear filtering for a dynamic system.The KF is one of the optimal recursive algorithms in data processing, particularly in the field of navigation, communication, and satellite and flight control, where high tolerance to noise is crucial.Contrary to the ordinary concept of low-pass, high-pass, and band-pass filters, the KF is an estimation and prediction approach based on a probability density function.The KF, with the optimal recursive data processing algorithm, (11) can estimate the present state by estimating the previous step and observing the current state.Therefore, without adopting previous observations and estimation data, less memory space is used, and a shorter system response time can be obtained.Furthermore, the KF outperforms its low-and high-pass counterparts in handling probabilistic noises.In short, without the need to record historical data for measurements or estimates, a KF can still calculate estimated values, and is close to the dynamic system state with regression over time.
In this research, a wearable device recorded the original IMU signals first, as shown in Fig. 3.The KF takes original a x , a y , and a z signals from an accelerometer and original g x , g y , and g z signals from a gyroscope of the IMU.
The Euler angles representing the orientation of a mobile frame of the subject's motion was used for the pitch, yaw, and roll angles.Each conversion from radian to angle degree was carried out by multiplying 180° and divided by pi in a numerical program.For example, as denoted in Eqs. ( 1) and ( 2), the Euler pitch and Euler yaw angles based on Euler angle's definition from an accelerometer are treated as state variables in following KF's estimation vector.
( ) During execution, the operations of the KF can be divided into two parts, namely, prediction and correction.In the recursive process, the following notations are employed: (11) k x : posteriori estimate vector at time step k A k : state transition matrix at time step k, A ∈ R n × n B k : input control matrix at time step k, B ∈ R n × l z k : measurement vector at time step k H k : measurement matrix at time step k v k : measurement noise at time step k Q k : process noise covariance matrix R k : measurement noise covariance matrix Q k and R k are the effects of the external disturbance noise and measurement noise, respectively, on the system.The recursive process of the KF can be explained as follows:

State prediction:
Error covariance matrix prediction:

Correction
State correction: 1 ( ) ( ) (1 ) In the aforementioned procedure, estimation and prediction using the previous time step can be employed for estimating and predicting the subsequent time step; that is, the previous Euler pitch angle is used to determine the subsequent Euler pitch angle.Besides, the rate bias of Euler pitch angle in the KF will take the measurement information by the value of gy from the gyroscope.This means that one can obtain the true rate by subtracting the bias from the gyro measurement.
In short, for the pitch angle indicating the pitch angles of a subject's tibias, we manipulated the original a x , a y , and a z signals from the accelerometer and gy signals of pitch orientation from the IMU gyroscope, while a x and a y signals and g z were for the yaw angle in Eq. ( 2).In practice, we can trust the gyroscope on a short term while we can trust the accelerometer on a long term.Therefore, the g y and g z from the gyroscope are used in the rate bias of the KF.Consequently, the number of walking step counts and the swing frequency of the pitch and yaw angles of users' tibias can be calculated and deployed precisely.

Moving average
Although the signal output of the KF was relatively smooth in Fig. 4(b), on the basis of several experiments and comparisons of many subjects' walking or running tests, a moving average was applied heuristically to prevent a fake swing angle, since a wavy fluctuation without careful calibration and threshold might be counted as one step as depicted in the enlargement of Fig. 4(b).Such counts of a subject's swing motion might vary with different gait features and ground environments.
Therefore, for the safe counting of a fake swing angle, the simplest form of the moving average was applied as follows.
( ) where y(i) is the output signal, x(i) is the input signal, m is set to 3, and N is the total length of the signal.A note is made here that the number of m of more than 3 reached the same moving average effect.For real-time implementation, m is set to 3 in this study.The manipulated pitch angle signal in Fig. 4(c) can be used to determine the real step count through a calibration offset and threshold algorithm.(c)

Calibration offset
The prototype device was attached to the user's instep; in the future, a similar chip with a smaller size might be implanted in an insole.Before the system began its calculations, the initial state of the physical system may have had some nonzero angle between the IMU and the ground.The system was designed to compensate for such angles.Figure 5 graphs the first ten output pitch signals that were acquired in the user's data as filtered using a KF followed by a moving average method.The average for these ten angular motion signals was calculated.Thus, the specific average value for a specific user was obtained.This value was set as the offset value.Predefined data can be used whenever a user begins walking or running with the smart wearable device.Such predefined data can be used if every subsequent output filtered pitch signal must be subtracted from the average of the first ten signals.This algorithm can adapt to different ground levels, different fastening positions of the device, and the individual tibia swing angle of the subject.The enlarged section of Fig. 5 demonstrates that the process of calibration offers a follow-up offset that is almost zero and is ready for the next incoming pitch angle signal; this is used to calculate step count.

Threshold algorithm
As shown in the enlarged section of Fig. 4(c), some bump profile was visible along the swing pitch angle for each tibia motion.A high frequency associated with a small waveform followed by a normal swing-pitch waveform indicates the bump.Therefore, the determination of whether the real-time step is a complete step through a threshold is necessary.A threshold algorithm for step counts was designed by observing and averaging numerous step counts from experiments.Therefore, we considered the pitch angle that was subtracted from the calibration offset from the first ten complete steps, and calculated the difference in the maximum peak value and minimum trough value of the calculated pitch angle in each step.To prevent pseudosignals, the angle difference had to be larger than a certain threshold.After several experiments, the correct threshold was determined, as presented in Fig. 6.This threshold could be multiplied by a gain k times the difference value of the maximum and minimum pitch angles at every step.Figure 7 indicates that the signal of the first step for every subject was less than the average signal when the subject was walking normally, which caused a step counting error.We calculated the threshold by determining the signals from the second step to the eleventh step.Finally, the peak-to-peak pitch difference was multiplied by k for the tested individual's independent settings, as presented in Eq. ( 9).

Step counting algorithm
We designed a step counting algorithm to determine whether any pitch angle would be counted as one step.After obtaining the step threshold of a subject, we compared the realtime pitch angle history with previous and subsequent profiles to determine whether the wave point was a crest or a trough.When the wavepoint was determined to be a trough, the previous recorded peak value was subtracted from the real-time trough value, the peak-to-peak difference was calculated, and the difference was compared with the step threshold value.If the sampled wave crest point associated with the following wave trough was less than the step threshold calculation, it would be recalculated.When determined as the peak-to-peak value, the real-time pitch angle signal and time of the step count were recorded.If the values were greater than the threshold, then the point was determined to be a complete step, the step counter was incremented, and the time was recorded.The device can output the step count, step frequency, step speed, and the distance traveled.

Direction discrimination algorithm
When the human body turns right, the yaw angle decreases instantaneously, and when turning left, the yaw angle increases instantaneously.As shown in Fig. 8, experimental data indicate that the yaw angle is in-phase with the pitch angle when the human body turns right but out-of-phase when the human body turns left.Feature extraction can be further studied by determining the peaks and troughs of these peak-to-peak signals.Presumably, one can set the threshold time on the basis of whether the yaw angle is maintained in-phase or out-of-phase.Therefore, direction discrimination can be achieved by calculation instead of by using an extra magnetic sensor.

Experimental Results
The experiments were initially performed by five healthy subjects.The calculated step counts and swing frequencies (step frequencies) of different subjects were compared.From the experiments, we found that four of the five subjects present almost the same gait cycle features, such as foot contact with ground, toe off, and heel off during the stance phase and swing phase.In contrast, the gait feature for one of the five subjects was slightly different.It was observed that the style this subject walks was that most of his shoe was very parallel to the ground during the gait cycle.Thus, the pitch angle of this subject's tibias did not clearly change during his walking.This caused a difficulty in the calculation of the real pitch angle and the associated step frequency.To strengthen the developed program and have a robust application, we compare two subjects: subject A (the latter one subject) and subject B (one of the former four subjects).
Several experiments as shown in Fig. 9 were conducted using a commercial treadmill and a commercially available shoe with an implanted chip.The off-line FFT step frequency calculations were tested first.Each user has a unique tibia swing motion; thus, each user has a different calibration offset, threshold value, and threshold gain.When the program counted a single step of the user, the program divided the target unit by the time duration between successive steps.Thus, the step rate was calculated precisely.By the aforementioned method, the step frequency of the IMU sensor was counted for a fixed pedestrian speed, and the averaged step frequency was obtained.Finally, we calculated the FFT from the original pitch angle signal of the subject and verified the accuracy of the step frequency using software.
Figure 10 compares the results of the FFT of the pitch angle history, the app message from the commercially available shoe with its implanted chip, and the calculated step frequency from the proposed prototype wearable sensing apparatus.The treadmill speed was set to 4 km/h (left) and 8 km/h (right) for pedestrians A and B. As indicated in Fig. 10, we observe that for the regular walking frequency range from 0.5 to 3.2 Hz, the FFT signals of different pedestrians are different; these can be used as the characteristic signals of different pedestrians at such speeds.However, evaluation for the prototype wearable sensing apparatus indicated that the averaged  speed frequency was similar to the results of FFT frequency from the original pitch angle history.The variation of the chip insole frequency with the FFT frequency may have been caused by the app program, which was based on the number of steps per minute.The initial acceleration of the subject must result in different step counts in different time segments when the treadmill is set to a constant speed (4 or 8 km/h).This result confirms that the tibia swing frequency can be measured reliably and precisely with the wearable sensing device of this research.Tables 1 and 2 tabulate the detailed results of using the wearable sensing apparatus and the commercially available shoe.The step counts of the developed device are precise and accurate, but the proposed wearable sensing device outperformed the commercially available device in the treadmill, testing.
Shoes can be used for gait analysis and evaluation both in walking and running.This research was successful in developing a wearable instep shoe sensing apparatus that can calculate the step count and frequency.The prototype algorithm can be used in future insole chips that analyze the variability of different gait types.By analyzing overall gait dynamics, we can acquire the joint range of motion and therefore calculate the gait patterns of our subjects.In the future, this sensor may be applied to detect the anatomy of legs.We further want to apply the developed shoes for medical analyses of normal and abnormal gaits.Common abnormalities in a patient's normal walking and running gaits can be detected.We intend to enable general clinicians and primary care sports-medicine physicians to perform basic analyses of a patient's normal walking and running gaits and to recognize some common gait abnormalities.

Conclusion
In this research, the step count and frequency of a subject's walking and running gaits were calculated and compared with the results of existing commercial treadmill and insole chip shoe experiments.The accuracy of 85% bolstered confidence.In addition, the speeds of human motion can be observed and displayed on a device indicating athletic performance.This device, worn on two feet, can report human speed directly through wireless transmission.This allows the user or another observer to obtain real-time speed information without using a mobile phone.A threshold algorithm was designed for each individual threshold.Notable accuracy of individual step counts and running information were achieved.The proposed method was validated successfully using FFT.In the future, we intend to apply the results of the study to clinical problems.For example, gait pattern data may assist in detecting abnormal movement and confirm pathologic conditions or diseases.By using our techniques, the distinction between normal anatomy and abnormal anatomy may be possible.Finally, the study is expected to generalize the data of multiple users' various gaits for Big Data analysis on an Internet of Shoes.

Fig. 1 .
Fig. 1.Flow chart of step count, heading, and speed by using a single IMU.

Fig. 2 .
Fig. 2. (Color online) Apparatus for gait speed feature with dual wireless communication on right and left feet.

Fig. 3 .
Fig. 3. Illustration of IMU mobile sensor attached to a subject's instep.

Figure 4 (
a) illustrates the initial output Euler pitch angle raw data.As we can see, some small ripples or miscellaneous signals were acquisitioned and clearly observed.The raw data signal after the KF filtering is illustrated in Fig 4(b).It is obvious that the effect of KF on deburring the subsequent ripples or miscellaneous signal waveform was significant.For a glimpse of the signal from the sampled number of 250 to 300 in Fig. 4(b), the numbered swing pitch angle of a subject's tibias satisfied the actual number of the subject's swing motion from experimental validation.

Fig. 6 .
Fig. 6. (Color online) Threshold value distribution plotted by the difference value of maximum and minimum pitch angles of every step count.

Fig. 7 .
Fig. 7. (Color online) Initial rejected waveform of the calculated pitch angle signal for one of the subjects on the treadmill.

Fig. 8 .
Fig. 8. (Color online) (a) Left turn and (b) right turn signals of the pitch and yaw angles.

Fig. 9 .
Fig. 9. (Color online) Testing the developed apparatus with a treadmill and commercial shoes with chip in insole.

Fig. 10 .
Fig. 10.(Color online) Frequency response calculation by FFT (signal in blue color) of the pitch angle history, the commercial shoe with chip in insole (dashed line in red), and the calculated step frequency (solid line in red) under the treadmill speeds of 4 km/h (left) and 8 km/h (right) for pedestrians A and B.

Table 1
Experiments for step counts with wearable apparatus sensor.

Table 2
Experiments or step counts using commercial shoe with chip in insole.