[ros-users] How to get copy of message using MessageEvent callback?

Josh Faust jfaust at willowgarage.com
Mon Oct 25 18:47:41 UTC 2010

> The first error is still present for me, though:
> /home/bouffard/dev/ros/ros_flyer/flyer_controller/nodes/controller.cpp:
> In member function ‘void
> flyer_controller::Controller::controlModesStatusCallback(const
> ros::MessageEvent<const
> flyer_controller::control_mode_status_<std::allocator<void> > >&)’:
> /home/bouffard/dev/ros/ros_flyer/flyer_controller/nodes/controller.cpp:198:
> error: invalid initialization of reference of type ‘const
> flyer_controller::control_mode_statusPtr&’ from expression of type
> ‘boost::shared_ptr<const
> flyer_controller::control_mode_status_<std::allocator<void> > >’

The error is saying that you're initializing a reference to a pointer from a
reference to a const pointer.  It's an equivalent error to this:

const char* foo = "hello";
char* bar = foo;

blah.cpp:4: error: invalid conversion from ‘const char*’ to ‘char*’

In this case you need to be using:
const flyer_controller::control_mode_status*Const*Ptr& msg =

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20101025/d90c60d8/attachment-0003.html>

More information about the ros-users mailing list