Ask Your Question

ROS2 equivalent for tf_prefix or tf_remap

asked 2021-08-24 11:12:10 -0500

spoluri gravatar image

updated 2021-08-24 11:49:29 -0500

I am trying to create a multi-robot setup with turtlebot3 on ROS2. Most resources I have found online use ROS1.

My issue is my SLAM node does not create it's map to odom transform under the namespace of robot1 while all the other transforms generated by turtlebot3 are properly created under robot1.

I thought tf_prefix or tf_remap might do the trick but they don't seem to be supported for ROS2. How can I create this map->odom transform with "robot1" prefix?

I see this piece of code in which seems like what I need:

for plugin in root.iter('plugin'):

    if 'ros_diff_drive' in plugin.get('filename'):

        # The only plugin we care for now is 'diff_drive' which is

        # broadcasting a transform between`odom` and `base_footprint`


if args.robot_namespace:

    ros_params = plugin.find('ros')

    ros_tf_remap = ET.SubElement(ros_params, 'remapping')

    ros_tf_remap.text = f'/tf:=/{args.robot_namespace}/tf'

Do I need to do something similar in my SLAM node?

Alternatively: I see a remappings parameter when launching a Node. I tried remapping /map to robot1/map but it does not result in any change in behavior.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2021-08-25 19:13:34 -0500

spoluri gravatar image

I just added remappings like this and it worked: remappings = [('/tf', 'tf'), ('tf_static', 'tf_static')]

edit flag offensive delete link more


if this answered your question, please mark it as check as an answer

kak13 gravatar image kak13  ( 2021-08-25 20:16:19 -0500 )edit

answered 2021-10-12 15:08:47 -0500

shonigmann gravatar image

updated 2021-10-13 11:27:46 -0500

For any new viewers to this question, a feature similar to tf_prefix from ROS1 (now named frame_prefix) has been recently reintroduced in ROS2 Foxy and Galactic. More details can be found here

edit flag offensive delete link more


I afraid that's ROS1 Wiki.

ROS1 and ROS2 have a lot of differences.

Please provide more information solely focus on ros2 as for people like me who started with ROS2 as our first language.

kak13 gravatar image kak13  ( 2021-10-12 15:13:18 -0500 )edit

The ROS2 version of robot_state_publisher exists on the same repository as the ROS1 version, and there is very little in terms of difference in how they are used. There is no ROS2 specific wiki for the robot_state_publisher node that I know of. Simply launch it as you normally would in ROS2, and add a parameter named tf_prefix set to the prefix. This ros2 wiki page gives an example of adding a parameter through your launch file

shonigmann gravatar image shonigmann  ( 2021-10-12 15:24:19 -0500 )edit

For ROS 2 packages, you'd want to use the ROS Index. So p/robot_state_publisher/github-ros-robot_state_publisher.

I can only find a parameter called frame_prefix there. Not tf_prefix. @shonigmann: is that the parameter you are referring to?

gvdhoorn gravatar image gvdhoorn  ( 2021-10-13 01:41:24 -0500 )edit

Yes, my mistake... I got carried away when seeing the 3 PRs getting merged for Noetic, Foxy, and Galactic, but only actually read the Noetic PR where they kept ROS1's tf_prefix notation. I will update my answer and comments accordingly.

shonigmann gravatar image shonigmann  ( 2021-10-13 11:26:27 -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: 2021-08-24 11:12:10 -0500

Seen: 217 times

Last updated: Oct 13 '21