Ask Your Question
0

roscpp node handles convention

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

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 -0600

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 imageDirk Thomas ( 2014-09-10 14:04:49 -0600 )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

Stats

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

Seen: 85 times

Last updated: Sep 10 '14