# multirobot tf tree

I was reading the ROS Best Practices page for the REP 105 regarding the coordinate frames in order to start building a multi-robot ready tf tree.

I would like to be able to launch two robots within the same roscore environment. This would imply some modifications to the standard tf tree proposed, for the need to distinguish between the frames of one robot from the other.

For what I have seen, one of the common ways to build the robot tf tree is through the URDF files. In there all robot frames are named. From here it comes my first question. As my two robots have exactly the same configuration I wanted to use the same urdf file, but that would duplicate the frame names. Do I have to create a different urdf file for each robot?

Assuming two robots, r1 and r2, then the final tf tree would look something like this:

map
/       \
odom_r1    odom_r2
|             |
|             |
sensors_r1    sensors_r2

I do not specially like this solution, but as the frame names must be unique I can not see a better one.

As I read in several anwsers the odometry node is supposed to send the transforms from odom to base_link, while a localization node would send the transforms from map to odom to correct the odometry drifting over time. In this "new" tf scheme this solution is still valid, the nodes would just require a parameter remapping to work with "odom_r1" instead of just "odom".

I just wanted to be sure my assumptions are coherent with the ROS directions before starting the whole implementation.

edit retag close merge delete

there is a multi_robot_test.launch file I played around with and mentioned in http://answers.ros.org/question/1826/how-to-import-two-pr2-on-gazebo-at-the-same-time
( 2011-08-24 11:59:58 -0600 )edit

Sort by » oldest newest most voted

The tf_prefix is the recommended way of using multiple robots. This will allow you to use the same URDFs (or at least it should), since the prefix will turn things into r1/odom and r2/odom automatically depending on which robot you are on.

See Coordinate Frame Conventions: Naming, the TF FAQ and the mailing list archive for more info on tf_prefix. I've never used it personally, but it should help you split up things across robots without manually changing all of the frame names.

more

( 2011-08-24 01:34:15 -0600 )edit

I have added the tf_prefix to my robot state publisher node. All my frames have been pushed down accordingly.

My launch file is as follows:

<!-- robot urdf model -->
<param name="robot_description" command="cat \$(find urdf_pkg)/urdf/my_robot.urdf" />

<!-- robot state publisher node -->
<node pkg="robot_state_publisher"
type="state_publisher"
name="robot_state_publisher">
<param name="~tf_prefix" value="robot_name" type="str"/>
</node>


I have another node which publishes an odometry message. I have added as well the tf_prefix to its launch file. Common frames correctly match their names as I have seen in the resulting tf tree. However, the odometry message does not get updated with the tf_prefix. The msg.header.frame_id and msg.child_frame_id fields remain the same.

How can I push down frame ids from other topics than the tf::TransformBroadcaster, i.e. the odometry topic message?

more

You need to resolve the frame_id. For that you can use the TransformListener::resolve or tf::resolve methods.
( 2011-08-24 02:14:09 -0600 )edit

@joan hi, im doing the same work as you mentioned above. I'm trying to spawning two erratic robots. tf_prefix is working fine in my case but I have problem in publishing multiple odom e.g. r1/odom. If u have solved that problem please post your solution

( 2012-04-19 11:38:08 -0600 )edit

hi, I am very interested in simulate multiple robots and have the same troubles. How do you solve this? I try without ~ in the tf_prefix and works fine. Like this: <param name="tf_prefix" type="string" value="summit_one" />

( 2012-08-02 00:24:40 -0600 )edit
2

This should really be a separate question and not an answer.

( 2013-03-19 05:20:59 -0600 )edit