tpp.c:84:使用pcl_ros::transformPointCloud时断言失败

tpp.c:84: Assertion fails when using pcl_ros::transformPointCloud

本文关键字:transformPointCloud 断言 ros 失败 pcl 使用 tpp      更新时间:2023-10-16

我正在尝试创建一个节点来使用tf侦听器并订阅PointCloud2主题,并使用pcl_ros:transformPointCloud函数输出一个已转换为基础框架的新PointCloud2话题。代码运行良好,直到收到消息,当它在第一次调用pcl_ros函数时失败,并显示以下错误消息:

transf_vox_cloud:tpp.c:84:__pthread_tpp_change_priority:断言`new_prio=-1||(new_prio>=fifo_min_prio&&new_prio<=fifo_max_prio'失败。中止(堆芯转储)

#include <ros/ros.h>
#include <tf/tf.h>
#include <tf/transform_listener.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl_ros/transforms.h>
#include <string>
class STP
{
public:
STP()
{
new_PCD_pub = n.advertise<sensor_msgs::PointCloud2>("new_voxel_cloud",500); //define publisher
old_PCD_sub = n.subscribe("voxel_cloud",500, &STP::transformCallback, this); //define subscriber
ros::spin();
}
private: //initialize node, define pub/sub, initialize tf listener, define destination frame for transforms
ros::NodeHandle n;
ros::Publisher new_PCD_pub;
ros::Subscriber old_PCD_sub;
tf::TransformListener *tf_listener;
std::string dest_frame = "/map";
void transformCallback(const sensor_msgs::PointCloud2::ConstPtr& camera_frame_cloud) //callback func to transform received pointcloud
{
sensor_msgs::PointCloud2 map_frame_cloud;
pcl_ros::transformPointCloud(dest_frame, *camera_frame_cloud, map_frame_cloud, *tf_listener);
new_PCD_pub.publish(map_frame_cloud);
}
}; //end callback func
int main(int argc, char** argv){
ros::init(argc, argv, "voxel_cloud_transformer");
STP STPobject;
return 0;
}

您尚未初始化tf_listener,因此您正在取消引用一个null指针。所需的最小更改应为:

public:
STP() :
tf_listener {new tf::TransformListener}
{
new_PCD_pub = n.advertise<sensor_msgs::PointCloud2>("new_voxel_cloud", 500); //define publisher
old_PCD_sub = n.subscribe("voxel_cloud", 500, &STP::transformCallback, this); //define subscriber
ros::spin();
}

但我还没试过,所以请告诉我。

也就是说,我建议让监听器不在堆上(我看不出有什么好的理由),或者如果你这样做了,至少使用智能指针。我还建议初始化n,不要在构造函数内旋转,使用tf2而不是tf,等等。

相关文章:
  • 没有找到相关文章