ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You you can definitely make a concrete message type from a <Message>Ptr
type. Because the original type is a pointer you'll need to copy the entire message to do this, fine for small geometry messages but it will have a performance penalty for larger point cloud or image message types. You can use the copy constructor to create a local concrete instance of a message which is the same as a given <Message>Ptr
type. This is the same as if if was a regular C++ pointer.
void myFunction(geometry_msgs::PosePtr postMsg)
{
geometry_msgs::Pose concretePose = *poseMsg;
// ... do something with concretePose
}
Regarding your second point the geometry_msgs::PosePtr
is actually a boost::shared_ptr<geometry_msgs::Pose>
not a simple C++ pointer. A Boost shared pointer is a smart pointer container that ensures memory will always deleted when no more references to the object exist. You can read more about these here.
Hope this helps.