vision
SceneReconstruction.hpp
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __SCENE_RECONSTRUCTION_HPP__
4 #define __SCENE_RECONSTRUCTION_HPP__
5 
6 #include <atomic>
7 #include <string>
8 
9 #include <yarp/os/RpcServer.h>
10 #include <yarp/os/RFModule.h>
11 
12 #include <yarp/dev/IRGBDSensor.h>
13 #include <yarp/dev/PolyDriver.h>
14 
15 #include "KinectFusion.hpp"
16 #include "SceneReconstructionIDL.h"
17 
18 namespace roboticslab
19 {
20 
22 {
23 public:
24  enum class update_result { ACQUISITION_FAILED, KINFU_FAILED, SUCCESS };
25 
26  RenderUpdater(KinectFusion & _kinfu, yarp::dev::IRGBDSensor * _sensor) : kinfu(_kinfu), sensor(_sensor) {}
27 
28  virtual ~RenderUpdater() = default;
29  virtual std::string getPortName() const = 0;
30  virtual bool openPort(const std::string & name) = 0;
31  virtual void interruptPort() = 0;
32  virtual void closePort() = 0;
33  virtual update_result update() = 0;
34 
35 protected:
36  KinectFusion & kinfu;
37  yarp::dev::IRGBDSensor * sensor;
38 };
39 
45 class SceneReconstruction : public yarp::os::RFModule,
46  public SceneReconstructionIDL
47 {
48 public:
49  ~SceneReconstruction() override
50  { close(); }
51 
52  bool configure(yarp::os::ResourceFinder & rf) override;
53 
54  double getPeriod() override
55  { return period; }
56 
57  bool updateModule() override;
58 
59  bool interruptModule() override;
60 
61  bool close() override;
62 
63  bool pause() override;
64 
65  bool resume() override;
66 
67  bool reset() override;
68 
69  return_pose getPose() override;
70 
71  return_points getPoints() override;
72 
73  return_points_with_normals getPointsWithNormals() override;
74 
75 private:
76  double period;
77  std::atomic_bool isRunning {false};
78  std::unique_ptr<KinectFusion> kinfu {nullptr};
79 
80  yarp::dev::PolyDriver cameraDriver;
81  yarp::dev::IRGBDSensor * iRGBDSensor {nullptr};
82 
83  std::unique_ptr<RenderUpdater> renderUpdater {nullptr};
84  yarp::os::RpcServer rpcServer;
85 };
86 
87 } // namespace roboticslab
88 
89 #endif // __SCENE_RECONSTRUCTION_HPP__
Definition: KinectFusion.hpp:18
Definition: SceneReconstruction.hpp:22
Exposes Kinect Fusion as a YARP service via RPC.
Definition: SceneReconstruction.hpp:47
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:5