I have IMU sensor that gives me the raw data such as orientation, Angular and Linear acceleration. Im using ROS and doing some Gazebo UUV simulation. Furthermore, I want to get linear velocity from the raw IMU data. If I do integration over time there will be accumulated error and will not be accurate with the time when for example the robot makes turns. So If I use

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 integrating linear acceleration is very bad,

Velocity_x= Velocity_old_x+acceleration_x*dt;

because integrates the acceleration without taking into account any possible rotation of the sensor, which means that the results will probably be terrible if the sensor rotates at all. So I need some ROS package that takes into account all this transformation and gives me the most accurate estimation of the linear velocity. Any Help? Thanks


1 Answer 1


What you have stumbled upon here is a classic problem in robotics; where am I? Localization is a hard to solve problem. Every sensor will have associated noise and accurately figuring out velocity and position is hard. The most widely used package in ros is robot_localization that will take in arbitrary number of sensor inputs and produce output poses (position and velocity). I'd recommend using the ekf state estimation node.

Unfortunately, if you are stuck with using one IMU, you will have to deal with noise. I'd recommend using additional sources of odometry for better estimates.

  • $\begingroup$ my first step is to use only IMU to estimate velocity. Then will do sensor fusion of IMU and Pressure for example. But first only get linear velocity using only IMU. So docs.ros.org/en/noetic/api/robot_localization/html/index.html and docs.ros.org/en/noetic/api/robot_localization/html/… can give me linear velocity using only IMU? $\endgroup$
    – bob
    Sep 23, 2021 at 6:02
  • $\begingroup$ Maybe. I have never tried it with only 1 source but they claim its possible. So give it a try $\endgroup$ Sep 23, 2021 at 19:53
  • $\begingroup$ That doesn't solve the integration problem. In order to get velocity need to integrate the acceleration. And with the time that error will accumulate and will be huge. So my problem is how to minimize that error. Understand? $\endgroup$
    – bob
    Sep 24, 2021 at 8:51
  • $\begingroup$ I understand your question. I am only sharing a ROS package that I think might be helpful! $\endgroup$ Sep 24, 2021 at 15:07
  • $\begingroup$ ok Im looking for more as mathematical approach to minimize the integration error. $\endgroup$
    – bob
    Sep 25, 2021 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.