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

What are the differences between getNodeHandle() and getPrivateNodeHandle() in nodelet?

asked 2012-04-17 16:02:45 -0600

monsterkappa gravatar image

updated 2016-08-07 14:43:18 -0600

2ROS0 gravatar image

I found some examples of nodelets used both getNodeHandle() and getPrivateNodeHandle () to get the ros::NodeHandle, and I felt that they had the same effects. So what are the exact deferences between getNodeHandle() and getPrivateNodeHandle () in nodelet?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
8

answered 2012-04-17 23:30:55 -0600

Lorenz gravatar image

Private node handles are used for accessing resources (advertising, subscribing topics, parameters, ...) in the nodelet's private namespace. The non-private version should give a node handle in the manager's namespace.

Example: you run a nodelet foo in the manager named bar. When advertising the topic baz using the private node handle, the topic should be something like that:

/bar/foo/baz

When using the non-private node handle, you should get:

/bar/baz

edit flag offensive delete link more

Comments

Thank you, Explains the question I had.

nihalsoans91 gravatar image nihalsoans91  ( 2020-05-11 10:52:22 -0600 )edit
20

answered 2012-04-18 06:07:22 -0600

joq gravatar image

As a general rule (there are exceptions), you should access parameters using getPrivateNodeHandle(), and topics via getNodeHandle().

That is because parameters are (generally) private to your nodelet, while topics will be shared with other nodes and nodelets.

edit flag offensive delete link more

Comments

I wish I can vote for this answer 1000 times!

emacsd gravatar image emacsd  ( 2014-07-08 19:15:07 -0600 )edit

Question Tools

Stats

Asked: 2012-04-17 16:02:45 -0600

Seen: 6,989 times

Last updated: Aug 07 '16