ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
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.
2 | No.2 Revision |
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.