orbslam_semantic_nav_ros 编译出现的问题2

报错内容:

home/ckq/catkin_ws_iit/src/semantic_slam_nav_ros/dense_surfel_mapping/src/surfel_map.cpp:767:46:   required from here
/opt/ros/noetic/include/ros/message_traits.h:125:14: error:const class std::shared_ptr<pcl::PointCloud<pcl::PointXYZI> >’ has no member named ‘__getMD5Sum’
     return m.__getMD5Sum().c_str();

surfel_map.cpp:767的代码如下 以及相关代码:
raw_pointcloud_publish.publish(pointcloud);

ros::Publisher raw_pointcloud_publish;
raw_pointcloud_publish = nh.advertise(“raw_pointcloud”, 10);

这个错误表明你在发布点云消息时遇到了问题。具体来说,编译器抱怨 std::shared_ptr<pcl::PointCloud<pcl::PointXYZI>> 类型没有成员函数 __getMD5Sum。这通常是因为消息类型不匹配或者缺少某些ROS消息特质(message traits)的定义。

根据你提供的代码片段,我注意到你试图使用 PointCloud 作为 ros::Publisher 的模板参数,但并没有指明这个 PointCloud 是什么类型。在 ROS 中,如果你想发布 PCL 点云,通常会使用 sensor_msgs::PointCloud2 类型。

这里有几个可能的解决方案:

  1. 确保你使用正确的消息类型:如果你的 pointcloudpcl::PointCloud<pcl::PointXYZI> 类型,你需要先将它转换为 sensor_msgs::PointCloud2 类型,然后再发布。你可以使用 pcl::toROSMsg 函数来做这个转换。

  2. 检查头文件和命名空间:确保你包含了所有必要的头文件,并正确使用了命名空间。对于PCL和ROS消息,通常需要包括以下头文件:

    #include <ros/ros.h>
    #include <sensor_msgs/PointCloud2.h>
    #include <pcl_conversions/pcl_conversions.h>
    
  3. 修改发布器的类型:更改你的 ros::Publisher 对象的类型,使其匹配你想要发布的消息类型。如果你正在发布转换后的 sensor_msgs::PointCloud2 消息,你的发布器应该是这样定义的:

    ros::Publisher raw_pointcloud_publish;
    raw_pointcloud_publish = nh.advertise<sensor_msgs::PointCloud2>("raw_pointcloud", 10);
    
  4. 发布转换后的点云:当你准备发布点云时,确保它已经被转换为 sensor_msgs::PointCloud2 类型。使用 pcl::toROSMsg 进行转换,并发布转换后的消息:

    sensor_msgs::PointCloud2 output;
    pcl::toROSMsg(*pointcloud, output);
    raw_pointcloud_publish.publish(output);
    

试试这些解决方案,看看是否能解决你的问题。

  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值