Ask Your Question

roscpp node handles convention

asked 2014-09-10 13:42:41 -0500

Pototo gravatar image

I want to know what is the convention for creating ROS node handles. I have my ROS nodes, but I realized that for every subscriber/publisher in my node I have created an individual node handle.

I am doing this in one node/program, for example:

ros::NodeHandle motor_nh;
ros::NodeHandle velocity_nh;
ros::NodeHandle vel_callback_nh;
ros::NodeHandle imu_nh;
ros::NodeHandle alarm_sound_nh;

I am not sure if that is the correct usage, or am I supposed to have one single node handle for the entire node/program?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-09-10 13:47:33 -0500

Tom Moore gravatar image

You can use the same node handle for all of your publishers and subscribers.

edit flag offensive delete link more


You basically already use one node handle because all your variables are effectively using the same instance behind the scene.

Dirk Thomas gravatar image Dirk Thomas  ( 2014-09-10 14:04:49 -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

1 follower


Asked: 2014-09-10 13:42:41 -0500

Seen: 156 times

Last updated: Sep 10 '14