当前位置:网站首页>ros(24):error: invalid initialization of reference of type ‘xx’ from expression of type ‘xx’

ros(24):error: invalid initialization of reference of type ‘xx’ from expression of type ‘xx’

2022-06-24 19:51:00 biter0088

报错:

error: invalid initialization of reference of type ‘const boost::shared_ptr<const
sensor_driver_msgs::GpswithHeading_<std::allocator<void> > >&’ from expression of type
‘const boost::shared_ptr<const sensor_msgs::NavSatFix_<std::allocator<void> > >’

报错原因:

使用const sensor_msgs::NavSatFix类型来初始化sensor_driver_msgs::GpswithHeading类型数据,这是改代码时马虎造成的。

教训:

(1)有些看起来像c++、python等语言语法报错的,可能只是自己代码写/改错了,不要急着去找语法错误,先硬着头皮看报错

(2)在ros中使用message_filters进行多个话题同步时,需要注意以下三个位置数据类型一致(这次报错就是下面图片中第四行的数据类型没有改为新的)

原网站

版权声明
本文为[biter0088]所创,转载请带上原文链接,感谢
https://blog.csdn.net/BIT_HXZ/article/details/125431740