Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You are trying to assign a shared pointer geometry_msgs::PoseWithCovarianceConstPtr to an instance of geometry_msgs::PoseWithCovarianceStamped.

The operator= is not overloaded to perform deep copies (AFAIK).

The shared pointer cannot know the structure of the underlying object. A slightly annoying, but easy way of working around that is by copying the data field by field, such as:

initial_pose_.header = pose->header;
initial_pose_.pose = pose->pose;

Also note that your global variable named pose has the same name as the shared pointer (message) received in the callback.

Perhaps you could avoid using global variables in the process of making the necessary changes! :-)