cloud_visualizer.cc
Go to the documentation of this file.
00001 #include "cloud_visualizer.h"
00002 #include <ros/ros.h>
00003 
00004 namespace rc
00005 {
00006 
00007 CloudVisualizer::CloudVisualizer(const char* name) : viewer_(new visualizer_t(name))
00008 {
00009   viewer_->setBackgroundColor(0.2, 0.2, 0.2);//dark gray
00010   viewer_->addCoordinateSystem(0.1);//make a small coordinate system where the world pose is
00011   viewer_->initCameraParameters();
00012   viewer_->setCameraPosition(-1,0,0,  //1m behind the origin (x is the viewing direction).
00013                               0,0,0,  //look towards the origin.
00014                               0,0,1); //Z is up
00015 }
00016 
00017 void CloudVisualizer::stop(){ stop_ = true; }
00018 
00019 void CloudVisualizer::operator()()
00020 {
00021   while(!viewer_->wasStopped() && ros::ok())
00022   {
00023     boost::this_thread::sleep(boost::posix_time::microseconds(100000));
00024     if(!ros::ok()) break;
00025     boost::mutex::scoped_lock guard(viewer_mutex_);
00026     viewer_->spinOnce();
00027   }
00028 }
00029 
00030 void CloudVisualizer::addCloudToViewer(const pointcloud_t::Ptr pointcloud)
00031 {
00032   boost::mutex::scoped_lock guard(viewer_mutex_);
00033   viewer_->removeAllPointClouds();
00034   pcl::visualization::PointCloudColorHandlerRGBField<point_t> rgb(pointcloud);
00035   viewer_->addPointCloud<point_t>(pointcloud, rgb);
00036   viewer_->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3);
00037 }
00038 
00039 void CloudVisualizer::updateCloudInViewer(const pointcloud_t::Ptr pointcloud)
00040 {
00041   boost::mutex::scoped_lock guard(viewer_mutex_);
00042   pcl::visualization::PointCloudColorHandlerRGBField<point_t> rgb(pointcloud);
00043   viewer_->updatePointCloud<point_t>(pointcloud, rgb);
00044 }
00045 
00046 }//namespace rc
00047 


rc_cloud_accumulator
Author(s): Felix Endres
autogenerated on Thu Jun 6 2019 19:56:20