Ask Your Question

Is it possible to have 2 nodehandlers for a single node

asked 2011-12-16 06:56:05 -0500

karthik gravatar image

Hi, I was checking one of the question posed in this forum where there was an incomplete code that has 2 node_handlers in a single code. Though i see its wrong in that particular code. i am curious to know if any such situation would arise where this possibility comes. As for as i know 1 node should have 1 node_handler. Correct me if i am wrong.

Thanks, Karthik

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted

answered 2011-12-16 07:29:16 -0500

DimitriProsser gravatar image

If, for example, you had:

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

Then, nh.getParam() would look in the global namespace for a parameter, whereas private_nh.getParam() would look in a private namespace.

This configuration (one global, one private) is most common situation in which I use multiple NodeHandles.

edit flag offensive delete link more


Thanks!! That makes it clear.
karthik gravatar image karthik  ( 2011-12-16 07:42:45 -0500 )edit

answered 2011-12-16 07:04:07 -0500

dornhege gravatar image

You can have as many node handles as you want, but they will all represent the same node.

edit flag offensive delete link more


can you quote an example where i may have many instead of just one. Thanks
karthik gravatar image karthik  ( 2011-12-16 07:06:03 -0500 )edit

answered 2011-12-17 04:03:15 -0500

updated 2012-02-08 21:25:21 -0500

One node <-> one system process. In any case you could use nodelets: many nodelets (threads) in a node in a process.

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


Asked: 2011-12-16 06:56:05 -0500

Seen: 1,811 times

Last updated: Feb 08 '12