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

What is the proper convention for published topic names?

asked 2019-02-27 03:17:36 -0600

geistmate gravatar image

Hi, I'm working on a wheeled robot using rosserial and I am publishing wheel encoder counts and velocities. I was wondering if there was a proper way to write the topic names I am publishing. For example, should I write it as

std_msgs::Int32 lwheelMsg;
ros::Publisher countsLeftPub("/lwheel_ticks", &lwheelMsg);

or

std_msgs::Int32 lwheelMsg;
ros::Publisher countsLeftPub("lwheel_ticks", &lwheelMsg);

Best, Matthew

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-02-27 03:39:15 -0600

Delb gravatar image

updated 2019-02-27 03:40:07 -0600

I would advise you to read this wiki about names in ROS.

It is not a convention to choose to put a / or nothing before the topic name. It will actually have consequences about the final name of the topic. In your second example you'll probably have your topic in the rostopic list appearring as : /your_node_name/lwheel_ticks whereas with your first example you will just have /lwheel_ticks.

So it's basically up to you to choose wheither you define the topic with /, nothing or even a ~ but you should be aware of what it will induce on the actual name of the topic.

For example : imagine you have a node publishing some velocities to a robot. If you define a global name (i.e. /topic) it will be fine with one robot but what will happened if you have two robots ? You will call your node twice (with a different name of course) and you would have to remap your topic for both node because they would publish on the same topic. If you define a relative name then the topic will be already remapped with your node name so there won't be conflilct and you'll have two topics without changing anything, just by calling your node twice with a different name.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-02-27 03:17:36 -0600

Seen: 3,693 times

Last updated: Feb 27 '19