34 #include <sl/Camera.hpp>
42 static cv::Mat slMat2cvMat(sl::Mat& input) {
43 #if ZED_SDK_MAJOR_VERSION < 3
46 switch (input.getDataType()) {
47 case sl::MAT_TYPE_32F_C1: cv_type = CV_32FC1;
break;
48 case sl::MAT_TYPE_32F_C2: cv_type = CV_32FC2;
break;
49 case sl::MAT_TYPE_32F_C3: cv_type = CV_32FC3;
break;
50 case sl::MAT_TYPE_32F_C4: cv_type = CV_32FC4;
break;
51 case sl::MAT_TYPE_8U_C1: cv_type = CV_8UC1;
break;
52 case sl::MAT_TYPE_8U_C2: cv_type = CV_8UC2;
break;
53 case sl::MAT_TYPE_8U_C3: cv_type = CV_8UC3;
break;
54 case sl::MAT_TYPE_8U_C4: cv_type = CV_8UC4;
break;
59 return cv::Mat(input.getHeight(), input.getWidth(), cv_type, input.getPtr<sl::uchar1>(sl::MEM_CPU));
63 switch (input.getDataType()) {
64 case sl::MAT_TYPE::F32_C1: cv_type = CV_32FC1;
break;
65 case sl::MAT_TYPE::F32_C2: cv_type = CV_32FC2;
break;
66 case sl::MAT_TYPE::F32_C3: cv_type = CV_32FC3;
break;
67 case sl::MAT_TYPE::F32_C4: cv_type = CV_32FC4;
break;
68 case sl::MAT_TYPE::U8_C1: cv_type = CV_8UC1;
break;
69 case sl::MAT_TYPE::U8_C2: cv_type = CV_8UC2;
break;
70 case sl::MAT_TYPE::U8_C3: cv_type = CV_8UC3;
break;
71 case sl::MAT_TYPE::U8_C4: cv_type = CV_8UC4;
break;
76 return cv::Mat(input.getHeight(), input.getWidth(), cv_type, input.getPtr<sl::uchar1>(sl::MEM::CPU));
80 Transform zedPoseToTransform(
const sl::Pose & pose)
83 pose.pose_data.m[0], pose.pose_data.m[1], pose.pose_data.m[2], pose.pose_data.m[3],
84 pose.pose_data.m[4], pose.pose_data.m[5], pose.pose_data.m[6], pose.pose_data.m[7],
85 pose.pose_data.m[8], pose.pose_data.m[9], pose.pose_data.m[10], pose.pose_data.m[11]);
88 #if ZED_SDK_MAJOR_VERSION < 3
89 IMU zedIMUtoIMU(
const sl::IMUData & imuData,
const Transform & imuLocalTransform)
91 sl::Orientation
orientation = imuData.pose_data.getOrientation();
94 Transform opticalTransform(0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0);
96 orientationT = opticalTransform * orientationT;
98 static double deg2rad = 0.017453293;
99 Eigen::Vector4d accT = Eigen::Vector4d(imuData.linear_acceleration.v[0], imuData.linear_acceleration.v[1], imuData.linear_acceleration.v[2], 1);
100 Eigen::Vector4d gyrT = Eigen::Vector4d(imuData.angular_velocity.v[0]*deg2rad, imuData.angular_velocity.v[1]*deg2rad, imuData.angular_velocity.v[2]*deg2rad, 1);
102 cv::Mat orientationCov = (cv::Mat_<double>(3,3)<<
103 imuData.pose_covariance[21], imuData.pose_covariance[22], imuData.pose_covariance[23],
104 imuData.pose_covariance[27], imuData.pose_covariance[28], imuData.pose_covariance[29],
105 imuData.pose_covariance[33], imuData.pose_covariance[34], imuData.pose_covariance[35]);
106 cv::Mat angCov = (cv::Mat_<double>(3,3)<<
107 imuData.angular_velocity_convariance.r[0], imuData.angular_velocity_convariance.r[1], imuData.angular_velocity_convariance.r[2],
108 imuData.angular_velocity_convariance.r[3], imuData.angular_velocity_convariance.r[4], imuData.angular_velocity_convariance.r[5],
109 imuData.angular_velocity_convariance.r[6], imuData.angular_velocity_convariance.r[7], imuData.angular_velocity_convariance.r[8]);
110 cv::Mat accCov = (cv::Mat_<double>(3,3)<<
111 imuData.linear_acceleration_convariance.r[0], imuData.linear_acceleration_convariance.r[1], imuData.linear_acceleration_convariance.r[2],
112 imuData.linear_acceleration_convariance.r[3], imuData.linear_acceleration_convariance.r[4], imuData.linear_acceleration_convariance.r[5],
113 imuData.linear_acceleration_convariance.r[6], imuData.linear_acceleration_convariance.r[7], imuData.linear_acceleration_convariance.r[8]);
120 cv::Vec3d(gyrT[0], gyrT[1], gyrT[2]),
122 cv::Vec3d(accT[0], accT[1], accT[2]),
127 IMU zedIMUtoIMU(
const sl::SensorsData & sensorData,
const Transform & imuLocalTransform)
129 sl::Orientation
orientation = sensorData.imu.pose.getOrientation();
132 Transform opticalTransform(0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0);
134 orientationT = opticalTransform * orientationT;
136 static double deg2rad = 0.017453293;
137 Eigen::Vector4d accT = Eigen::Vector4d(sensorData.imu.linear_acceleration.v[0], sensorData.imu.linear_acceleration.v[1], sensorData.imu.linear_acceleration.v[2], 1);
138 Eigen::Vector4d gyrT = Eigen::Vector4d(sensorData.imu.angular_velocity.v[0]*deg2rad, sensorData.imu.angular_velocity.v[1]*deg2rad, sensorData.imu.angular_velocity.v[2]*deg2rad, 1);
140 cv::Mat orientationCov = (cv::Mat_<double>(3,3)<<
141 sensorData.imu.pose_covariance.r[0], sensorData.imu.pose_covariance.r[1], sensorData.imu.pose_covariance.r[2],
142 sensorData.imu.pose_covariance.r[3], sensorData.imu.pose_covariance.r[4], sensorData.imu.pose_covariance.r[5],
143 sensorData.imu.pose_covariance.r[6], sensorData.imu.pose_covariance.r[7], sensorData.imu.pose_covariance.r[8]);
144 cv::Mat angCov = (cv::Mat_<double>(3,3)<<
145 sensorData.imu.angular_velocity_covariance.r[0], sensorData.imu.angular_velocity_covariance.r[1], sensorData.imu.angular_velocity_covariance.r[2],
146 sensorData.imu.angular_velocity_covariance.r[3], sensorData.imu.angular_velocity_covariance.r[4], sensorData.imu.angular_velocity_covariance.r[5],
147 sensorData.imu.angular_velocity_covariance.r[6], sensorData.imu.angular_velocity_covariance.r[7], sensorData.imu.angular_velocity_covariance.r[8]);
148 cv::Mat accCov = (cv::Mat_<double>(3,3)<<
149 sensorData.imu.linear_acceleration_covariance.r[0], sensorData.imu.linear_acceleration_covariance.r[1], sensorData.imu.linear_acceleration_covariance.r[2],
150 sensorData.imu.linear_acceleration_covariance.r[3], sensorData.imu.linear_acceleration_covariance.r[4], sensorData.imu.linear_acceleration_covariance.r[5],
151 sensorData.imu.linear_acceleration_covariance.r[6], sensorData.imu.linear_acceleration_covariance.r[7], sensorData.imu.linear_acceleration_covariance.r[8]);
158 cv::Vec3d(gyrT[0], gyrT[1], gyrT[2]),
160 cv::Vec3d(accT[0], accT[1], accT[2]),
166 class ZedIMUThread:
public UThread
169 ZedIMUThread(
float rate, sl::Camera * zed, CameraStereoZed * camera,
const Transform & imuLocalTransform,
bool accurate)
172 UASSERT(zed != 0 && camera != 0);
176 accurate_ = accurate;
177 imuLocalTransform_ = imuLocalTransform;
180 virtual void mainLoopBegin()
182 frameRateTimer_.start();
184 virtual void mainLoop()
186 double delay = 1000.0/double(rate_);
187 int sleepTime = delay - 1000.0f*frameRateTimer_.getElapsedTime();
198 while(frameRateTimer_.getElapsedTime() < delay-0.000001)
208 frameRateTimer_.start();
210 #if ZED_SDK_MAJOR_VERSION < 3
212 bool res = zed_->getIMUData(imudata, sl::TIME_REFERENCE_IMAGE);
213 if(res == sl::SUCCESS && imudata.valid)
215 this->postInterIMU(zedIMUtoIMU(imudata, imuLocalTransform_),
UTimer::now());
218 sl::SensorsData sensordata;
219 sl::ERROR_CODE
res = zed_->getSensorsData(sensordata, sl::TIME_REFERENCE::CURRENT);
220 if(res == sl::ERROR_CODE::SUCCESS && sensordata.imu.is_available)
222 camera_->postInterIMUPublic(zedIMUtoIMU(sensordata, imuLocalTransform_),
double(sensordata.imu.timestamp)/10e9);
228 CameraStereoZed * camera_;
230 Transform imuLocalTransform_;
248 return ZED_SDK_MAJOR_VERSION;
261 bool computeOdometry,
264 bool selfCalibration,
266 int texturenessConfidenceThr) :
267 Camera(imageRate, localTransform)
272 usbDevice_(deviceId),
274 resolution_(resolution),
276 selfCalibration_(selfCalibration),
277 sensingMode_(sensingMode),
278 confidenceThr_(confidenceThr),
279 texturenessConfidenceThr_(texturenessConfidenceThr),
280 computeOdometry_(computeOdometry),
282 force3DoF_(odomForce3DoF),
283 imuPublishingThread_(0)
288 #if ZED_SDK_MAJOR_VERSION < 4
293 else if(resolution_ == 5)
298 #if ZED_SDK_MAJOR_VERSION < 3
299 UASSERT(resolution_ >= sl::RESOLUTION_HD2K && resolution_ <sl::RESOLUTION_LAST);
300 UASSERT(quality_ >= sl::DEPTH_MODE_NONE && quality_ <sl::DEPTH_MODE_LAST);
301 UASSERT(sensingMode_ >= sl::SENSING_MODE_STANDARD && sensingMode_ <sl::SENSING_MODE_LAST);
302 UASSERT(confidenceThr_ >= 0 && confidenceThr_ <=100);
304 sl::RESOLUTION
res =
static_cast<sl::RESOLUTION
>(resolution_);
305 sl::DEPTH_MODE qual =
static_cast<sl::DEPTH_MODE
>(quality_);
307 UASSERT(
res >= sl::RESOLUTION::HD2K &&
res < sl::RESOLUTION::LAST);
308 UASSERT(qual >= sl::DEPTH_MODE::NONE && qual < sl::DEPTH_MODE::LAST);
309 #if ZED_SDK_MAJOR_VERSION < 4
310 sl::SENSING_MODE sens =
static_cast<sl::SENSING_MODE
>(sensingMode_);
311 UASSERT(sens >= sl::SENSING_MODE::STANDARD && sens < sl::SENSING_MODE::LAST);
313 UASSERT(sensingMode_ >= 0 && sensingMode_ < 2);
315 UASSERT(confidenceThr_ >= 0 && confidenceThr_ <=100);
316 UASSERT(texturenessConfidenceThr_ >= 0 && texturenessConfidenceThr_ <=100);
322 const std::string & filePath,
326 bool computeOdometry,
329 bool selfCalibration,
331 int texturenessConfidenceThr) :
332 Camera(imageRate, localTransform)
338 svoFilePath_(filePath),
341 selfCalibration_(selfCalibration),
342 sensingMode_(sensingMode),
343 confidenceThr_(confidenceThr),
344 texturenessConfidenceThr_(texturenessConfidenceThr),
345 computeOdometry_(computeOdometry),
347 force3DoF_(odomForce3DoF),
348 imuPublishingThread_(0)
353 #if ZED_SDK_MAJOR_VERSION < 3
354 UASSERT(resolution_ >= sl::RESOLUTION_HD2K && resolution_ <sl::RESOLUTION_LAST);
355 UASSERT(quality_ >= sl::DEPTH_MODE_NONE && quality_ <sl::DEPTH_MODE_LAST);
356 UASSERT(sensingMode_ >= sl::SENSING_MODE_STANDARD && sensingMode_ <sl::SENSING_MODE_LAST);
357 UASSERT(confidenceThr_ >= 0 && confidenceThr_ <=100);
359 sl::RESOLUTION
res =
static_cast<sl::RESOLUTION
>(resolution_);
360 sl::DEPTH_MODE qual =
static_cast<sl::DEPTH_MODE
>(quality_);
362 UASSERT(
res >= sl::RESOLUTION::HD2K &&
res < sl::RESOLUTION::LAST);
363 UASSERT(qual >= sl::DEPTH_MODE::NONE && qual < sl::DEPTH_MODE::LAST);
364 #if ZED_SDK_MAJOR_VERSION < 4
365 sl::SENSING_MODE sens =
static_cast<sl::SENSING_MODE
>(sensingMode_);
366 UASSERT(sens >= sl::SENSING_MODE::STANDARD && sens < sl::SENSING_MODE::LAST);
368 UASSERT(sensingMode_ >= 0 && sensingMode_ < 2);
370 UASSERT(confidenceThr_ >= 0 && confidenceThr_ <=100);
371 UASSERT(texturenessConfidenceThr_ >= 0 && texturenessConfidenceThr_ <=100);
379 if(imuPublishingThread_)
381 imuPublishingThread_->join(
true);
383 delete imuPublishingThread_;
392 if(imuPublishingThread_)
394 imuPublishingThread_->join(
true);
395 delete imuPublishingThread_;
396 imuPublishingThread_=0;
406 sl::InitParameters param;
407 param.camera_resolution=
static_cast<sl::RESOLUTION
>(resolution_);
409 param.depth_mode=(sl::DEPTH_MODE)quality_;
410 #if ZED_SDK_MAJOR_VERSION < 3
411 param.camera_linux_id=usbDevice_;
412 param.coordinate_units=sl::UNIT_METER;
413 param.coordinate_system=(sl::COORDINATE_SYSTEM)sl::COORDINATE_SYSTEM_IMAGE ;
415 param.coordinate_units=sl::UNIT::METER;
416 param.coordinate_system=sl::COORDINATE_SYSTEM::IMAGE ;
418 param.sdk_verbose=
true;
420 param.depth_minimum_distance=-1;
421 param.camera_disable_self_calib=!selfCalibration_;
423 sl::ERROR_CODE r = sl::ERROR_CODE::SUCCESS;
426 UINFO(
"svo file = %s", svoFilePath_.c_str());
427 zed_ =
new sl::Camera();
428 #if ZED_SDK_MAJOR_VERSION < 3
429 param.svo_input_filename=svoFilePath_.c_str();
431 param.input.setFromSVOFile(svoFilePath_.c_str());
433 r = zed_->open(param);
437 #if ZED_SDK_MAJOR_VERSION >= 3
438 param.input.setFromCameraID(usbDevice_);
440 UINFO(
"Resolution=%d imagerate=%f device=%d", resolution_,
getImageRate(), usbDevice_);
441 zed_ =
new sl::Camera();
442 r = zed_->open(param);
445 if(r!=sl::ERROR_CODE::SUCCESS)
447 UERROR(
"Camera initialization failed: \"%s\"", toString(r).
c_str());
453 #if ZED_SDK_MAJOR_VERSION < 3
454 UINFO(
"Init ZED: Mode=%d Unit=%d CoordinateSystem=%d Verbose=false device=-1 minDist=-1 self-calibration=%s vflip=false",
455 quality_, sl::UNIT_METER, sl::COORDINATE_SYSTEM_IMAGE , selfCalibration_?
"true":
"false");
457 if(quality_!=sl::DEPTH_MODE_NONE)
459 zed_->setConfidenceThreshold(confidenceThr_);
462 UINFO(
"Init ZED: Mode=%d Unit=%d CoordinateSystem=%d Verbose=false device=-1 minDist=-1 self-calibration=%s vflip=false",
463 quality_, sl::UNIT::METER, sl::COORDINATE_SYSTEM::IMAGE , selfCalibration_?
"true":
"false");
471 if (computeOdometry_)
473 #if ZED_SDK_MAJOR_VERSION < 3
474 sl::TrackingParameters tparam;
475 tparam.enable_spatial_memory=
false;
476 r = zed_->enableTracking(tparam);
478 sl::PositionalTrackingParameters tparam;
479 tparam.enable_area_memory=
false;
480 r = zed_->enablePositionalTracking(tparam);
482 if(r!=sl::ERROR_CODE::SUCCESS)
484 UERROR(
"Camera tracking initialization failed: \"%s\"", toString(r).
c_str());
488 sl::CameraInformation infos = zed_->getCameraInformation();
489 #if ZED_SDK_MAJOR_VERSION < 4
490 sl::CalibrationParameters *stereoParams = &(infos.calibration_parameters );
492 sl::CalibrationParameters *stereoParams = &(infos.camera_configuration.calibration_parameters );
494 sl::Resolution
res = stereoParams->left_cam.image_size;
496 #if ZED_SDK_MAJOR_VERSION < 4
498 stereoParams->left_cam.fx,
499 stereoParams->left_cam.fy,
500 stereoParams->left_cam.cx,
501 stereoParams->left_cam.cy,
503 this->getLocalTransform(),
504 cv::Size(
res.width,
res.height));
507 stereoParams->left_cam.fx,
508 stereoParams->left_cam.fy,
509 stereoParams->left_cam.cx,
510 stereoParams->left_cam.cy,
511 stereoParams->getCameraBaseline(),
512 this->getLocalTransform(),
513 cv::Size(
res.width,
res.height));
516 #if ZED_SDK_MAJOR_VERSION < 4
517 UINFO(
"Calibration: fx=%f, fy=%f, cx=%f, cy=%f, baseline=%f, width=%d, height=%d, transform=%s",
518 stereoParams->left_cam.fx,
519 stereoParams->left_cam.fy,
520 stereoParams->left_cam.cx,
521 stereoParams->left_cam.cy,
525 this->getLocalTransform().prettyPrint().c_str());
527 UINFO(
"Calibration: fx=%f, fy=%f, cx=%f, cy=%f, baseline=%f, width=%d, height=%d, transform=%s",
528 stereoParams->left_cam.fx,
529 stereoParams->left_cam.fy,
530 stereoParams->left_cam.cx,
531 stereoParams->left_cam.cy,
532 stereoParams->getCameraBaseline(),
535 this->getLocalTransform().prettyPrint().c_str());
538 #if ZED_SDK_MAJOR_VERSION < 3
539 if(infos.camera_model == sl::MODEL_ZED_M)
541 if(infos.camera_model != sl::MODEL::ZED)
544 #if ZED_SDK_MAJOR_VERSION < 4
547 imuLocalTransform_ = this->
getLocalTransform() * zedPoseToTransform(infos.sensors_configuration.camera_imu_transform).
inverse();
550 #if ZED_SDK_MAJOR_VERSION < 4
551 UINFO(
"IMU local transform: %s (imu2cam=%s))",
552 imuLocalTransform_.prettyPrint().c_str(),
553 zedPoseToTransform(infos.camera_imu_transform).prettyPrint().c_str());
555 UINFO(
"IMU local transform: %s (imu2cam=%s))",
556 imuLocalTransform_.prettyPrint().c_str(),
557 zedPoseToTransform(infos.sensors_configuration.camera_imu_transform).prettyPrint().c_str());
561 imuPublishingThread_ =
new ZedIMUThread(200, zed_,
this, imuLocalTransform_,
true);
562 imuPublishingThread_->start();
568 UERROR(
"CameraStereoZED: RTAB-Map is not built with ZED sdk support!");
576 return stereoModel_.isValidForProjection();
587 return uFormat(
"%x", zed_->getCameraInformation ().serial_number);
596 return computeOdometry_;
606 if (computeOdometry_ && zed_)
610 #if ZED_SDK_MAJOR_VERSION < 3
615 sl::TRACKING_STATE tracking_state = zed_->getPosition(
p);
616 if (tracking_state == sl::TRACKING_STATE_OK)
618 if(zed_->grab()!=sl::ERROR_CODE::SUCCESS)
622 sl::POSITIONAL_TRACKING_STATE tracking_state = zed_->getPosition(
p);
623 if (tracking_state == sl::POSITIONAL_TRACKING_STATE::OK)
626 int trackingConfidence =
p.pose_confidence;
628 if (trackingConfidence>0)
630 pose = zedPoseToTransform(
p);
644 covariance = cv::Mat::eye(6, 6, CV_64FC1) * 9999.0f;
650 covariance = cv::Mat::eye(6, 6, CV_64FC1) * 1.0f /
float(trackingConfidence);
651 UDEBUG(
"Run %s (var=%f)", pose.
prettyPrint().c_str(), 1.0f /
float(trackingConfidence));
657 covariance = cv::Mat::eye(6, 6, CV_64FC1) * 9999.0f;
659 UWARN(
"ZED lost! (trackingConfidence=%d)", trackingConfidence);
664 covariance = cv::Mat::eye(6, 6, CV_64FC1) * 9999.0f;
666 UWARN(
"ZED lost! (trackingConfidence=%d)", trackingConfidence);
671 UWARN(
"Tracking not ok: state=\"%s\"", toString(tracking_state).
c_str());
682 #if ZED_SDK_MAJOR_VERSION < 3
683 sl::RuntimeParameters rparam((sl::SENSING_MODE)sensingMode_, quality_ > 0, quality_ > 0, sl::REFERENCE_FRAME_CAMERA);
684 #elif ZED_SDK_MAJOR_VERSION < 4
685 sl::RuntimeParameters rparam((sl::SENSING_MODE)sensingMode_, quality_ > 0, confidenceThr_, texturenessConfidenceThr_, sl::REFERENCE_FRAME::CAMERA);
687 sl::RuntimeParameters rparam(quality_ > 0, sensingMode_ == 1, confidenceThr_, texturenessConfidenceThr_, sl::REFERENCE_FRAME::CAMERA);
693 #if ZED_SDK_MAJOR_VERSION < 3
694 bool res = zed_->grab(rparam);
699 res = zed_->grab(rparam);
706 sl::Timestamp timestamp;
707 bool imuReceived =
true;
710 res = zed_->grab(rparam);
711 timestamp = zed_->getTimestamp(sl::TIME_REFERENCE::IMAGE);
714 if(imuPublishingThread_ == 0 && !imuLocalTransform_.isNull())
716 sl::SensorsData imudatatmp;
717 res = zed_->getSensorsData(imudatatmp, sl::TIME_REFERENCE::IMAGE);
718 imuReceived =
res == sl::ERROR_CODE::SUCCESS && imudatatmp.imu.is_available && imudatatmp.imu.timestamp.data_ns != 0;
723 if(
res==sl::ERROR_CODE::SUCCESS)
728 #if ZED_SDK_MAJOR_VERSION < 3
729 zed_->retrieveImage(tmp,sl::VIEW_LEFT);
731 zed_->retrieveImage(tmp,sl::VIEW::LEFT);
733 cv::Mat rgbaLeft = slMat2cvMat(tmp);
736 cv::cvtColor(rgbaLeft, left, cv::COLOR_BGRA2BGR);
743 #if ZED_SDK_MAJOR_VERSION < 3
744 zed_->retrieveMeasure(tmp,sl::MEASURE_DEPTH);
746 zed_->retrieveMeasure(tmp,sl::MEASURE::DEPTH);
748 slMat2cvMat(tmp).copyTo(depth);
749 #if ZED_SDK_MAJOR_VERSION < 3
752 data =
SensorData(left, depth, stereoModel_.left(),
this->getNextSeqID(),
double(timestamp)/10e9);
758 #if ZED_SDK_MAJOR_VERSION < 3
759 sl::Mat tmp;zed_->retrieveImage(tmp,sl::VIEW_RIGHT );
761 sl::Mat tmp;zed_->retrieveImage(tmp,sl::VIEW::RIGHT );
763 cv::Mat rgbaRight = slMat2cvMat(tmp);
765 cv::cvtColor(rgbaRight, right, cv::COLOR_BGRA2GRAY);
766 #if ZED_SDK_MAJOR_VERSION < 3
773 if(imuPublishingThread_ == 0)
775 #if ZED_SDK_MAJOR_VERSION < 3
777 res = zed_->getIMUData(imudata, sl::TIME_REFERENCE_IMAGE);
778 if(
res == sl::SUCCESS && imudata.valid)
780 sl::SensorsData imudata;
781 res = zed_->getSensorsData(imudata, sl::TIME_REFERENCE::IMAGE);
782 if(
res == sl::ERROR_CODE::SUCCESS && imudata.imu.is_available)
786 data.setIMU(zedIMUtoIMU(imudata, imuLocalTransform_));
790 if (computeOdometry_ &&
info)
793 #if ZED_SDK_MAJOR_VERSION < 3
794 sl::TRACKING_STATE tracking_state = zed_->getPosition(pose);
795 if (tracking_state == sl::TRACKING_STATE_OK)
797 sl::POSITIONAL_TRACKING_STATE tracking_state = zed_->getPosition(pose);
798 if (tracking_state == sl::POSITIONAL_TRACKING_STATE::OK)
801 int trackingConfidence = pose.pose_confidence;
803 info->odomPose = zedPoseToTransform(pose);
804 if (!
info->odomPose.isNull())
806 #if ZED_SDK_MAJOR_VERSION >=3
807 if(pose.timestamp != timestamp)
809 UWARN(
"Pose retrieve doesn't have same stamp (%ld) than grabbed image (%ld)", pose.timestamp, timestamp);
820 info->odomPose =
info->odomPose.to3DoF();
824 info->odomCovariance = cv::Mat::eye(6, 6, CV_64FC1) * 9999.0f;
826 UDEBUG(
"Init %s (var=%f)",
info->odomPose.prettyPrint().c_str(), 9999.0f);
828 else if(trackingConfidence==0)
830 info->odomCovariance = cv::Mat::eye(6, 6, CV_64FC1) * 9999.0f;
832 UWARN(
"ZED lost! (trackingConfidence=%d)", trackingConfidence);
836 info->odomCovariance = cv::Mat::eye(6, 6, CV_64FC1) * 1.0f /
float(trackingConfidence);
837 UDEBUG(
"Run %s (var=%f)",
info->odomPose.prettyPrint().c_str(), 1.0f /
float(trackingConfidence));
842 info->odomCovariance = cv::Mat::eye(6, 6, CV_64FC1) * 9999.0f;
844 UWARN(
"ZED lost! (trackingConfidence=%d)", trackingConfidence);
849 UWARN(
"Tracking not ok: state=\"%s\"", toString(tracking_state).
c_str());
855 UERROR(
"CameraStereoZed: Failed to grab images after 2 seconds!");
859 UWARN(
"CameraStereoZed: end of stream is reached!");
863 UERROR(
"CameraStereoZED: RTAB-Map is not built with ZED sdk support!");