ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
If its no problem for your that the data is copied you can do something like:
sensor_msgs::ImageConstPtr your_const_pointer( new sensor_msgs::Image( source_image ) );
Note that, this calls the copy constructor of sensor_msgs::Image thereby copying the underlying data. (But I guess its Ok for you because you want ConstPtr)
If you need a shared pointer that can modify the data in your original object this is not possible in this way because you cannot (safely) create a shared_pointer for a object you do not have the ownership for ( Unless you already have a shared_pointer (, which you don't,) and the object you intend to point to does not implement boost enable_shared_from_this<y> (which message types do not) ) ....