Remove gravity from IMU accelerometer
Asked Answered
C

1

9

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.

Cost answered 27/9, 2012 at 8:32 Comment(2)
Are you trying to implement sensor fusion? Or you already have a reliable sensor fusion algorithm and you want to remove gravity from the measured acceleration?Claudy
OK, I believe I have given an answer to your question, please check and comment / ask.Claudy
C
6

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.

Claudy answered 27/9, 2012 at 8:59 Comment(7)
Just to be sure - someone else already implemented Kalman Filter which outputs the Roll, Pitch and Yaw from earth's frame of reference - so sensors are already fused. Does this piece of info have any impact on your answer (possibility to use the code above)?Cost
Hmm. I am not sure I follow. What I am saying is that someone else must have implemented sensor fusion so that the linked Python code works. The linked Python code would require further explanations (for example scaling: is everything measured in g or what happened with the scales?). The simplest way is to try it out and experiment.Claudy
The paper you linked seems to be discussing about gyro drift cancelation - as said, I already get good gyro results through KF, no need to cancel the drift - however, I need to "cancel" the gravity on accelerometers.Cost
This solution sounds elegant but I am concerned about substracting the gravity only from Z in the end. Isn't the gravity incorporated in at two if not all three components of acc. vector? Or does the rotation actually also takes this into account?Cost
The rotation aligns your vector into the Earth frame of reference where gravity only appers in Z. In other words yes, the rotation takes care of that, don't worry.Claudy
Is it possible that you can link the manuscript again? because it is a 404 now.Chiquita
@Chiquita Thanks for warning, two other links were broken too. Fixed, please check!Claudy

© 2022 - 2024 — McMap. All rights reserved.