Ask Your Question
3

How to support multiple robots with tf2

asked 2020-10-05 17:12:09 -0600

leemagnusson gravatar image

I've found this question asked multiple times, but haven't found an up to date answer that fully answers the question. ROS messages have namespaces and everything works out great for examples like running two turtle sims. But when using urdfs, transforms, and the robot_state_publisher, there are no namespaces and everything goes to the /tf topic. I'd like to have two overlapping renderings of a robot arm in rviz showing both a sim and a real version. And I'm sure many people would like to have multiple robots on the same roscore using the same urdf for many reasons. How is this best accomplished right now?

Other references: https://answers.ros.org/question/2201... https://github.com/ros2/robot_state_p...

For reference 2, I don't quite understand how that solution helps the situation, so if that is up to date can someone give an example?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2020-10-05 18:50:02 -0600

sloretz gravatar image

There was previously a way of rewriting the frame names for each robot using the tf_prefix in the original tf library, but that was removed in tf2.

One option is to remap the /tf and /tf_static topics for each robot to different topics /alice/tf /alice/tf_static and /bob/tf /bob/tf_static and then write a relay node to bridge them to the global /tf and /tf_static topics. This is what ARIAC 2019 does to support multiple robots on the same ROS core.

A benefit of mapping bridging the topics is you get to pick what data gets bridged and how often. In the use case of visualizing the robots maybe you'd like every tf frame, but some use cases only require robots to have a little bit of each other's data - like each other's position. A drawback of bridging is it adds extra latency because the data has to be copied and sent out again.

edit flag offensive delete link more

Comments

1

Yes, relaying is really not very nice.

However I wouldn't know of any other way.

Note btw that you wouldn't necessarily need to write a new node. The transform node from topic_tools could be used for this (as you're just changing the frame_id).

gvdhoorn gravatar image gvdhoorn  ( 2020-10-06 05:20:24 -0600 )edit
1

But then it still leaves the problem that when you map back to the global /tf, you have frame names that are prefixed and not compatible with the urdf file as is. So I see in that code that I can add a prefix to the URDF like for the UR10. If I modify the urdf like that I can do it without relay, but then I'll have multiple robot descriptions around, which I guess is ok. Or is there another way of dealing with the prefixed frame_ids?

leemagnusson gravatar image leemagnusson  ( 2020-10-06 11:15:36 -0600 )edit
1

Even with tf_prefix you have to make sure your URDF (or: .xacro) matches the TF frames. I'm not sure how that would be different now?

gvdhoorn gravatar image gvdhoorn  ( 2020-10-06 13:01:25 -0600 )edit
1

But then it still leaves the problem that when you map back to the global /tf, you have frame names that are prefixed and not compatible with the urdf file as is

If a node operates on one robot then its tf topics should be remapped to /alice/tf and /alice/tf_static too. For example, maybe each robot gets its own robot_state_publisher instance on /alice and /bob. A tool only needs to be aware of the prefixed frame ids if it needs to operate on both robots at the same time.

but then I'll have multiple robot descriptions around,

It's possible to reuse the same description for both robots. That said, if there are multiple robots then it sounds reasonable to have multiple robot descriptions.

sloretz gravatar image sloretz  ( 2020-10-06 13:11:34 -0600 )edit
1

So then either an xacro or multiple urdf files with unique link names are a part of the recommended solution for this problem? If I wanted to put two UR10 robots in the same rviz session. With the xacro, I would use the ${prefix} option, for /tf frame_ids like alice/base_link and bob/base_link. If I use two urdf files that are calibrated for example, I'd need to have all my link names in those urdf files unique.

leemagnusson gravatar image leemagnusson  ( 2020-10-06 16:04:24 -0600 )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

4 followers

Stats

Asked: 2020-10-05 17:12:09 -0600

Seen: 537 times

Last updated: Oct 05 '20