Question

I'm in troubles.

I have searched here for an answer, I read this:

Stream of Cloud Point Visualization using PCL

But I don't understand how doing it.

I need to use a separate thread to visualize with PCL viewer a set of points stored in an a C++ ...this array will be updated at every elaboration from another thread, that clean and refill it with new points.

I need that the PCL window it's a real time visualizer of these points...so, at every new end of elaboration from other thread, visualized update his draw.

This is my code of visualization function on my program:

void VisualizzaPointCl()
{
      //dichiarazione del cloud
    pcl::PointCloud<pcl::PointXYZ>::Ptr basic_cloud_ptr (new pcl::PointCloud<pcl::PointXYZ>);

       //Creazione del cloud

       for (int i=0;i<Clist.size();i++)
       {
            pcl::PointXYZ basic_point;
            basic_point.x = Clist[i].x;
            basic_point.y = Clist[i].y;
            basic_point.z = Clist[i].z;
            basic_cloud_ptr->points.push_back(basic_point);
        }

       //puntatore al cloud
      basic_cloud_ptr->width = (int) basic_cloud_ptr->points.size ();
      basic_cloud_ptr->height = 1;

       //avvia il viewer
      boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
      viewer = simpleVis(basic_cloud_ptr);

  //--------------------
  // -----loop-----
  //--------------------
  while (!viewer->wasStopped ())
  {
    viewer->spinOnce (100,true);
    boost::this_thread::sleep (boost::posix_time::microseconds (100000));
  }
}

If I launch this function at every elaboration, output it's ok but block the flow of my program...

Please help me, how can I don this?

Was it helpful?

Solution

You are running an infinite while loop.

A solution would be putting your function in a separate thread (or just call spinOnce after the rest of your code in every frame).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top