unable to find the correct transform between odom and base_link for a mobile robot

asked 2019-11-17 06:10:00 -0600

Spartan_007 gravatar image

updated 2019-11-17 22:07:30 -0600

Hi, This must be a simple problem, but I somehow messed up. I am trying to move pioneer P2DX in Gazebo from say (-5,0) to (5,0). The robot is fitted with two lidars facing 180 deg apart, at two different ends. The important part of the model is below.

  <model name="pioneer2dx_with_lidars">

  <pose>0 0 0 0 0 0</pose>

  <pose>0.2 0 0.30 0 0 0</pose>

  <pose>-0.2 0 0.30 0 0 3.14159</pose>

<joint name="joint1" type="fixed">

<joint name="joint2" type="fixed">


Then, I created a world with other objects along with this robot model. The initial position of the robot was set at (-5,0). Then, I use this package for merging two scans . map was not available initially. So, I wrote a node with br.sendTransform( tf::StampedTransform( tf::Transform(q1, tf::vec(x, y, msg->pose.pose.position.z)), ros::Time::now(), "map", "pioneer2dx_with_lidars/odom")); as well as sendTransform between base_link and the two scanners. The tf tree is given as

image description (left part is important here).

The tf in the rviz looks like image description The problem is that although odometry is good but positions of parents in tftree, show incorrect value. The base_link is separated from odom by huge distance and base_link position is showing to be close to -10 just after starting whereas, it should be close to -5. The merged pointcloudis shown in sky blue. Both seems to move along with odom and base_link.

Any help is highly appreciated.

edit retag flag offensive close merge delete



I highly recommend you to use the robot_state_publisherpackage so you can get rid of tf problems.

When you load your model this package will use the joints in the URDF/Xacro to compute and publish all the TF of your robot (Including the lasers). To link the base_footprint frame with odom frame you can implement a node or a Gazebo model plugin.

From there you can have AMCL for localization and Navigation stack to move the platform with obstacle avoidance.

Weasfas gravatar image Weasfas  ( 2019-11-21 06:05:46 -0600 )edit

All my models are in SDF. I didn't find any easy way to convert SDF-> URDF? Can you suggest any?

Spartan_007 gravatar image Spartan_007  ( 2019-11-21 23:00:50 -0600 )edit

Hi Spartan_007,

If you are using ROS and Gazebo I recommend you to start with Xacrothat will help you mantaining an URDF. The general flow is Xacro -> URDF -> SDF, you can learn more [here].(http://gazebosim.org/tutorials...

Weasfas gravatar image Weasfas  ( 2019-11-22 08:30:51 -0600 )edit

ok, thanks Weasfas. I'll try and update here.

Spartan_007 gravatar image Spartan_007  ( 2019-11-22 08:33:09 -0600 )edit

Hello, I am having some trouble, when I used the package above mentioned in the question and I am using a robot_state_publisher. Is there any solution for this?

Nagarjun gravatar image Nagarjun  ( 2020-10-28 22:21:38 -0600 )edit

@Nagarjun, can you post your problem in a new question so you can be more specific? However, bear in mind that the robot_state_publisher needs the joint states from the joint_state_publisher node, so it is advisable to have both launched.

Weasfas gravatar image Weasfas  ( 2020-10-29 05:10:00 -0600 )edit