Re: [ros-users] How to get copy of message using MessageEven…

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
Delete this message
Reply to this message
Author: User discussions
Date:  
To: User discussions
Subject: Re: [ros-users] How to get copy of message using MessageEvent callback?
>
>
> 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 =
event.getMessage();

Josh