Go Down

Topic: Getting velocity from accelerometer and gyroscope (Read 894 times) previous topic - next topic

kytpau

Hi everyone,
I am Thomas and I am a student of the Hong Kong University of Science and Technology
Currently I need to use the arduino to finish my final year project
I need to get velocity data from the sensor (GY-80) to calculate the calorie burnt
But as a mechanical engineering student, I am a beginner of arduino and even programming
So I would like to ask help from all of you

P.S. my professor said I should study the usage of filter, can anyone help me?

jremington

#1
Mar 12, 2014, 07:54 pm Last Edit: Mar 12, 2014, 09:34 pm by jremington Reason: 1
It is very difficult, and perhaps impossible, to measure a person's velocity directly using the GY-80. For an explanation, see this: http://www.chrobotics.com/library/accel-position-velocity
However, it is possible to use an accelerometer to determine the gait (for example, time between footsteps) and using other information, to estimate a walking or running speed.

bitch_please

is it fine if you just measure the distance and possibly speed of the person using a gps shield???also try a modified pedometer system which could multiply the number of steps a person took with average calories burnt per step. there are various systems you could use but only if you are willing to change your basic design.

kytpau


It is very difficult, and perhaps impossible, to measure a person's velocity directly using the GY-80. For an explanation, see this: http://www.chrobotics.com/library/accel-position-velocity
However, it is possible to use an accelerometer to determine the gait (for example, time between footsteps) and using other information, to estimate a walking or running speed.


um...some one told me that to use to v=u+at to estimate the velocity, so is it applicable?
Also can you provide me so reference code of filter...I found some code but my adruino said that cannot be used.

#include <ADXL345.h>

#include <Wire.h>


const float alpha = 0.5;

double fXg = 0;
double fYg = 0;
double fZg = 0;

ADXL345 acc;

void setup()
{
   acc.begin();
   Serial.begin(9600);
   delay(100);
}

void loop()
{
   double pitch, roll, Xg, Yg, Zg;
   acc.read(&Xg, &Yg, &Zg);

   //Low Pass Filter to smooth out data
   fXg = Xg * alpha + (fXg * (1.0 - alpha));
   fYg = Yg * alpha + (fYg * (1.0 - alpha));
   fZg = Zg * alpha + (fZg * (1.0 - alpha));

   //Roll and Pitch Equations
   roll  = (atan2(-fYg, fZg)*180.0)/M_PI;
   pitch = (atan2(fXg, sqrt(fYg*fYg + fZg*fZg))*180.0)/M_PI;

   Serial.print(pitch);
   Serial.print("   ");
   Serial.println(roll);

   delay(50);
}

kytpau


is it fine if you just measure the distance and possibly speed of the person using a gps shield???also try a modified pedometer system which could multiply the number of steps a person took with average calories burnt per step. there are various systems you could use but only if you are willing to change your basic design.


I cannot use the gps because my topic is to use the mems sensor to help the fat people calculate the calorie.
But my professor said I could consider to use the digital compass. Are the have similar function?

MarkT

There is only one way that's not disasterously bad.

1) Use 6-DoF to maintain an estimate of the orientation via DCM or quaternion
2) Subtract estimate of the gravity vector from the accelerometer output
3) integrate remaining acceleration to give velocity vector estimate
4) integrate velocity estimate to get position vector.

All of this must be done in 3D, any 2D approximation can be laughably wrong
when significant 3D rotation is present.  3D rotation is not commutative for
instance, and 2D cannot even understand that.

Unfortunately the last two steps have drift - once you integrate you will turn
small offsets into longterm drift which will rapidly degrade the information
when two integration steps are used.

You can high-pass filter to remove the worst of the drift, but that then will cancel
any uniform velocity component completely.  However you may be able to get
fairly accurate short-term movement tracks, individual steps for instance, and
then use that to calibrate the model (if you can determine when the foot is
on the ground, that gives you a zero-velocity reference to reset the model and cancel
offsets and drift).

This is all theoretical, it may be harder than I suggest (!)
[ I won't respond to messages, use the forum please ]

jremington

Quote
um...some one told me that to use to v=u+at to estimate the velocity, so is it applicable?

Only if you accurately know the acceleration a, and that is the problem. Evidently, you did not bother to read this link: http://www.chrobotics.com/library/accel-position-velocity  which very clearly explains the problem.

Since you probably won't read it, I'll summarize the main issue. In order to subtract the acceleration due to gravity from the measured acceleration (to get the remainder that generates your walking/running speed) you have to know the absolute orientation of the sensor to much better than 1 degree accuracy. That is not currently possible with hobby-grade accelerometers, magnetometers and rate gyros.

airwuf

If you're only want to get velocity, then use some physical marked points, that a sensor would detect, measure the time between the points and you the velocity. all other is way overshoot.

something like this:
1. sensor detects the point. ---> starts a timer .
2. sensor detects the next point,   -----> read timer value and reset the timer.
3. calculate the time into seconds ( u got the distance between points) calculate ( speed(m/s)  = distance(meter) /time(seconds)  )

repeat step 2 and 3. as much as u like.  you dont need any fancy shit, just use the built in timer and 2 microswitches.

kytpau

Sorry for disappearing for a long time

After taking a deep consideration,now my work should be like that
1) apply filter to both accelerometer and gyroscope
2) tilting
3) Remove the gravity vector
4) calculate the velocity vector by numerical method

So I would ask that is it appropriate?
and is there any suggestion for filter?



jremington

Quote
May I ask for the reason?
Read the previous responses.

michinyon

Quote
That is not currently possible with hobby-grade accelerometers, magnetometers and rate gyros.


I am curious,  what you think are "hobby grade" devices.   These devices are all designed,  and marketed towards,  makers of phones,  cars ( for active suspension and stability control ),  and applications like turning off hard disk drives between sliding off the desk and hitting the floor.  Who is designing and marketing devices towards "hobbyists" ?

Go Up