Accelerometer and Gyro Data & How to Proceed

Hi all,

I have a project that requires me to detect step occurrence by using accelerometer and gyroscope data.

Below show the raw sensor data for the accelerometer and gyroscope for walking in a straight line.

However the results are quite noisy so i decided to combine altogether by taking the magnitude of it which is
magnitude = sqrt ((accX * accX)+(accY * accY)+(accZ * accZ)+(gyroX * gyroX)+(gyroY * gyroY)+(gyroZ * gyroZ))

and implement and moving average with 10 samples. I was able to detect 19 peaks from the moving average which indicates the occurrence of 19 steps in total. ( as shown below )

How do i implement a code that can actually count these 19 peaks? Or is there any better way to handle the data and detect the steps.

Please advice me, any comments and suggestion will be very helpful. THANKS! :slight_smile:

Calculating the "magnitude" including both the accelerometer and gyro data in the same calculation is physically meaningless. The actual numbers you get would depend on the scaling of the two measured quantities which may be completely inconsistent.

Hi thanks for the reply. Say im able to fuse the accelerometer and gyro data by using a complimentary filter. Would it be useful?

You need to figure out what pattern of behaviour corresponds to "taking a step", and then figure out how to reliably detect and count them.

Where is this pedometer device attached to your body ?

I'd take just one or two steps and spread out the time scale on your graph to make it easier to see what is going on.

Looking at your third graph, you could try something like counting a step each time the red line in the third graph goes from below 31000 to above 32000, and stays there for at least 0.08 seconds, but don't count a step unless at least 0.2 seconds has passed since the previous time you tried to count one.

You need to think about whether a step consists of lifting your foot, or putting it down, or swinging it forward.

If you combine the two properly to get true orientation information you'll be able
do appropriate gesture recognition (which is what this is really) using the angular
data. You do need a proper DCM or quarternion orientation library to get this,
as used in IMUs. That basically uses the gyro only (except the accelerometer corrects
for drift).

However you can take the higher frequency information from the accelerometer
(the spikes) to indicate foot fall I suspect. This would be a second technique to
back up the first.

One of the great signal processing techniques you might want to play with is
correlation, its often imployed to recognise signals buried in noise and interference.

You should take a close look at Sebastian Madgwick's work on gait tracking and analysis. His code is open source so there will be lots of useful information. Gait tracking with x-IMU – x-io Technologies

Is there any code available for gait phase detection (e.g. to detect real-time Heel strike and Toe off detection ) using Arduino UNO?