Ask Your Question

Revision history [back]

The most common use is to get access to both private and global ROS namespaces.

So a very typical thing to do would be something like this:

node_ = ros::NodeHandlePtr(new ros::NodeHandle);
pnode_ = ros::NodeHandlePtr(new ros::NodeHandle("~"));

with this approach you can publish your topics on the global namespace by using node_->advertise<...>(...), while accessing parameters under private namespace with pnode_->param(...).

Also note that NodeHandlePtr is actually a shared pointer (smart pointer), so it does internal reference counting, thus controlling object's lifetime.

The most common use is to get access to both private and global ROS namespaces.

So a very typical thing to do would be something like this:

node_ = ros::NodeHandlePtr(new ros::NodeHandle);
pnode_ = ros::NodeHandlePtr(new ros::NodeHandle("~"));

with this approach you can publish your topics on the global namespace by using node_->advertise<...>(...), while accessing parameters under private namespace with pnode_->param(...).

Also note that NodeHandlePtr is actually a shared pointer (smart pointer), so it does internal reference counting, thus controlling it controls object's lifetime.