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

Revision history [back]

Concerning to the question: why topics names are harcorded? the response is easy: because they are dynamically renamable though the "remap" mechanims during the ros node initialization. This mechanism is usually managed by developers through the roslaunch and rosrun tools.

You'll see in most of project all the topic names directly hardcoded. And in fact it can been also seen as a way of improve the readability of the code.

Nonetheless there are some special cases in which is interesting to decouple the topic name using a parameter. For instance when the node has to subscribe to a not fixed number of topics, for instance: input_sources in the costmap node. Here a list of topic names are enumerated in a yaml configuration file.

Concerning to the question: why topics names are harcorded? the response is easy: because they are dynamically renamable though the "remap" mechanims mechanim during the ros node initialization. This mechanism is usually managed by developers through the roslaunch and rosrun tools.

You'll see in most of project all the topic names directly hardcoded. And in fact it can been also seen as a way of improve the readability of the code.

Nonetheless there are some special cases in which is interesting to decouple the topic name using a parameter. For instance when the node has to subscribe to a not fixed number of topics, for instance: input_sources in the costmap node. Here a list of topic names are enumerated in a yaml configuration file.