Rosanswers logo


I am trying to make use of the robot_localization package in order to estimate the position of my robot, unfortunately I have only IMU data of type sensor_msgs/imu.

I tried to configure the package to my situation with imu topic and Icouldn't get reasonable values. I am getting drift in thousands after minutes of running this launch file

  <node pkg="robot_localization" type="ekf_localization_node" name="ekf_se" clear_params="true">
    <rosparam command="load" file="$(find ghattas_localization)/params/ekf.yaml" />


yaml parameters file as following

frequency: 30
sensor_timeout: 0.1
two_d_mode: false
print_diagnostics: true #echo the /diagnostics_agg topic for details

## IMU 0

imu0: /mavros/imu/data
odom_frame: odom_fil            # Defaults to "odom" if unspecified

imu0_config: [false, false, false,
              true,  true,  true,
              false, false, false,
              true,  true,  true,
              true,  true,  true]
imu0_nodelay: false
imu0_differential: false
imu0_relative: true
imu0_queue_size: 5
imu0_pose_rejection_threshold: 0.8                 # Note the difference in parameter names
imu0_twist_rejection_threshold: 0.8                #
imu0_linear_acceleration_rejection_threshold: 0.8  #

# [ADVANCED] Some IMUs automatically remove acceleration due to gravity, and others don't. If yours doesn't, please set
# this to true, and *make sure* your data conforms to REP-103, specifically, that the data is in ENU frame.
imu0_remove_gravitational_acceleration: true

this is the output of my imu sensor

  seq: 76883
    secs: 1553471696
    nsecs: 643437952
  frame_id: "base_link"
  x: -0.00401678876775
  y: 0.00692985006211
  z: 0.18002671006
  w: -0.983629110108
orientation_covariance: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
  x: 0.00155547540635
  y: 0.000273763580481
  z: 0.00184202415403
angular_velocity_covariance: [1.2184696791468346e-07, 0.0, 0.0, 0.0, 1.2184696791468346e-07, 0.0, 0.0, 0.0, 1.2184696791468346e-07]
  x: 0.06864655
  y: -0.08825985
  z: 9.77723005
linear_acceleration_covariance: [8.999999999999999e-08, 0.0, 0.0, 0.0, 8.999999999999999e-08, 0.0, 0.0, 0.0, 8.999999999999999e-08]

and this is the output of the topic /odometry/filtered after mintues of running the launch file mentioned above

  seq: 85355
    secs: 1553471740
    nsecs: 522055387
  frame_id: "odom_fil"
child_frame_id: "base_link"
      x: 5931.45757968
      y: -524851.96709
      z: -83022.4001185
      x: -3.09389446171e-05
      y: -0.00255077454028
      z: 0.0352035710502
      w: 0.999376906466
  covariance: [123428762.20239958, 14303.125278606882, -432994.46126881544, -0.1112066300728559, -2.6491734572265484, 16.50020719493778, 14303.125278592377, 117327753.84775318, -978791.8404554238, 2.6481353764573927, -0.19240492653648597, -0.17084136219435272, -432994.4612687591, -978791.8404553946, 193571512.2978465, -16.679576436670256, 1.385559988732174, 0.0005322252938017805, -0.11120663007285585, 2.648135376457387, -16.679576436670246, 0.03404565909294526, 7.622682310836132e-10, -7.402346050531404e-07, -2.6491734572265524, -0.1924049265364862, 1.3855599887321741, 7.622682310838457e-10, 0.03404565076858593, 1.2813554639653757e-07, 16.50020719493774, -0.1708413621943528, 0.0005322252938017805, -7.402346050531408e-07, 1.2813554639653757e-07, 0.04780378874325498]
      x: -35.3374913315
      y: -431.961762545
      z: -68.7201530547
      x: 0.000821793150427
      y: 0.00030448779041
      z: 0.00136453106476
  covariance: [60.3615155475993, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 60.3615155475993, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 96.5658004680656, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.2180987398690317e-07, -2.4508723486153523e-30, 5.4119992206463886e-27, 0.0, 0.0, 0.0, -2.450872348615352e-30, 1.2180987398690317e-07, -3.281227584477414e-30, 0.0, 0.0, 0.0, 5.411999220646388e-27, -3.281227584477413e-30, 1.218284153041031e-07]

Originally posted by ShehabAldeen on ROS Answers with karma: 97 on 2019-03-24

Post score: 1


1 Answer 1


Rosanswers logo

I think that's an intended behaviour.

You see IMU gives linear and angular acceleration values. These values have to be double integrated to get positions. The problem is, everytime the IMU calculates acceleration, there is an error. And that error gets integrated and multiplied and within seconds, this accumulated error would be so large that your data from IMU will be useless for calculation of the position.

IMU by itself is not a reliable way to measure position. What you can do, however, is fuse this data with odometry ( if it's a wheeled robot) using a kalman filter, to get accurate results.

There's a package for Extended kalman filter (ekf) in ROS. That might help.

Originally posted by parzival with karma: 463 on 2019-03-24

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by ShehabAldeen on 2019-03-25:
The IMU gives orientation, linear acceleration, and angular velocity in my case.

The thing is I can not provide odometry data, and its an underwater robot.

Comment by parzival on 2019-03-25:
In that case, you'll have to implement some other method to estimate position. For example an underwater pinger locator/receiver.

Comment by stevemacenski on 2019-03-25:
Additionally, I would take a second look at those covariances you have for your IMU, they seem susepect at best

Comment by ShehabAldeen on 2019-03-25:
shall I show you another IMU msg you mean?

Comment by stevemacenski on 2019-03-25:
No, but you should take a look at them. I doubt theyre correct. Especially the orientation and accelerometer covariances.

Comment by ShehabAldeen on 2019-03-25:
Actually I don't have that much experience on how to configure covariances


Your Answer

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