Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove gravity from IMU accelerometer

I've found this beautiful quick way to remove gravity from accelerometer readings. However, I have a 6dof IMU (xyz gyro, xyz accel, no magnetometer) so I am not sure if I can use this code (I tried and it doesn't work correctly).

How would someone remove the gravity component? It's a big obstacle because I can't proceed with my project.


EDIT:

What I have:

  • quaternion depicting the position of aircraft (got that using Extended Kalman Filter)
  • acceleration sensor readings (unfiltered; axes aligned as the plane is aligned; gravity is also incorporated in these readings)

What I want:

  • remove the gravity
  • correct (rotate) the accelerometer readings so it's axes will be aligned with earth's frame of reference's axes
  • read the acceleration towards earth (now Z component of accelerometer)

Basically I want to read the acceleration towards earth no matter how the plane is oriented! But first step is to remove gravity I guess.

like image 349
c0dehunter Avatar asked Sep 27 '12 08:09

c0dehunter


1 Answers

UPDATE: OK, so what you need is to rotate a vector with quaternion. See here or here.

You rotate the measured acceleration vector with the quaternion (corresponding to the orientation) then you substract gravity [0, 0, 9.81] (you may have -9.81 depending on your sign conventions) from the result. That's all.


I have implemented sensor fusion for Shimmer 2 devices based on this manuscript, I highly recommend it. It only uses accelerometers and gyroscopes but no magnetometer, and does exactly what you are looking for.

The resource you link to in your question is misleading. It relies on the quaternion that comes from sensor fusion. In other words, somebody already did the heavy lifting for you, already prepared the gravity compensation for you.

like image 91
Ali Avatar answered Oct 08 '22 11:10

Ali