Ask Your Question
3

PCLVisualizer within a ROS node does not respond

asked 2012-10-30 07:21:29 -0500

Markus Eich gravatar image

updated 2012-10-30 07:25:39 -0500

Dear all,

I want to visualize my pointcloud data and some objects within a ROS node. The node receives the data via a ROS Topic. The problem I have is how to integrate the viewer properly. In the main class I am using a member variable for the viewer and one thread which should update the view.

boost::shared_ptr<boost::thread> visualizer_thread_;
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer_;

In the constructor of my class (basically a segmentation class) I initialize the viewer and start the thread to do the update.

 viewer_= boost::make_shared<pcl::visualization::PCLVisualizer>("Cylinder Viewer");
 visualizer_thread_.reset(new boost::thread(boost::bind(&CylinderSegmentation::visualize,this)));

In the visualization thread I do basically an spin operation on the view

/** Visualizer Thread for the objects
*
*/
void visualize(){
   ros::Rate r(40);
   viewer_->setBackgroundColor(10.5,0.5,1.0);
   viewer_->addCoordinateSystem(1.0);     
   while (!viewer_->wasStopped()){
      viewer_->spinOnce();
      r.sleep();
   }     
   std::cout<<"Stopped the Viewer"<<std::endl;
 }

When I close the viewer window, I receive the message "Stopped the Viewer" but the window does not close. I cannot even add something to the window to be shown. Is there something wrong I do about the usage of the PCLViewer?

Cheers,

Markus

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-11-21 22:18:15 -0500

christiank gravatar image

Hi Markus,

I had the same problem. I solved it by creating the visualizer in my thread function, e.g. your visualize(). Would be interesting to know the reason of this problem.

Cheers, Christian

edit flag offensive delete link more

Comments

1

Could you post an example? I'm dealing with the same issue. Thanks!

vkee gravatar image vkee  ( 2016-06-30 07:52:42 -0500 )edit

@vkee did you get it working?

jtim gravatar image jtim  ( 2017-01-23 11:58:39 -0500 )edit
1
vkee gravatar image vkee  ( 2017-01-23 12:16:53 -0500 )edit

Thanks found another way quite simple http://stackoverflow.com/a/41814275/2...

jtim gravatar image jtim  ( 2017-01-23 13:40:37 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2012-10-30 07:21:29 -0500

Seen: 1,079 times

Last updated: Nov 21 '12