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

Two reasons for having different NodeHandle instances in the same node are:

1. namespace scope: This is the most common usecase, and specifies the namespace prefix that applies to all graph resource names that hang from it. This is what @Boris refers to in his answer. For instance, the following two constructs are equivalent:

ros::NodeHandle("/foo").hasParam("bar");
ros::NodeHandle().hasParam("/foo/bar");

2. control callback spinning: This usecase is more advanced, or at least less common. It is possible to assign different callback queues to different NodeHandle instances, so you can for instance have a node in which some callbacks are processed at high-frequency (e.g. control commands), while others are processed at a slower rate.