ros在测试订阅话题函数的时候,出现了如上报错,同下
/opt/ros/melodic/include/ros/serialization.h:136:7: error: ‘class boost::shared_ptr<const xxxxx::xxxxx_<std::allocator<void> > >’ has no member named ‘deserialize’
t.deserialize(stream.getData());
这种错误的原因是,你在回调的时候,没有对传进来的消息加const限定,需要在形参前加上const
void doMsg(const std_msgs::String::ConstPtr & msg){
ROS_INFO("接收到的数据:%s", msg->data.c_str());
}