grasp
All Data Structures Namespaces Functions Modules
visThread.h
1 /*
2  * VISUALIZER THREAD for 3D OBJECT DISPLAY
3  * Copyright (C) 2015 iCub Facility - Istituto Italiano di Tecnologia
4  * Author: Tanis Mar
5  * email: tanis.mar@iit.it
6  * Permission is granted to copy, distribute, and/or modify this program
7  * under the terms of the GNU General Public License, version 2 or any
8  * later version published by the Free Software Foundation.
9  *
10  * A copy of the license can be found at
11  * http://www.robotcub.org/icub/license/gpl.txt
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16  * Public License for more details
17 */
18 
19 #ifndef __PCLVISTHRD_H__
20 #define __PCLVISTHRD_H__
21 
22 // Includes
23 
24 #include <iostream>
25 #include <string>
26 
27 #include <yarp/os/RateThread.h>
28 #include <yarp/os/Network.h>
29 
30 #include <pcl/io/io.h>
31 #include <pcl/io/ply_io.h>
32 #include <pcl/io/pcd_io.h>
33 #include <pcl/point_types.h>
34 #include <pcl/visualization/pcl_visualizer.h>
35 #include <pcl/features/normal_3d.h>
36 #include <pcl/features/moment_of_inertia_estimation.h>
37 
38 
39 class VisThread: public yarp::os::RateThread
40 {
41 protected:
42  // EXTERNAL VARIABLES: set on call
43  std::string id;
44 
45  // INTERNAL VARIABLES:
46  // Mutex cotnrol
47  bool update;
48  boost::mutex updateModelMutex;
49 
50  // Visualizer global variables
51  pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud;
52  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
53 
54  // Flow control flags
55  bool initialized;
56  bool addClouds;
57  bool clearing;
58  bool updatingCloud;
59  bool displayNormals;
60  bool displayBB;
61 
62  // Processing parameters
63  bool minimumBB;
64  double radiusSearch;
65 
69  void updateVis();
70 
75  void plotBB(bool minBB); // Function called within the update loop.
76 
81  void plotNormals(double rS); // Function called within the update loop.
82 
83 public:
84  // CONSTRUCTOR
85  VisThread(int period, const std::string &_cloudname);
86  // INIT
87  virtual bool threadInit();
88  // RUN
89  virtual void run();
90  // RELEASE
91  virtual void threadRelease();
92 
97  void addNormals(double rS); // Function called from main module to set parameters and unlock update
98 
103  void addBoundingBox(bool minBB); // Function called from main module to set parameters and unlock update
104 
108  void clearVisualizer();
109 
114  void updateCloud(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_in);
115 
120  void accumulateClouds(bool accum);
121 
122 
123 };
124 
125 #endif
126 
127