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

What is the naming conventions for tf_prefix vs ns?

asked 2021-08-02 19:14:31 -0500

hwil292 gravatar image

I have not found a clear answer to this, and reading code on Github has merely confused things further.

What is the standard naming convention for tf_trees that relate to a namespace for a robot? Reading into the UR robot package they pass down a "prefix" that is added to the tf tree names, but it adds it as ${prefix}base_link.

Is the convention to send either 1 or 2, and is it expected that you should add the "_" or "/" manually for the prefix value.

  1. robot_1/ for "robot_1/base_link/
  2. robot_1_ "robot_1_base_link"

It make sense to be "robot_1/" as it aligns a bit better with the namespace convention of "/" but I understand tf trees are meant to be treated separately.

edit retag flag offensive close merge delete



Is your question whether / or _ should be used, or something else? I'm not sure I understand the reference to the ur_description approach of using ${prefix}.

gvdhoorn gravatar image gvdhoorn  ( 2021-08-03 02:53:52 -0500 )edit

That is exactly what I am asking

Reference to using ${prefix} within the UR arm urdf file - <link name="${prefix}base_link"/> as an example. Given this it implies I have to append prefix with either "/" or "_" manually.

hwil292 gravatar image hwil292  ( 2021-08-03 15:18:20 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-08-03 07:14:13 -0500

Mike Scheutzow gravatar image

updated 2021-08-03 07:23:40 -0500

I'm not aware of any standard convention for Transform Frame names. The frame names are simple strings, with no concept of hierarchy. You can use "/" character if you like, but it will have no special meaning. It is best to avoid using a "/" as the first character, as internally the ros code strips it off for historical reasons.

Use whatever convention you think looks best.

Note: that there is a parameter named tf_prefix, but it is deprecated. Do not assume this feature works at all.

edit flag offensive delete link more



Use whatever convention you think looks best.

If this is the question the OP wanted to ask, I'd actually suggest to use /. TF2 doesn't care at all, but humans will. Parsing frames with embedded / is much easier than with _, if only for the fact that _ is already used as a replacement for whitespace.

gvdhoorn gravatar image gvdhoorn  ( 2021-08-03 09:21:03 -0500 )edit

This is exactly what the question was. I know it sounds basic, but I really could not find a standard and since I have two answers with alternate suggestions I am happy I didn't just miss something obvious.

I am leaning towards "/" as it makes it easier to align with namespaces from a readability standpoint as well.

@Mike I saw tf_prefix is deprecated generally but within the urdfs people still rely on a "prefix" or "tf_prefix" parameter to set the frame ID of a robot when launching multiple robots (or in my case two UR5s on the same robot). Because the namespace doesn't auto-magically align with frame-ids you still need some way to set a frame-id for a topic pushed to another namespace.

As an example here ( takes in the prefix parameter and sets the tf tree with it. Given it just does ...(more)

hwil292 gravatar image hwil292  ( 2021-08-03 15:16:37 -0500 )edit

To clarify: ${prefix} is not related to tf_prefix (the parameter to robot_state_publisher) at all.

It's likely many setups will assign the same value to them, but that's essentially a "coincidence". There's no direct relationship or coupling (in the code fi).

gvdhoorn gravatar image gvdhoorn  ( 2021-08-04 12:46:09 -0500 )edit

ahh yup, confusing but I see that.

I have gone with "/" just because it makes more sense in my mind, but easy enough to swap within the launch files etc.

Thanks all

hwil292 gravatar image hwil292  ( 2021-08-04 17:33:37 -0500 )edit

Question Tools



Asked: 2021-08-02 19:14:31 -0500

Seen: 1,512 times

Last updated: Aug 03 '21