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

Revision history [back]

Assuming you are using ROS1: The NodeHandles define how names are resolved in the ROS system. See the wiki for details.

One typical use case is the following:

Create a regular and a private NodeHandle:

ros::NodeHandle nh();
ros::NodeHandle pnh("~");

Topics, services, etc. typically use the regular NodeHandle nh. This ensures that topics etc. are always relative to the nodes namespace.

A private NodeHandle makes the nodes name part of the namespace. This is good for parameters, as they are typically tightly coupled to the node itself and thus having them private avoids collisions.