Robotics StackExchange | Archived questions

Changing default namespace in ROS2

Hi everyone,

Does anybody know if there is an easy way to set a namespace for all the nodes started by a launch file, and by all the other launch files started from there?

In ROS 1 there was the possibility to change the default namespace by setting the environment variable ROS_NAMESPACE, but from a quick test I found that this is not the case anymore in ROS 2 foxy.

For large systems distributed among many launch files it is quite bothersome to go and set the namespace argument for each node in each of the launch files. And namespace remapping works only with ros run, but not with ros launch.

To give you a concrete example: imagine having several machines all running the same software. They should all communicate their data and accept commands under separate topics, so it would be great to have a simple way to configure a different namespace for each of them.

Asked by Raposa on 2021-08-20 02:00:42 UTC

Comments

Answers

Using GroupAction's may be able to do what you're looking for, per the comments here. At minimum, it would provide you with a way to scope the launch configuration of your different machines and provide a single namespace to each node in the group. I believe this would still require some manual instrumentation of your launch files to accept a namespace argument, but I have yet to try it myself.

Asked by shonigmann on 2021-08-20 14:42:16 UTC

Comments