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

Is it possible to have 2 nodehandlers for a single node

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

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
4

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

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

Comments

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

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

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

Comments

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 -0600 )edit
0

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

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

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

Question Tools

Stats

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

Seen: 2,056 times

Last updated: Feb 08 '12