grasp
All Data Structures Namespaces Functions Modules
objectReconstr.h
1 /* Copyright: (C) 2014 iCub Facility - Istituto Italiano di Tecnologia
2  * Authors: Ilaria Gori
3  * email: ilaria.gori@iit.it
4  * Permission is granted to copy, distribute, and/or modify this program
5  * under the terms of the GNU General Public License, version 2 or any
6  * later version published by the Free Software Foundation.
7  *
8  * A copy of the license can be found in the file LICENSE located in the
9  * root directory.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14  * Public License for more details
15 */
16 
17 #ifndef __OBJECT_RECONSTRUCTION_MODULE_H__
18 #define __OBJECT_RECONSTRUCTION_MODULE_H__
19 
20 #include <fstream>
21 #include <yarp/os/Vocab.h>
22 #include <yarp/os/RFModule.h>
23 #include <iCub/data3D/SurfaceMeshWithBoundingBox.h>
24 #include <iCub/data3D/minBoundBox.h>
25 #include <reconstructionRoutine.h>
26 #include <visThread.h>
27 
28 #define ACK VOCAB3('a','c','k')
29 #define NACK VOCAB4('n','a','c','k')
30 
31 #define STATE_WAIT 0
32 #define STATE_RECONSTRUCT 1
33 #define STATE_VISUALIZE 2
34 
35 class ObjectReconstr: public yarp::os::RFModule
36 {
37  int currentState;
38  int number;
39  double middlex;
40  double middley;
41  bool write;
42  bool closing;
43  bool visualizationOn;
44  bool computeBB;
45  std::string outputDir;
46  std::string fileName;
47 
48  iCub::data3D::BoundingBox boundingBox;
49 
50  yarp::os::Port rpc;
51  yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > imagePortInLeft;
52  yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > imagePortInRight;
53  yarp::os::BufferedPort<iCub::data3D::SurfaceMeshWithBoundingBox> pointCloudPort;
54  yarp::os::RpcClient segmentationPort;
55 
56  ReconstructionRoutine recRoutine;
57  VisThread *visThrd;
58 
59  //void visualize(boost::shared_ptr<pcl::visualization::PCLVisualizer> tmpViewer, pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr cloud);
60  bool updateCloud();
61  void filter(pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_in,pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_in_filtered, bool second=false);
62  yarp::os::Bottle getPixelList();
63  void savePointsPly(pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud, const std::string& name);
64 
65 public:
66 
67  ObjectReconstr();
68  bool configure(ResourceFinder &rf);
69  bool close();
70  bool updateModule();
71  bool interruptModule();
72  double getPeriod();
73  bool respond(const yarp::os::Bottle& command, yarp::os::Bottle& reply);
74 
75 };
76 
77 #endif
The Definition of the BoundingBox class.
Definition: boundingBox.h:61