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

Josh Faust jfaust at willowgarage.com
Mon Oct 25 17:21:02 UTC 2010


>
>
>    const control_mode_statusPtr& msg = event.getMessage(); // this is line
> 172
>

You're assigning to a pointer from a const pointer, which is not allowed.
 If you want a mutable copy you can subscribe with
MessageEvent<control_mode_status> instead of
MessageEvent<control_mode_status const>.  You can also make a copy manually.


> void controlModesStatusCallback(control_mode_status msg)
>  {
>
>    string publisher_name = (*(msg.__connection_header))["callerid"];
>    ROS_INFO_STREAM("Got control mode status, from: " << publisher_name);
>    latest_mode_status[node_mode_map[publisher_name]] = msg;
>  }
>
> .. is there any issue with using this?
>

__connection_header has been deprecated for a while, and will cease to exist
in a future version of roscpp.

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


More information about the ros-users mailing list