get ConstPtr for msg field

asked 2016-09-12 14:31:18 -0600

blueberry gravatar image

updated 2016-09-12 14:32:11 -0600

I have a callback function defined as on_string_msg(const std_msgs::String::ConstPtr& msg). I have both std_msgs::String and a self-defined msg which wraps a std_msgs::String field. myMsg.msg { std_msgs/String subField; }

How can I get std_msgs::String::ConstPtr for subField in the myMsg callback function on_myMsg(const myMsg::ConstPtr& msg) so that I can reuse the function on_string_msg(const std_msgs::String::ConstPtr& msg) with the subField?

Basically, I would like to do

on_myMsg(const myMsg::ConstPtr& msg) {

on_string_msg(msg->subFieldConstPtr); // How to achieve this?

}

edit retag flag offensive close merge delete