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?
>
>
>    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