stereo-vision
All Data Structures Namespaces Functions Modules Pages
RGBD2PointCloud.hpp
1 #ifndef RGBD_2_POINT_CLOUD_H
2 #define RGBD_2_POINT_CLOUD_H
3 
4 #include <cmath>
5 #include <yarp/os/Bottle.h>
6 #include <yarp/os/RFModule.h>
7 #include <yarp/os/BufferedPort.h>
8 #include <yarp/dev/PolyDriver.h>
9 #include <yarp/sig/Image.h>
10 #include <yarp/sig/Vector.h>
11 #include <yarp/os/Node.h>
12 #include <yarp/os/Publisher.h>
13 #include <yarp/os/Stamp.h>
14 #include <yarp/rosmsg/sensor_msgs/PointCloud2.h>
15 
16 #include "RGBD2PointCloud_IDL.h"
17 
18 class RGBD2PointCloud : public yarp::os::RFModule,
19  public RGBD2PointCloud_IDL
20 {
21 private:
22  bool use_RGBD_client;
23  yarp::dev::PolyDriver RGBD_Client;
24 
25  int width, height;
26  yarp::sig::ImageOf<yarp::sig::PixelRgb> colorImage;
27  yarp::sig::ImageOf<yarp::sig::PixelFloat> depthImage;
28  yarp::os::Port imageFrame_inputPort; // rgb input
29  yarp::os::Port depthFrame_inputPort; // depth input
30  yarp::os::RpcServer rpcPort;
31 
32  yarp::os::Stamp colorStamp, depthStamp;
33 
34  int mirrorX;
35  int mirrorY;
36  int mirrorZ;
37 
38  bool publishTF;
39  std::string rotation_frame_id;
40  yarp::sig::Vector translation;
41  yarp::sig::Vector rotation;
42 
43  double scaleFactor;
44 
45  // ROS stuff
46  std::string frame_id;
47  yarp::os::Node *rosNode;
48  yarp::rosmsg::sensor_msgs::PointCloud2 rosPC_data;
49  yarp::os::Publisher<yarp::rosmsg::sensor_msgs::PointCloud2> pointCloud_outTopic;
50 
51  // Publishing TF is useful only for debugging purposes. In real use case, someone else
52  // robot-aware should publish the tf. Here I just need to publish the frame_id
53  // tf::TransformBroadcaster *tf_broadcaster;
54 
55 public:
56 
57  RGBD2PointCloud();
58  ~RGBD2PointCloud();
59  bool convertRGBD_2_XYZRGB();
60 
61  bool configure(yarp::os::ResourceFinder &rf);
62  bool updateModule();
63  double getPeriod();
64  bool interruptModule();
65  bool close();
66  yarp::os::Bottle get_3D_points(const std::vector<yarp::sig::Vector> &pixels, bool color);
67  bool attach(yarp::os::RpcServer &source);
68 };
69 
70 
71 #endif //RGBD_2_POINT_CLOUD_H