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

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?

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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

Comments

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

Question Tools

1 follower

Stats

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

Seen: 257 times

Last updated: Sep 10 '14