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

Patrick Bouffard bouffard at eecs.berkeley.edu
Mon Oct 25 19:00:56 UTC 2010


Facepalm... Thanks for bearing with me on that.

On Mon, Oct 25, 2010 at 11:47 AM, Josh Faust <jfaust at willowgarage.com> wrote:
>>
>> 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_statusConstPtr& msg =
> event.getMessage();
> Josh
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
>



More information about the ros-users mailing list