Ask Your Question
5

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

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

monsterkappa gravatar image

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

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
6

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

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
17

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

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!

dj0405 gravatar imagedj0405 ( 2014-07-08 19:15:07 -0500 )edit

Your Answer

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

Add Answer

Question Tools

Stats

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

Seen: 4,114 times

Last updated: Aug 07 '16