Ask Your Question
0

when and why do we use two or more ros::NodeHandle for one Node?

asked 2018-11-20 23:24:23 -0600

MahShah gravatar image

updated 2018-11-20 23:49:17 -0600

could you please explain when and why two or more ros::NodeHandle object are used in a program? could you please give some experimental example for these cases?

edit retag flag offensive close merge delete

Comments

1

You tagged this with ros2, but afaik ROS 2 doesn't (yet) have a NodeHandle?

gvdhoorn gravatar imagegvdhoorn ( 2018-11-20 23:40:45 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-11-21 03:25:40 -0600

mgruhler gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-11-20 23:24:23 -0600

Seen: 349 times

Last updated: Nov 21 '18