我目前正在Ubuntu Ubuntu 22.04.3上使用ROS 2 humble和一个rosbag pointcloud。然而,现在当我启动节点时,我得到了一个**[ros2run] Segmentation fault**。我只得到了错误,当我试图用PCL 1.12.1可视化点云时。如果我注解掉查看器,这个错误没有发生。2你知道什么可能导致这个问题,我如何修复它吗?
#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/point_cloud2.hpp>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/visualization/cloud_viewer.h>
class SimplePointCloudSubscriber : public rclcpp::Node
{
public:
SimplePointCloudSubscriber() : Node("simple_point_cloud_subscriber")
{
subscription_ = this->create_subscription<sensor_msgs::msg::PointCloud2>(
"/velodyne_points", 10,
std::bind(&SimplePointCloudSubscriber::pointCloudCallback, this, std::placeholders::_1));
}
private:
void pointCloudCallback(const sensor_msgs::msg::PointCloud2::SharedPtr msg)
{
RCLCPP_INFO(this->get_logger(), "Received PointCloud2 message");
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>());
pcl::fromROSMsg(*msg, *cloud);
viewer_.showCloud(cloud);
}
rclcpp::Subscription<sensor_msgs::msg::PointCloud2>::SharedPtr subscription_;
pcl::visualization::CloudViewer viewer_{"Simple Cloud Viewer"};
};
int main(int argc, char **argv)
{
rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<SimplePointCloudSubscriber>());
rclcpp::shutdown();
return 0;
}
字符串
1条答案
按热度按时间webghufk1#
您遇到的问题可能是这样的:https://github.com/PointCloudLibrary/pcl/issues/5237 Tldr:VTK中有一个bug(PCL的依赖性),最简单的修复方法是使用较新版本的PCL(至少是PCL 1.13.0)。