【问题标题】:How to convert ros PointCloud2 to a pcl Pointcloud2 using only pcl 1.8?如何仅使用 pcl 1.8 将 ros PointCloud2 转换为 pcl Pointcloud2?
【发布时间】:2018-10-06 12:07:54
【问题描述】:

我正在使用 ros,但我需要 pcl 1.8 的一些新功能。这就是为什么我使用find_package(PCL 1.8 Required) 像系统依赖项一样包含它并且不能包含任何 ros_pcl 包,因为我在邮件列表中读到了关于这个问题的混合 ros_pcl 和独立 pcl 是一个坏主意。

现在我找不到如何将 ros sensor_msgs::PointCloud2 点云转换为 pcl::PointCloud2 点云的方法。我只发现 void pcl::toPCLPointCloud2 (const pcl::PointCloud< PointT >& cloud, pcl::PCLPointCloud2 & msg) 的类型错误并给我一个编译错误。

现在 pcl_conversion 包中有这个功能:void pcl::fromROSMsg (const sensor_msgs::PointCloud2 &cloud, pcl::PointCloud< T > &pcl_cloud) 我确实使用它成功只是为了尝试一下,但是不能同时使用 pcl 1.8。现在我的问题是:最好自己复制/实现函数fromROSMsg 以便能够使用 1.8,还是有更好的方法来解决这个问题?

【问题讨论】:

    标签: ros point-cloud-library


    【解决方案1】:

    如果您对此仍有疑问,以下提示可能会对您有所帮助,

    在 CMakeLists.txt 中

    find_package(catkin_simple REQUIRED)
    catkin_simple(ALL_DEPS_REQUIRED)
    
    .
    .
    .
    
    find_package(PCL 1.8 REQUIRED)
    include_directories(${PCL_INCLUDE_DIRS})
    link_directories(${PCL_LIBRARY_DIRS})
    add_definitions(${PCL_DEFINITIONS})
    

    然后将${PCL_LIBRARIES} 添加到target_link_libraries

    为了在 1.8 中进行转换,我使用了这种方式,并且成功了。

    pcl::PointCloud<pcl::PointXYZI> in_cloud;
    pcl::fromROSMsg(in_msg, in_cloud);
    

    其中 in_msg 是 const sensor_msgs::PointCloud2&amp; 的一种类型。

    【讨论】:

    • 谢谢,我前段时间解决了这个问题,忘记删除问题了。如果其他人赞成,我会接受这个答案。我不能,因为我无法确认,而且我不会很快与 PCL 合作。
    • fromROSMsg 是否复制数据?
    • @johannes_lalala 是的,它将 ros 消息转换为 pcl 定义的类型 (pcl::PointCloud<:pointxyzi>)
    • 是否有任何等效的 pcl::fromROSMsg(in_msg, in_cloud);在 python 中?
    • @darshanz 你可以试试这个answers.ros.org/question/202787/…
    猜你喜欢
    • 2017-02-07
    • 1970-01-01
    • 2023-01-14
    • 2022-08-17
    • 2015-06-26
    • 2021-11-14
    • 1970-01-01
    • 2022-07-31
    • 2015-03-26
    相关资源
    最近更新 更多