ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

IMU linear acceleration to position

asked 2015-06-19 09:57:41 -0500

ozo gravatar image

updated 2015-06-19 10:31:30 -0500

Hey guys,

I have IMU 3dm_GX2 and I want to get position from it. I know that there will be accumulated error and will not be accurate but I need to get the best out of it. I excluded the gravity effect from linear acceleration

     acceleration_x = (msg->linear_acceleration.x + 9.81 * sin(pitch)) * cos(pitch);
     acceleration_y = (msg->linear_acceleration.y - 9.81 * sin(roll))  * cos(roll);

so whats is the best way for integrating linear acceleration twice because the ordinary integration is very bad.

     Velocity_x= Velocity_old_x+acceleration_x*dt;
     x_pos += Velocity_x*dt;

Thanks in advance

edit retag flag offensive close merge delete


You should implement an Inertial Navigation Stabilized (or Strapdown) Platform algorithm to get a sort of reliability.

alextoind gravatar image alextoind  ( 2015-06-19 12:28:36 -0500 )edit

have same issue. Any help to find implementation of that?

Astronaut gravatar image Astronaut  ( 2021-09-21 01:43:17 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-06-19 12:47:39 -0500

ahendrix gravatar image

Integrating acceleration twice to get position is terrible. I think you're discovering just how bad it actually is.

additionally, your current approach integrates the acceleration without taking into account any possible rotation of the sensor, which means that your results will probably be terrible if the sensor rotates at all.

If you have gyro or compass data from the 3dm_GX2, you may be able to feed all of your data into something like a kalman filter to get better results.

edit flag offensive delete link more


Hi. I have almost the same problem. And checking your inputs, you are taking a velocity value, where is it coming from? And how do you exclude the gravity effect ???

jafecasu gravatar image jafecasu  ( 2016-05-26 08:40:24 -0500 )edit

answered 2015-06-22 07:24:12 -0500

ozo gravatar image

I will try using Kalman filter also I think it will be complicated. I considered the yaw because my model is for a car with yaw

    Velocity_x= Velocity_old_x+acceleration_x*dt;
    Displacement_x += Velocity_x*dt;

    x_pos = (Displacement_x * cos(yaw));
    y_pos =  (Displacement_x * sin(yaw));
edit flag offensive delete link more


This is not the movement model for a car. You need to incorporate the yaw when you compute displacement, to get dx and dy, and then integrate x and y separately.

ahendrix gravatar image ahendrix  ( 2015-06-22 08:39:14 -0500 )edit

is this right ?

     Displacement_x +=Velocity_x*cos(yaw)*dt;

     x_pos += Velocity_x*Displacement_x;
ozo gravatar image ozo  ( 2015-06-22 09:01:55 -0500 )edit

No. Why are you multiplying displacement and velocity?

ahendrix gravatar image ahendrix  ( 2015-06-22 09:05:24 -0500 )edit

its not displacment its dx ?

ozo gravatar image ozo  ( 2015-06-22 09:24:04 -0500 )edit


dx = velocity * dt * cos(yaw);
dy = velocity * dt * sin(yaw);
x_pos += dx;
y_pos += dy;
ahendrix gravatar image ahendrix  ( 2015-06-22 09:33:55 -0500 )edit

Thank You I will try it.

ozo gravatar image ozo  ( 2015-06-22 09:57:58 -0500 )edit

Question Tools

1 follower


Asked: 2015-06-19 09:57:41 -0500

Seen: 4,473 times

Last updated: Jun 22 '15