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

Revision history [back]

click to hide/show revision 1
initial version

After an analysis of the various solutions, also thanks to @delb and @gvdhoorn for some suggestions, here are what I think to be the best suited:

  • use a bash command from inside a script: as I said, I'm mainly using Python so that would be achieved via the subprocess module. The idea is to call rosnode list, parse the output and do some string comparison to find the recurring substrings at the start of each line. It needs an extra node dedicated.
  • using the XML-RPC protocol in ROS, throughout the use of appropriate libraries and APIs. The wiki says it's unnecessary to call the APIs directely, so I'll passed this option.
  • setting a parameter in the launch file: this is what I ended up adopting in my project, though it required some workarounds. The syntax is pretty straight-forward:

<rosparam ns="/namespaces" param="$(arg robot_name)" subst_value="true" > $(arg robot_name) </rosparam>

In my case, name and value were the same, but it is in fact arbitrary.

After an analysis of the various solutions, also thanks to @delb and @gvdhoorn for some suggestions, here are what I think to be the best suited:

  • use a bash command from inside a script: as I said, I'm mainly using Python so that would be achieved via the subprocess module. The idea is to call rosnode list, parse the output and do some string comparison to find the recurring substrings at the start of each line. It needs an extra node dedicated.
  • using the XML-RPC protocol in ROS, throughout the use of appropriate libraries and APIs. The wiki says it's unnecessary to call the APIs directely, so I'll passed this option.
  • setting a parameter in the launch file: this is what I ended up adopting in my project, though it required some workarounds. Every time a robot is launched, it sets its namespace to the ROS Parameter Server, so that every node that needs the list of the active namespaces can get the parameter value via rosparam get /namespaces. The .launch syntax is pretty straight-forward:

<rosparam ns="/namespaces" param="$(arg robot_name)" subst_value="true" > $(arg robot_name) </rosparam>

In my case, name and value were the same, but it is in fact arbitrary. arbitrary.

After an analysis of the various solutions, also thanks to @delb and @gvdhoorn for some suggestions, here are what I think to be the best suited:

  • use a bash command from inside a script: as I said, I'm mainly using Python so that would be achieved via the subprocess module. The idea is to call rosnode list, parse the output and do some string comparison to find the recurring substrings at the start of each line. It needs an extra node dedicated.
  • using the XML-RPC protocol in ROS, throughout the use of appropriate libraries and APIs. The wiki says it's unnecessary to call the APIs directely, so I'll I've passed this option.
  • setting a parameter in the launch file: this is what I ended up adopting in my project, though it required some workarounds. Every time a robot is launched, it sets its namespace to the ROS Parameter Server, so that every node that needs the list of the active namespaces can get the parameter value via rosparam get /namespaces. The .launch syntax is pretty straight-forward:

<rosparam ns="/namespaces" param="$(arg robot_name)" subst_value="true" > $(arg robot_name) </rosparam>

In my case, name and value were the same, but it is in fact arbitrary.