# IMU gravity sensing

How are IMUs used to sense the direction of gravity? I have read a number of articles that talk about using IMU for orientation of flying robotics but I do not understand how. Could someone explain how?

To be more concrete, how can we differentiate between acceleration of the vehicle and gravity?

• i think that you cannot differentiate the two directly Jun 8 at 0:13

That is partly possible if you fuse linear acceleration and angular velocity.

1. Estimate the gravity direction from IMU when the robot is stationary. Now you know the gravity direction.

2. Once your robot starts to move around, your IMU will give you the estimation of acceleration where gravity and real acceleration are mixed. How to extract the real acceleration?

3. Estimate your robot orientation by accumulating angular velocity from a gyrometer. Now you know where is the gravity direction with respect to your flying robot body frame.

4. Rotate a gravity vector [0 0 -9.81] into your current robot body frame.

5. Substrat your rotated gravity vector from the acceleration.

6. Now you have a pure real acceleration without gravity.

This works only for a few seconds or minutes due to the accumulated errors of the gyrometer. You need extra sensors such as a camera to continuously compensate the IMU bias and get the correct acceleration.

• The problem is it's never stationary, I have seen drones use IMU for leveling but it's not at all clear how. Jun 8 at 6:21
• It only needs to be stationary in the beginning. 100ms seconds before take-off is enough to estimate the gravity direction. There is no other way as far as I know. Jun 8 at 6:28