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

How to create the odom --> base_link transform in gmapping

asked 2018-10-18 08:44:22 -0600

sberg gravatar image


We are trying to run gmapping using ROS Indigo on Ubuntu 14.04 . The problem we are encountering is that the transform between "odom" and "base frame" is not created correctly. Even though we think it should exist since the transform is visible when echoing rostopic. Should the way we are launching gmapping work or is the problem that the robot is not publishing the transforms correctly? Also how do we create the transform between odom and base_link.


rosrun rqt_tf_tree rqt_tf_tree

yields the following result:

link to tf_tree

As you can see the link between odom and base_link is missing

however when we run

rostopic echo cvc/tf

The transform between odom and base_link is visible

      seq: 0
        secs: 1539863401
        nsecs: 756178000
      frame_id: odom
    child_frame_id: base_link
        <omitted to save space
        <omitted to save space>

We are using the following launch file:

  <param name="robot_description"
    textfile="/home/pd/vmc/Thesis_tools/SLAM_launch/gmapping/charm.urdf" /> 

  <node name="robot_state_publisher" pkg="robot_state_publisher"
    type="robot_state_publisher" /> 

  <node pkg="tf" type="static_transform_publisher" name="base_laser" args="0.23 0 0 0 0 0 1 base_link laser_frame 100" />

  <node name="gmapper" pkg="gmapping" type="slam_gmapping" args=""  output="screen">
    <param name="scan_frame" value="cvc/scan"/>
    <param name="odom_frame" value="odom"/>
    <param name="base_frame" value="base_link"/>
    <param name="map_frame" value="map"/>

  <node name="rviz" pkg="rviz" type="rviz" required="true"
      args="-d gmapping.rviz" />


Thanks in advance for any help.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-10-18 09:28:09 -0600

Delb gravatar image

I don't think your issue comes from base_link->odom but from laser_frame->base_link and since there is an issue with base_link, the link with odom isn't created.

From the gmapping wiki, section 4.1.5 : Required tf transforms :

the frame attached to incoming scans → base_link

usually a fixed value, broadcast periodically by a robot_state_publisher, or a tf static_transform_publisher.

In your launch file you have robot_state_publisher AND static_transform_publisher so I'm pretty sure you redifine a new parent to the laser_frame which often leads to that kind of error in the tf tree. I would suggest to get rid of the static_transform_publisher, if your URDF is correctly made with the laser frame inside that should work fine.

edit flag offensive delete link more


Okay thank you we solved it by removing the robot_state_publisher however then the robot model is no longer visible in Rviz. We tried removing both of them and removing static_transform_publisher resulted in nothing working. Where is the documentation on linking sensors to the robot model?

sberg gravatar image sberg  ( 2018-10-19 02:55:49 -0600 )edit

Normally you have a static_transform_publisher to create a frame so that ROS can link your sensor if it's not represented already in the URDF. robot_state_publisher already do that if you have it in the URDF so you should remove the static_transform instead of robot_state_publisher.

Delb gravatar image Delb  ( 2018-10-19 03:01:48 -0600 )edit

Thanks Yes that is what we are trying to do but failing when using the robot_state_publisher. We think that the problem is that we do not have the sensor correctly repsresented in the URDF-file The error we are getting is Fixed frame [map] does not exist even though the tf_tree looks correct

sberg gravatar image sberg  ( 2018-10-19 04:34:49 -0600 )edit

Can you show the tf tree with robot_state_publisher please ? Also are you only launching the launch file from the question ? You miss providing the odometry information (usually odom comes from the mobile_base if it's a real robot or Gazebo if simulation)

Delb gravatar image Delb  ( 2018-10-19 04:56:06 -0600 )edit

Turns out we had named one of the variables wrong in the URDF file. Still kind of strange that the tf_tree looked good.

Also a big thank you for your time!

sberg gravatar image sberg  ( 2018-10-19 08:34:56 -0600 )edit

Question Tools

1 follower


Asked: 2018-10-18 08:44:22 -0600

Seen: 4,057 times

Last updated: Oct 18 '18