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

You can definitely run nodes in namespaces, and it is quite easy in lauch files. To run a node in a namespace, simply add the ns attribute to a <node> tag. For example:

<node pkg="foo" type="bar" name="my_node" ns="my_namespace" />

would run the bar node with runtime name my_node in the my_namespace namespace. Therefore, if you ran rosnode list now, you would see /my_namespace/my_node.

Running a node in a namespace allows the following:

  • You can run multiple instances of a node with the same name, as long as they are in different namespaces
  • All topics and services the node advertises or subscribes to are also placed in the same namespace, as long as there is no leading slash in the topic or service name string

There are some fancy things you can do with namespaces in launch files, like running a bunch of things in a namespace using <group>, or including other launch files and putting everything in those launch files into a namespace. Check out the roslaunch XML syntax documentation for more http://wiki.ros.org/roslaunch/XML