ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

How to run 2 instances of robot_localization to compare them in Rviz?

asked 2020-12-02 03:14:17 -0500

jorgemia gravatar image

I've got two instances of robot_localization with different sensors being fused (eg. one with just wheel odometry and imu and another one with that + vo). How can I run both at the same time so I can compare them in Rviz, as both can't be publishing the same base_link to odom transform?

Do I need to create two versions of my robot eg. base_link1 and base_link2 and have the parent of both be the odom frame? Then I should be able to visualise both in the odom frame in Rviz?

How would I create two versions of my robot to visualise in Rviz (I've currently got a URDF of my real robot being loaded up when launching my nodes)?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-12-02 17:17:57 -0500

updated 2020-12-02 17:23:36 -0500

A look at REP105 will tell you that there typically are two frames odom and map. It further says that odom should be continuous whereas map can be discontinuous. This is mentioned in the excellent robot_localization wiki too. Per the recommendation there, you can have two instances of robot_localization running at the same time. One will integrate wheel odometry and imu (both continuous) to generate an estimate of your position in the odom frame. This may drift over time! The second instance can integrate these again but with added VO (which might be discontinuous). This will generate an estimate in the map frame.

The image here shows such usage with gps but you can just replace the gps with VO.

You don't have to create two base_links. Both these instances will link to the same base_link and hence only one robot is needed for visualization. I believe this is the right way of setting up the robot_localization package. Of course, you can have just one instance that integrates all the above mentioned sensors in the frame of your choice (but this would go against convention).

This is an example of a launch file that can launch two instances simultaneously:


  <!-- robot_localization for fusing continous data (odom -> base_link) -->
  <node pkg="robot_localization" type="ekf_localization_node" name="ekf_local" clear_params="true" if="true" >
    <!-- param -->
    <rosparam command="load" file="/your/path/params/ekf_local.yaml" />
    <!-- input -->
    <remap from="wheel_odom" to="/your/odom/topic" />
    <remap from="imu" to="/your/imu/topic" />
    <!-- output -->
    <remap from="/odometry/filtered" to="/odometry/filtered/local" />

  <!-- robot_localization for fusing discontinous data (map -> odom) -->
  <node pkg="robot_localization" type="ekf_localization_node" name="ekf_global" clear_params="true" if="true" >
    <!-- param -->
    <rosparam command="load" file="/your/path/params/ekf_global.yaml" />
    <!-- input -->
    <remap from="wheel_odom" to="/your/odom/topic" />
    <remap from="imu" to="/your/imu/topic" />
    <remap from="vo_odom" to="/your/odom/topic" />
    <!-- output -->
    <remap from="/odometry/filtered" to="/odometry/filtered/global" />


An example param file. As in the launch file above, you will need two of these. For the global param file, replace world_frame with map and you should be set.

map_frame: map
odom_frame: odom
base_link_frame: base_link
world_frame: odom

frequency: 20

imu0: imu
imu0_config: [false, false, false,
              true, true, true,
              false, false, false,
              true, true, false,
              true, true, true]
imu0_differential: false
imu0_relative: false
imu0_queue_size: 1
imu0_remove_gravitational_acceleration: false

odom0: wheel_odom
odom0_config: [true, true, false,
               false, false, false,
               false, false, false,
               false, false, false,
               false, false, false]
odom0_differential: false
odom0_queue_size: 1

odom1: vo_odom
odom1_config: [true, true, true,    # x, y, z
               true, true, true,    # r, p, y
               false, false, false, # vx, vy, vz
               false, false, false, # wx, wy, wz
               false, false, false] # ax, ay, az
odom1_differential: false
odom1_queue_size: 2

Make sure you have the P and Q matrices set per your application

edit flag offensive delete link more


Thanks for the answer but by doing that my first instance is going to provide the base_link to odom transform whilst the second instance is going to provide the odom to map transform as you said. Also, my vo is continuous. I've already done something like that before with r_l providing the base_link <-> odom transform and rtabmap providing the odom <-> map transform (as it uses loop closures to correct the localization and can jump), therefore I'm only worried about improving the base_link <-> odom transform. I simply want to compare two different methods of calculating the base_link to odom transform and see which one gives me more accurate results.

jorgemia gravatar image jorgemia  ( 2020-12-02 17:28:33 -0500 )edit

That makes sense. Since you just want to compare, how about still running two instances as I mentioned above and comparing the /odometry/filtered/local and /odometry/filtered/global. The local will not have vo but global would!

If you don't want robot_localization to publish transforms, you can add publish_tf: false to the param file or in the launch file.

Akhil Kurup gravatar image Akhil Kurup  ( 2020-12-02 17:37:17 -0500 )edit

But how would I be able to visually compare the performance of the two robot localization instances? Don't they have to be in the same frame? I just want to essentially plot odometry with vo and odometry without vo in Rviz and compare their performance, but maybe Rviz is not the best way to do that and I should just record the data from the odometry topics and plot it on an actual graph.

jorgemia gravatar image jorgemia  ( 2020-12-03 08:09:01 -0500 )edit

Don't they have to be in the same frame?

As long as a valid tf tree is present, rviz will take care of the transforms for you and you can run a comparison.

Akhil Kurup gravatar image Akhil Kurup  ( 2020-12-03 09:58:01 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-12-02 03:14:17 -0500

Seen: 269 times

Last updated: Dec 02 '20