Ask Your Question
4

What is NodeHandle?

asked 2013-07-22 20:38:10 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I make publisher and subscriber. Why do I need to declare NodeHandle? NodeHandele is per topic?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2013-07-22 22:38:30 -0600

Thomas gravatar image

updated 2013-07-22 22:38:48 -0600

A NodeHandle is an object which represents your ROS node. You usually only need one or two node handles.

ros::NodeHandle nh; //public node handle
ros::NodeHandle nhPrivate("~"); // private node handle

If you are a beginner then you can safely ignore the second line. Otherwise, keep in mind that all the topics, services, parameters you manipulate are resolved depending on where your node is placed in the ROS namespace hierarchy (see ROS_NAMESPACE environment variable for instance). By default the node handle will create topics, etc. in your current position but it can be overridden by giving a parameter when creating the ROS NodeHandle. The special character "~" represents your node private space where you can create communication channels without having to worry with name collision or other problems like this.

Anyway, if this is unclear for you: create only one node handle without any argument. See the roscpp tutorial for more information on this matter.

edit flag offensive delete link more

Comments

Hi Thomas, I don't know if you can help me to solve this: http://answers.ros.org/question/157696/actionlib-client-question/. Thanks for your help!

Yantian_Zha gravatar imageYantian_Zha ( 2014-04-26 15:53:18 -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: 2013-07-22 20:38:10 -0600

Seen: 11,280 times

Last updated: Jul 22 '13