CameraTango.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef CAMERATANGO_H_
29 #define CAMERATANGO_H_
30 
31 #include <rtabmap/core/Camera.h>
33 #include <rtabmap/utilite/UMutex.h>
37 #include <rtabmap/utilite/UEvent.h>
38 #include <rtabmap/utilite/UTimer.h>
39 #include <boost/thread/mutex.hpp>
40 #include <tango_support_api.h>
41 
42 class TangoPoseData;
43 
44 namespace rtabmap {
45 
46 class PoseEvent: public UEvent
47 {
48 public:
49  PoseEvent(const Transform & pose) : pose_(pose) {}
50  virtual std::string getClassName() const {return "PoseEvent";}
51  const Transform & pose() const {return pose_;}
52 
53 private:
55 };
56 
57 class CameraTangoEvent: public UEvent
58 {
59 public:
60  CameraTangoEvent(int type, const std::string & key, const std::string & value) : type_(type), key_(key), value_(value) {}
61  virtual std::string getClassName() const {return "CameraTangoEvent";}
62  int type() const {return type_;}
63  const std::string & key() const {return key_;}
64  const std::string & value() const {return value_;}
65 
66 private:
67  int type_;
68  std::string key_;
69  std::string value_;
70 
71 };
72 
73 class CameraTango : public Camera, public UThread, public UEventsSender {
74 public:
75  static const float bilateralFilteringSigmaS;
76  static const float bilateralFilteringSigmaR;
77 
78 public:
79  CameraTango(bool colorCamera, int decimation, bool publishRawScan, bool smoothing);
80  virtual ~CameraTango();
81 
82  virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = "");
83  void close(); // close Tango connection
84  void resetOrigin();
85  virtual bool isCalibrated() const;
86  virtual std::string getSerial() const;
87  const CameraModel & getCameraModel() const {return model_;}
88  rtabmap::Transform tangoPoseToTransform(const TangoPoseData * tangoPose) const;
89  void setColorCamera(bool enabled) {if(!this->isRunning()) colorCamera_ = enabled;}
90  void setDecimation(int value) {decimation_ = value;}
91  void setSmoothing(bool enabled) {smoothing_ = enabled;}
92  void setRawScanPublished(bool enabled) {rawScanPublished_ = enabled;}
93  void setScreenRotation(TangoSupportRotation colorCameraToDisplayRotation) {colorCameraToDisplayRotation_ = colorCameraToDisplayRotation;}
94  void setGPS(const GPS & gps);
95 
96  void cloudReceived(const cv::Mat & cloud, double timestamp);
97  void rgbReceived(const cv::Mat & tangoImage, int type, double timestamp);
98  void poseReceived(const Transform & pose);
99  void tangoEventReceived(int type, const char * key, const char * value);
100 
101 protected:
102  virtual SensorData captureImage(CameraInfo * info = 0);
103 
104 private:
105  rtabmap::Transform getPoseAtTimestamp(double timestamp);
106 
107  virtual void mainLoopBegin();
108  virtual void mainLoop();
109 
110 private:
120  cv::Mat cloud_;
121  double cloudStamp_;
122  cv::Mat tangoColor_;
125  boost::mutex dataMutex_;
129  TangoSupportRotation colorCameraToDisplayRotation_;
135 };
136 
137 } /* namespace rtabmap */
138 #endif /* CAMERATANGO_H_ */
Transform originOffset_
Definition: CameraTango.h:133
cv::Mat fisheyeRectifyMapY_
Definition: CameraTango.h:131
Definition: UTimer.h:46
virtual std::string getClassName() const
Definition: CameraTango.h:50
void setScreenRotation(TangoSupportRotation colorCameraToDisplayRotation)
Definition: CameraTango.h:93
Definition: UEvent.h:57
TangoSupportRotation colorCameraToDisplayRotation_
Definition: CameraTango.h:129
USemaphore dataReady_
Definition: CameraTango.h:126
void setRawScanPublished(bool enabled)
Definition: CameraTango.h:92
static const float bilateralFilteringSigmaR
Definition: CameraTango.h:76
const Transform & pose() const
Definition: CameraTango.h:51
cv::Mat fisheyeRectifyMapX_
Definition: CameraTango.h:130
void setSmoothing(bool enabled)
Definition: CameraTango.h:91
boost::mutex dataMutex_
Definition: CameraTango.h:125
CameraTangoEvent(int type, const std::string &key, const std::string &value)
Definition: CameraTango.h:60
const std::string & key() const
Definition: CameraTango.h:63
const CameraModel & getCameraModel() const
Definition: CameraTango.h:87
virtual std::string getClassName() const
Definition: CameraTango.h:61
PoseEvent(const Transform &pose)
Definition: CameraTango.h:49
Transform previousPose_
Definition: CameraTango.h:112
void setColorCamera(bool enabled)
Definition: CameraTango.h:89
static const float bilateralFilteringSigmaS
Definition: CameraTango.h:75
void setDecimation(int value)
Definition: CameraTango.h:90
Transform deviceTColorCamera_
Definition: CameraTango.h:128
const std::string & value() const
Definition: CameraTango.h:64
CameraModel model_
Definition: CameraTango.h:127


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:41:30