32 #include "rtabmap/core/Version.h"
34 #include <pcl/pcl_config.h>
36 #ifdef RTABMAP_REALSENSE2
37 #include <librealsense2/rs.hpp>
38 #include <librealsense2/hpp/rs_frame.hpp>
48 struct rs2_intrinsics;
49 struct rs2_extrinsics;
58 static bool available();
62 const std::string & deviceId =
"",
67 virtual bool init(
const std::string & calibrationFolder =
".",
const std::string & cameraName =
"");
68 virtual bool isCalibrated()
const;
69 virtual std::string getSerial()
const;
70 virtual bool odomProvided()
const;
71 virtual bool getPose(
double stamp,
Transform & pose, cv::Mat & covariance,
double maxWaitTime = 0.06);
75 void setEmitterEnabled(
bool enabled);
76 void setIRFormat(
bool enabled,
bool useDepthInsteadOfRightImage);
77 void setResolution(
int width,
int height,
int fps = 30);
78 void setDepthResolution(
int width,
int height,
int fps = 30);
79 void setGlobalTimeSync(
bool enabled);
86 void setDualMode(
bool enabled,
const Transform & extrinsics);
87 void setJsonConfig(
const std::string & json);
89 void setImagesRectified(
bool enabled);
90 void setOdomProvided(
bool enabled,
bool imageStreamsDisabled=
false,
bool onlyLeftStream =
false);
92 #ifdef RTABMAP_REALSENSE2
95 void imu_callback(rs2::frame frame);
96 void pose_callback(rs2::frame frame);
97 void frame_callback(rs2::frame frame);
98 void multiple_message_callback(rs2::frame frame);
100 const double & stamp,
102 unsigned int & poseConfidence,
104 int maxWaitTimeMs = 35);
111 #ifdef RTABMAP_REALSENSE2
113 std::vector<rs2::device> dev_;
114 std::string deviceId_;
116 float depth_scale_meters_;
117 cv::Mat depthBuffer_;
122 std::map<double, cv::Vec3f> accBuffer_;
123 std::map<double, cv::Vec3f> gyroBuffer_;
124 std::map<double, std::pair<Transform, unsigned int> > poseBuffer_;
127 double lastImuStamp_;
128 bool clockSyncWarningShown_;
129 bool imuGlobalSyncWarningShown_;
131 bool emitterEnabled_;
135 bool odometryProvided_;
136 bool odometryImagesDisabled_;
137 bool odometryOnlyLeftStream_;
141 int cameraDepthWidth_;
142 int cameraDepthHeight_;
144 bool globalTimeSync_;
147 std::string jsonConfig_;
150 static Transform realsense2PoseRotation_;
151 static Transform realsense2PoseRotationInv_;