Robotics StackExchange | Archived questions

PCL not updating

I am able to view my lidar pointcloud using this script but not update it. viewer-> spin() does not seem to be work. Any help will be appreciated.

void callback(const ImageConstPtr& image1, const boost::shared_ptr<const sensor_msgs::PointCloud2>& input)

       pcl::PCLPointCloud2 pcl_pc2;
       pcl_conversions::toPCL(*input,pcl_pc2);
       pcl::PointCloud<pcl::PointXYZ>::Ptr temp_cloud(new pcl::PointCloud<pcl::PointXYZ>);
       pcl::fromPCLPointCloud2(pcl_pc2,*temp_cloud);
       pcl::visualization::CloudViewer viewer ("Simple Cloud Viewer");
       viewer.showCloud(temp_cloud);
       while (!viewer.wasStopped ())
       {

       {

Asked by pnambiar on 2020-08-31 16:26:00 UTC

Comments

Answers

It's not a good idea to run while() in callback. You have to leave callback function since it blocks ros internal event loop (the loop which handles new data and calls your callbacks). That is why you will not get update.

Asked by dtyugin on 2020-08-31 17:50:19 UTC

Comments