48 #include <rc_genicam_api/config.h> 60 #include <geometry_msgs/PoseWithCovarianceStamped.h> 66 bool isRcVisardDevice(
const std::string& vendor,
const std::string& model)
68 bool isKuka3DPerception = vendor.find(
"KUKA") != std::string::npos && model.find(
"3d_perception") != std::string::npos;
69 bool isRcVisard = vendor.find(
"Roboception") != std::string::npos && model.find(
"rc_visard") != std::string::npos;
70 return isKuka3DPerception || isRcVisard;
74 std::vector<std::string> discoverRcVisardDevices()
76 std::vector<std::string> device_ids;
80 for (
auto interf : system->getInterfaces())
83 for (
auto dev : interf->getDevices())
85 if (isRcVisardDevice(dev->getVendor(), dev->getModel()))
87 device_ids.push_back(dev->getID());
100 namespace rcd = dynamics;
102 #define ROS_HAS_STEADYTIME (ROS_VERSION_MINIMUM(1, 13, 1) || ((ROS_VERSION_MINOR == 12) && ROS_VERSION_PATCH >= 8)) 106 const std::string& frame_id_prefix,
bool tfEnabled)
108 if (stream ==
"pose")
112 if (stream ==
"pose_ins" || stream ==
"pose_rt" || stream ==
"pose_rt_ins" || stream ==
"imu")
116 if (stream ==
"dynamics" || stream ==
"dynamics_ins")
121 throw std::runtime_error(std::string(
"Not yet implemented! Stream type: ") + stream);
148 std::cout <<
"rc_visard_driver: Shutting down" << std::endl;
185 std::string device =
"";
186 std::string access =
"control";
192 tfPrefix = (ns !=
"") ? ns +
"_" :
"";
194 pnh.
param(
"device", device, device);
195 pnh.
param(
"gev_access", access, access);
204 if (access ==
"exclusive")
208 else if (access ==
"control")
212 else if (access ==
"off")
218 ROS_FATAL_STREAM(
"rc_visard_driver: Access must be 'control', 'exclusive' or 'off': " << access);
261 ROS_INFO(
"rc_visard_driver: Device successfully recovered from previous fail(s)!");
288 bool successfullyOpened =
false;
298 ROS_ERROR_STREAM(
"rc_visard_driver: Failed or lost connection. Trying to recover" 299 " rc_visard_driver from failed state (" 313 if (device.size() == 0)
315 ROS_INFO(
"No device ID given in the private parameter 'device'! Trying to auto-detect a single rc_visard device in the network...");
316 auto device_ids = discoverRcVisardDevices();
317 if (device_ids.size() != 1)
320 throw std::runtime_error(
"Auto-connection with rc_visard device failed because none or multiple devices were found!");
331 throw std::invalid_argument(
"Unknown or non-unique device '" + device +
"'");
355 std_srvs::Trigger::Request dummyreq;
356 std_srvs::Trigger::Response dummyresp;
360 ROS_WARN(
"rc_visard_driver: Could not auto-start dynamics module!");
370 for (
const auto& streamName : availStreams)
378 catch (
const std::exception& e)
380 ROS_WARN_STREAM(
"rc_visard_driver: Unable to create dynamics stream of type " << streamName <<
": " 385 successfullyOpened =
true;
387 catch (std::exception& ex)
414 std_srvs::Trigger::Request dummyreq;
415 std_srvs::Trigger::Response dummyresp;
416 ROS_INFO(
"rc_visard_driver: Autostop dynamics ...");
419 ROS_WARN(
"rc_visard_driver: Could not auto-stop dynamics module!");
422 std::cout <<
"rc_visard_driver: stopped." << std::endl;
432 cfg.camera_fps =
rcg::getFloat(nodemap,
"AcquisitionFrameRate", 0, 0,
true);
434 std::string v =
rcg::getEnum(nodemap,
"ExposureAuto",
true);
435 cfg.camera_exp_auto = (v !=
"Off");
437 cfg.camera_exp_value =
rcg::getFloat(nodemap,
"ExposureTime", 0, 0,
true) / 1000000;
438 cfg.camera_exp_max =
rcg::getFloat(nodemap,
"ExposureTimeAutoMax", 0, 0,
true) / 1000000;
454 cfg.camera_gain_value =
rcg::getFloat(nodemap,
"Gain", 0, 0,
true);
459 ROS_WARN(
"rc_visard_driver: Device does not support setting gain. gain_value is without function.");
462 cfg.camera_gain_value = 0;
471 cfg.camera_wb_auto = (v !=
"Off");
472 rcg::setEnum(nodemap,
"BalanceRatioSelector",
"Red",
true);
473 cfg.camera_wb_ratio_red =
rcg::getFloat(nodemap,
"BalanceRatio", 0, 0,
true);
474 rcg::setEnum(nodemap,
"BalanceRatioSelector",
"Blue",
true);
475 cfg.camera_wb_ratio_blue =
rcg::getFloat(nodemap,
"BalanceRatio", 0, 0,
true);
479 ROS_WARN(
"rc_visard_driver: Not a color camera. wb_auto, wb_ratio_red and wb_ratio_blue are without function.");
482 cfg.camera_wb_auto =
true;
483 cfg.camera_wb_ratio_red = 1;
484 cfg.camera_wb_ratio_blue = 1;
489 v =
rcg::getEnum(nodemap,
"DepthAcquisitionMode",
false);
493 cfg.depth_acquisition_mode = v;
497 ROS_WARN(
"rc_visard_driver: Device does not support triggering depth images. depth_acquisition_mode is without function.");
500 cfg.depth_acquisition_mode =
"Continuous";
504 cfg.depth_quality = v;
506 cfg.depth_static_scene =
rcg::getBoolean(nodemap,
"DepthStaticScene",
false);
507 cfg.depth_disprange =
rcg::getInteger(nodemap,
"DepthDispRange", 0, 0,
true);
509 cfg.depth_median =
rcg::getInteger(nodemap,
"DepthMedian", 0, 0,
true);
511 cfg.depth_minconf =
rcg::getFloat(nodemap,
"DepthMinConf", 0, 0,
true);
512 cfg.depth_mindepth =
rcg::getFloat(nodemap,
"DepthMinDepth", 0, 0,
true);
513 cfg.depth_maxdepth =
rcg::getFloat(nodemap,
"DepthMaxDepth", 0, 0,
true);
514 cfg.depth_maxdeptherr =
rcg::getFloat(nodemap,
"DepthMaxDepthErr", 0, 0,
true);
520 if (cfg.depth_quality[0] ==
'S')
522 cfg.depth_quality =
"High";
523 cfg.depth_static_scene =
true;
535 ROS_INFO(
"rc_visard_driver: License for stereo_plus not available, disabling depth_quality=Full and depth_smooth.");
538 catch (
const std::exception&)
540 ROS_WARN(
"rc_visard_driver: rc_visard has an older firmware, disabling depth_quality=Full and depth_smooth.");
550 rcg::setEnum(nodemap,
"AcquisitionAlternateFilter",
"Off",
false);
566 ROS_INFO(
"rc_visard_driver: License for iocontrol module not available, disabling out1_mode and out2_mode.");
573 catch (
const std::exception&)
575 ROS_WARN(
"rc_visard_driver: rc_visard has an older firmware, IO control functions are not available.");
577 cfg.out1_mode =
"ExposureActive";
578 cfg.out2_mode =
"Low";
586 pnh.
param(
"camera_fps", cfg.camera_fps, cfg.camera_fps);
587 pnh.
param(
"camera_exp_auto", cfg.camera_exp_auto, cfg.camera_exp_auto);
588 pnh.
param(
"camera_exp_value", cfg.camera_exp_value, cfg.camera_exp_value);
589 pnh.
param(
"camera_gain_value", cfg.camera_gain_value, cfg.camera_gain_value);
590 pnh.
param(
"camera_exp_max", cfg.camera_exp_max, cfg.camera_exp_max);
591 pnh.
param(
"camera_wb_auto", cfg.camera_wb_auto, cfg.camera_wb_auto);
592 pnh.
param(
"camera_wb_ratio_red", cfg.camera_wb_ratio_red, cfg.camera_wb_ratio_red);
593 pnh.
param(
"camera_wb_ratio_blue", cfg.camera_wb_ratio_blue, cfg.camera_wb_ratio_blue);
594 pnh.
param(
"depth_acquisition_mode", cfg.depth_acquisition_mode, cfg.depth_acquisition_mode);
595 pnh.
param(
"depth_quality", cfg.depth_quality, cfg.depth_quality);
596 pnh.
param(
"depth_static_scene", cfg.depth_static_scene, cfg.depth_static_scene);
597 pnh.
param(
"depth_disprange", cfg.depth_disprange, cfg.depth_disprange);
598 pnh.
param(
"depth_seg", cfg.depth_seg, cfg.depth_seg);
599 pnh.
param(
"depth_smooth", cfg.depth_smooth, cfg.depth_smooth);
600 pnh.
param(
"depth_median", cfg.depth_median, cfg.depth_median);
601 pnh.
param(
"depth_fill", cfg.depth_fill, cfg.depth_fill);
602 pnh.
param(
"depth_minconf", cfg.depth_minconf, cfg.depth_minconf);
603 pnh.
param(
"depth_mindepth", cfg.depth_mindepth, cfg.depth_mindepth);
604 pnh.
param(
"depth_maxdepth", cfg.depth_maxdepth, cfg.depth_maxdepth);
605 pnh.
param(
"depth_maxdeptherr", cfg.depth_maxdeptherr, cfg.depth_maxdeptherr);
606 pnh.
param(
"ptp_enabled", cfg.ptp_enabled, cfg.ptp_enabled);
607 pnh.
param(
"out1_mode", cfg.out1_mode, cfg.out1_mode);
608 pnh.
param(
"out2_mode", cfg.out2_mode, cfg.out2_mode);
612 pnh.
setParam(
"camera_fps", cfg.camera_fps);
613 pnh.
setParam(
"camera_exp_auto", cfg.camera_exp_auto);
614 pnh.
setParam(
"camera_exp_value", cfg.camera_exp_value);
615 pnh.
setParam(
"camera_gain_value", cfg.camera_gain_value);
616 pnh.
setParam(
"camera_exp_max", cfg.camera_exp_max);
617 pnh.
setParam(
"camera_wb_auto", cfg.camera_wb_auto);
618 pnh.
setParam(
"camera_wb_ratio_red", cfg.camera_wb_ratio_red);
619 pnh.
setParam(
"camera_wb_ratio_blue", cfg.camera_wb_ratio_blue);
620 pnh.
setParam(
"depth_acquisition_mode", cfg.depth_acquisition_mode);
621 pnh.
setParam(
"depth_quality", cfg.depth_quality);
622 pnh.
setParam(
"depth_static_scene", cfg.depth_static_scene);
623 pnh.
setParam(
"depth_disprange", cfg.depth_disprange);
624 pnh.
setParam(
"depth_seg", cfg.depth_seg);
625 pnh.
setParam(
"depth_smooth", cfg.depth_smooth);
626 pnh.
setParam(
"depth_median", cfg.depth_median);
627 pnh.
setParam(
"depth_fill", cfg.depth_fill);
628 pnh.
setParam(
"depth_minconf", cfg.depth_minconf);
629 pnh.
setParam(
"depth_mindepth", cfg.depth_mindepth);
630 pnh.
setParam(
"depth_maxdepth", cfg.depth_maxdepth);
631 pnh.
setParam(
"depth_maxdeptherr", cfg.depth_maxdeptherr);
632 pnh.
setParam(
"ptp_enabled", cfg.ptp_enabled);
633 pnh.
setParam(
"out1_mode", cfg.out1_mode);
634 pnh.
setParam(
"out2_mode", cfg.out2_mode);
639 reconfig =
new dynamic_reconfigure::Server<rc_visard_driver::rc_visard_driverConfig>(pnh);
642 dynamic_reconfigure::Server<rc_visard_driver::rc_visard_driverConfig>::CallbackType cb;
649 std::lock_guard<std::mutex> lock(
mtx);
655 c.camera_gain_value = 0;
659 c.camera_gain_value =
round(c.camera_gain_value / 6) * 6;
663 c.camera_wb_auto =
true;
664 c.camera_wb_ratio_red = 1;
665 c.camera_wb_ratio_blue = 1;
666 l &= ~(16384 | 32768 | 65536);
671 c.depth_acquisition_mode = c.depth_acquisition_mode.substr(0, 1);
673 if (c.depth_acquisition_mode[0] ==
'S')
675 c.depth_acquisition_mode =
"SingleFrame";
679 c.depth_acquisition_mode =
"Continuous";
684 c.depth_acquisition_mode =
"Continuous";
688 if (c.depth_quality[0] ==
'L')
690 c.depth_quality =
"Low";
692 else if (c.depth_quality[0] ==
'M')
694 c.depth_quality =
"Medium";
698 c.depth_quality =
"Full";
702 c.depth_quality =
"High";
707 c.depth_smooth=
false;
713 if (c.out1_mode !=
"Low" && c.out1_mode !=
"High" && c.out1_mode !=
"ExposureActive" &&
714 c.out1_mode !=
"ExposureAlternateActive")
716 c.out1_mode =
"ExposureActive";
719 if (c.out2_mode !=
"Low" && c.out2_mode !=
"High" && c.out2_mode !=
"ExposureActive" &&
720 c.out2_mode !=
"ExposureAlternateActive")
727 c.out1_mode =
"ExposureActive";
743 void setConfiguration(
const std::shared_ptr<GenApi::CNodeMapRef>& nodemap,
744 const rc_visard_driver::rc_visard_driverConfig& cfg, uint32_t lvl,
bool iocontrol_avail)
746 uint32_t prev_lvl = 0;
748 while (lvl != 0 && prev_lvl != lvl)
761 rcg::setFloat(nodemap,
"AcquisitionFrameRate", cfg.camera_fps,
true);
768 if (cfg.camera_exp_auto)
770 rcg::setEnum(nodemap,
"ExposureAuto",
"Continuous",
true);
781 rcg::setFloat(nodemap,
"ExposureTime", 1000000 * cfg.camera_exp_value,
true);
793 rcg::setFloat(nodemap,
"ExposureTimeAutoMax", 1000000 * cfg.camera_exp_max,
true);
800 if (cfg.camera_wb_auto)
802 rcg::setEnum(nodemap,
"BalanceWhiteAuto",
"Continuous",
false);
806 rcg::setEnum(nodemap,
"BalanceWhiteAuto",
"Off",
false);
814 rcg::setEnum(nodemap,
"BalanceRatioSelector",
"Red",
false);
815 rcg::setFloat(nodemap,
"BalanceRatio", cfg.camera_wb_ratio_red,
false);
822 rcg::setEnum(nodemap,
"BalanceRatioSelector",
"Blue",
false);
823 rcg::setFloat(nodemap,
"BalanceRatio", cfg.camera_wb_ratio_blue,
false);
830 std::vector<std::string> list;
831 rcg::getEnum(nodemap,
"DepthAcquisitionMode", list,
true);
834 for (
size_t i = 0; i < list.size(); i++)
836 if (list[i].compare(0, 1, cfg.depth_acquisition_mode, 0, 1) == 0)
844 rcg::setEnum(nodemap,
"DepthAcquisitionMode", val.c_str(),
true);
852 std::vector<std::string> list;
857 if (cfg.depth_quality ==
"High" && cfg.depth_static_scene)
861 for (
size_t i = 0; i < list.size() && val.size() == 0; i++)
863 if (list[i].compare(0, 1,
"StaticHigh", 0, 1) == 0)
870 for (
size_t i = 0; i < list.size() && val.size() == 0; i++)
872 if (list[i].compare(0, 1, cfg.depth_quality, 0, 1) == 0)
880 rcg::setEnum(nodemap,
"DepthQuality", val.c_str(),
true);
888 if (!
rcg::setBoolean(nodemap,
"DepthStaticScene", cfg.depth_static_scene,
false))
892 std::string quality = cfg.depth_quality;
894 if (cfg.depth_static_scene && quality ==
"High")
896 quality =
"StaticHigh";
899 std::vector<std::string> list;
903 for (
size_t i = 0; i < list.size() && val.size() == 0; i++)
905 if (list[i].compare(0, 1, quality, 0, 1) == 0)
913 rcg::setEnum(nodemap,
"DepthQuality", val.c_str(),
true);
951 rcg::setFloat(nodemap,
"DepthMinConf", cfg.depth_minconf,
true);
957 rcg::setFloat(nodemap,
"DepthMinDepth", cfg.depth_mindepth,
true);
963 rcg::setFloat(nodemap,
"DepthMaxDepth", cfg.depth_maxdepth,
true);
969 rcg::setFloat(nodemap,
"DepthMaxDepthErr", cfg.depth_maxdeptherr,
true);
985 rcg::setEnum(nodemap,
"LineSource", cfg.out1_mode.c_str(),
true);
996 rcg::setEnum(nodemap,
"LineSource", cfg.out2_mode.c_str(),
true);
1000 catch (
const std::exception& ex)
1013 void disableAll(
const std::shared_ptr<GenApi::CNodeMapRef>& nodemap)
1015 std::vector<std::string> component;
1017 rcg::getEnum(nodemap,
"ComponentSelector", component,
true);
1019 for (
size_t i = 0; i < component.size(); i++)
1021 rcg::setEnum(nodemap,
"ComponentSelector", component[i].c_str(),
true);
1025 rcg::setEnum(nodemap,
"ComponentSelector",
"Intensity");
1038 int enable(
const std::shared_ptr<GenApi::CNodeMapRef>& nodemap,
const char* component,
bool& en_curr,
bool en_new)
1040 if (en_new != en_curr)
1043 ROS_INFO_STREAM(
"rc_visard_driver: Enabled image stream: " << component);
1045 ROS_INFO_STREAM(
"rc_visard_driver: Disabled image stream: " << component);
1047 rcg::setEnum(nodemap,
"ComponentSelector", component,
true);
1060 unsigned int maxNumConsecutiveFails = 5;
1069 unsigned int cntConsecutiveFails = 0;
1070 while (!
stopImageThread && cntConsecutiveFails < maxNumConsecutiveFails)
1083 bool ccolor =
false;
1084 bool cintensity =
false;
1085 bool cintensitycombined =
false;
1086 bool cdisparity =
false;
1087 bool cconfidence =
false;
1088 bool cerror =
false;
1090 bool firstTime =
true;
1100 throw std::runtime_error(
"Focal length not found: Neither 'FocalLength' nor 'FocalLengthFactor'!");
1110 throw std::invalid_argument(
"Feature not found or not readable: Baseline");
1115 throw std::invalid_argument(
"Feature not float: Baseline");
1117 if (val->GetUnit() ==
"mm")
1137 int disprange =
config.depth_disprange;
1138 bool is_depth_acquisition_continuous = (
config.depth_acquisition_mode[0] ==
'C');
1142 std::shared_ptr<GenApi::CChunkAdapter> chunkadapter;
1172 std::shared_ptr<ImagePublisher> limage_color;
1173 std::shared_ptr<ImagePublisher> rimage_color;
1176 std::vector<std::string> format;
1180 for (
size_t i = 0; i < format.size(); i++)
1182 if (format[i] ==
"YCbCr411_8")
1193 std::vector<std::shared_ptr<rcg::Stream> > stream =
rcgdev->getStreams();
1197 if (stream.size() > 0)
1200 stream[0]->startStreaming();
1203 #if ROS_HAS_STEADYTIME 1227 chunkadapter->AttachBuffer(reinterpret_cast<std::uint8_t*>(buffer->
getGlobalBase()),
1233 for (uint32_t part=0; part<npart; part++)
1238 #if ROS_HAS_STEADYTIME 1243 cntConsecutiveFails = 0;
1253 lcaminfo.
publish(buffer, part, pixelformat);
1254 rcaminfo.
publish(buffer, part, pixelformat);
1256 limage.
publish(buffer, part, pixelformat, out1);
1257 rimage.
publish(buffer, part, pixelformat, out1);
1259 if (limage_color && rimage_color)
1261 limage_color->publish(buffer, part, pixelformat, out1);
1262 rimage_color->publish(buffer, part, pixelformat, out1);
1265 disp.
publish(buffer, part, pixelformat);
1266 cdisp.
publish(buffer, part, pixelformat);
1267 depth.
publish(buffer, part, pixelformat);
1269 confidence.
publish(buffer, part, pixelformat);
1270 error_disp.
publish(buffer, part, pixelformat);
1271 error_depth.
publish(buffer, part, pixelformat);
1273 points2.
publish(buffer, part, pixelformat, out1);
1279 if (chunkadapter) chunkadapter->DetachBuffer();
1283 #if ROS_HAS_STEADYTIME 1289 ROS_WARN(
"rc_visard_driver: Received incomplete image buffer");
1291 else if (buffer == 0)
1296 if (cintensity || cintensitycombined ||
1297 (is_depth_acquisition_continuous && (cdisparity || cconfidence || cerror)))
1299 #if ROS_HAS_STEADYTIME 1309 out <<
"No images received for " << t <<
" seconds!";
1310 throw std::underflow_error(out.
str());
1318 #if ROS_HAS_STEADYTIME 1339 if (limage_color && rimage_color && (limage_color->used() || rimage_color->used() || points2.
used()))
1360 int changed = enable(
rcgnodemap,
"IntensityCombined", cintensitycombined,
1361 rimage.
used() || (rimage_color && rimage_color->used()));
1363 changed += enable(
rcgnodemap,
"Intensity", cintensity,
1364 !cintensitycombined && (lcaminfo.
used() || rcaminfo.
used() || limage.
used() ||
1365 (limage_color && limage_color->used()) || points2.
used()));
1367 changed += enable(
rcgnodemap,
"Disparity", cdisparity,
1370 changed += enable(
rcgnodemap,
"Confidence", cconfidence, confidence.
used());
1372 changed += enable(
rcgnodemap,
"Error", cerror, error_disp.
used() || error_depth.
used());
1377 if (changed > 0 || firstTime)
1379 if (cintensity || cintensitycombined || cdisparity || cconfidence || cerror)
1393 rc_visard_driver::rc_visard_driverConfig cfg =
config;
1394 uint32_t lvl =
level;
1400 disprange = cfg.depth_disprange;
1406 bool alternate = (cfg.out1_mode ==
"ExposureAlternateActive");
1412 if (limage_color && rimage_color)
1414 limage_color->setOut1Alternate(alternate);
1415 rimage_color->setOut1Alternate(alternate);
1423 is_depth_acquisition_continuous = (cfg.depth_acquisition_mode[0] ==
'C');
1427 if (is_depth_acquisition_continuous)
1429 #if ROS_HAS_STEADYTIME 1439 stream[0]->stopStreaming();
1444 ROS_ERROR(
"rc_visard_driver: No stream");
1445 cntConsecutiveFails++;
1448 catch (
const std::exception& ex)
1451 cntConsecutiveFails++;
1457 if (cntConsecutiveFails > 0)
1459 ROS_ERROR_STREAM(
"rc_visard_driver: Number of consecutive failures: " << cntConsecutiveFails);
1461 if (cntConsecutiveFails >= maxNumConsecutiveFails)
1470 std_srvs::Trigger::Response& resp)
1474 resp.success =
true;
1496 void handleDynamicsStateChangeRequest(rcd::RemoteInterface::Ptr dynIF,
DynamicsCmd state,
1497 std_srvs::Trigger::Response& resp)
1499 resp.success =
true;
1502 std::string new_state;
1510 case DynamicsCmd::STOP:
1511 new_state = dynIF->stop();
1513 case DynamicsCmd::STOP_SLAM:
1514 new_state = dynIF->stopSlam();
1516 case DynamicsCmd::START:
1517 new_state = dynIF->start();
1519 case DynamicsCmd::START_SLAM:
1520 new_state = dynIF->startSlam();
1522 case DynamicsCmd::RESTART_SLAM:
1523 new_state = dynIF->restartSlam();
1525 case DynamicsCmd::RESTART:
1526 new_state = dynIF->restart();
1528 case DynamicsCmd::RESET_SLAM:
1529 new_state = dynIF->resetSlam();
1532 throw std::runtime_error(
"handleDynamicsStateChangeRequest: unrecognized state change request");
1534 if (new_state == rcd::RemoteInterface::State::FATAL)
1536 resp.success =
false;
1537 resp.message =
"rc_dynamics module is in " + new_state +
" state. Check the log files.";
1540 catch (std::exception& e)
1542 resp.success =
false;
1543 resp.message = std::string(
"Failed to change state of rcdynamics module: ") + e.what();
1548 resp.success =
false;
1549 resp.message =
"rcdynamics remote interface not yet initialized!";
1565 handleDynamicsStateChangeRequest(
dynamicsInterface, DynamicsCmd::START_SLAM, resp);
1571 handleDynamicsStateChangeRequest(
dynamicsInterface, DynamicsCmd::RESTART, resp);
1577 handleDynamicsStateChangeRequest(
dynamicsInterface, DynamicsCmd::RESTART_SLAM, resp);
1589 handleDynamicsStateChangeRequest(
dynamicsInterface, DynamicsCmd::STOP_SLAM, resp);
1595 handleDynamicsStateChangeRequest(
dynamicsInterface, DynamicsCmd::RESET_SLAM, resp);
1600 rc_visard_driver::GetTrajectory::Response& resp)
1602 TrajectoryTime start(req.start_time.sec, req.start_time.nsec, req.start_time_relative);
1603 TrajectoryTime end(req.end_time.sec, req.end_time.nsec, req.end_time_relative);
1606 resp.trajectory.header.frame_id = pbTraj.parent();
1607 resp.trajectory.header.stamp.sec = pbTraj.timestamp().sec();
1608 resp.trajectory.header.stamp.nsec = pbTraj.timestamp().nsec();
1610 for (
auto pbPose : pbTraj.poses())
1612 geometry_msgs::PoseStamped rosPose;
1613 rosPose.header.frame_id = pbTraj.parent();
1614 rosPose.header.stamp.sec = pbPose.timestamp().sec();
1615 rosPose.header.stamp.nsec = pbPose.timestamp().nsec();
1616 rosPose.pose.position.x = pbPose.pose().position().x();
1617 rosPose.pose.position.y = pbPose.pose().position().y();
1618 rosPose.pose.position.z = pbPose.pose().position().z();
1619 rosPose.pose.orientation.x = pbPose.pose().orientation().x();
1620 rosPose.pose.orientation.y = pbPose.pose().orientation().y();
1621 rosPose.pose.orientation.z = pbPose.pose().orientation().z();
1622 rosPose.pose.orientation.w = pbPose.pose().orientation().w();
1623 resp.trajectory.poses.push_back(rosPose);
1637 resp.success =
false;
1644 resp.success = (rc.value >= 0);
1645 resp.message = rc.message;
1647 catch (std::exception& e)
1649 resp.message = std::string(
"Failed to save SLAM map: ") + e.what();
1654 resp.message =
"rcdynamics remote interface not yet initialized!";
1665 resp.success =
false;
1672 resp.success = (rc.value >= 0);
1673 resp.message = rc.message;
1675 catch (std::exception& e)
1677 resp.message = std::string(
"Failed to load SLAM map: ") + e.what();
1682 resp.message =
"rcdynamics remote interface not yet initialized!";
1693 resp.success =
false;
1700 resp.success = (rc.value >= 0);
1701 resp.message = rc.message;
1703 catch (std::exception& e)
1705 resp.message = std::string(
"Failed to remove SLAM map: ") + e.what();
1710 resp.message =
"rcdynamics remote interface not yet initialized!";
1729 stat.
summary(diagnostic_msgs::DiagnosticStatus::ERROR,
"Disconnected");
1741 stat.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"Streaming");
1744 stat.
summary(diagnostic_msgs::DiagnosticStatus::WARN,
"No data");
1748 stat.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"Idle");
1755 stat.
summary(diagnostic_msgs::DiagnosticStatus::ERROR,
"Unknown");
1757 stat.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"Info");
bool getBoolean(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception=false, bool igncache=false)
ThreadedStream::Manager::Ptr dynamicsStreams
void publish(const rcg::Buffer *buffer, uint32_t part, uint64_t pixelformat) override
Offers a buffer for publication.
std::shared_ptr< Device > getDevice(const char *devid)
bool used() override
Returns true if there are subscribers to the topic.
bool autopublishTrajectory
bool used() override
Returns true if there are subscribers to the topic.
void publish(const boost::shared_ptr< M > &message) const
size_t getSizeFilled() const
unsigned int totalIncompleteBuffers
void summary(unsigned char lvl, const std::string s)
void reconfigure(rc_visard_driver::rc_visard_driverConfig &config, uint32_t level)
bool used() override
Returns true if there are subscribers to the topic.
std::shared_ptr< GenApi::CChunkAdapter > getChunkAdapter(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const std::string &tltype)
bool used() override
Returns true if there are subscribers to the topic.
void publish(const rcg::Buffer *buffer, uint32_t part, uint64_t pixelformat) override
Offers a buffer for publication.
void produce_connection_diagnostics(diagnostic_updater::DiagnosticStatusWrapper &stat)
void publish(const rcg::Buffer *buffer, uint32_t part, uint64_t pixelformat) override
Offers a buffer for publication.
void setHardwareID(const std::string &hwid)
static std::vector< std::shared_ptr< System > > getSystems()
bool used() override
Returns true if there are subscribers to the topic.
bool dynamicsRestart(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Restart Stereo INS.
std::shared_ptr< ThreadedStream > Ptr
bool depthAcquisitionTrigger(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Trigger stereo matching in mode 'SingleFrame'.
diagnostic_updater::Updater updater
diagnostics publishing
void add(const std::string &name, TaskFunction f)
bool used() override
Returns true if there are subscribers to the topic.
bool getSlamTrajectory(rc_visard_driver::GetTrajectory::Request &req, rc_visard_driver::GetTrajectory::Response &resp)
Get the Slam trajectory.
int64_t getInteger(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, int64_t *vmin=0, int64_t *vmax=0, bool exception=false, bool igncache=false)
ros::ServiceServer slamLoadMapService
void grab(std::string device, rcg::Device::ACCESS access)
void publish(const rcg::Buffer *buffer, uint32_t part, uint64_t pixelformat) override
Offers a buffer for publication.
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
void publish(const rcg::Buffer *buffer, uint32_t part, uint64_t pixelformat) override
Offers a buffer for publication.
bool dynamicsStartSlam(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Start Stereo INS+SLAM.
void produce_device_diagnostics(diagnostic_updater::DiagnosticStatusWrapper &stat)
Implementation of a ThreadedStream that receives rc_visard's dynamics protobuf messages and re-publis...
bool setFloat(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, double value, bool exception=false)
bool dynamicsStart(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Start Stereo INS.
ros::ServiceServer depthAcquisitionTriggerService
wrapper for REST-API calls relating to rc_visard's dynamics interface
bool setEnum(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, const char *value, bool exception=false)
ros::ServiceServer dynamicsStartSlamService
ros::NodeHandle & getPrivateNodeHandle() const
ros::ServiceServer getSlamTrajectoryService
interface GENAPI_DECL_ABSTRACT IFloat
static void clearSystems()
bool perform_depth_acquisition_trigger
bool tfEnabled
should poses published also via tf?
void publish(const rcg::Buffer *buffer, uint32_t part, uint64_t pixelformat) override
Offers a buffer for publication.
bool dev_supports_depth_acquisition_trigger
void initConfiguration(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, rc_visard_driver::rc_visard_driverConfig &cfg, rcg::Device::ACCESS access)
static ThreadedStream::Ptr CreateDynamicsStreamOfType(rc::dynamics::RemoteInterface::Ptr rcdIface, const std::string &stream, ros::NodeHandle &nh, const std::string &frame_id_prefix, bool tfEnabled)
std::atomic_bool imageSuccess
bool used() override
Returns true if there are subscribers to the topic.
void * getGlobalBase() const
ROSCPP_DECL const std::string & getNamespace()
ros::ServiceServer dynamicsStopSlamService
void checkFeature(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, const char *value, bool igncache=false)
unsigned int totalImageReceiveTimeouts
#define ROS_FATAL_STREAM(args)
std::string getEnum(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception=false)
ros::ServiceServer dynamicsRestartSlamService
uint64_t getPixelFormat(std::uint32_t part) const
bool dynamicsStopSlam(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Stop SLAM (keep Stereo INS running)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
std::atomic_uint_least32_t level
rc_visard_driver::rc_visard_driverConfig config
void keepAliveAndRecoverFromFails()
int cntConsecutiveRecoveryFails
bool used() override
Returns true if there are subscribers to the topic.
ros::ServiceServer slamSaveMapService
bool dynamicsRestartSlam(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Restart Stereo INS+SLAM.
bool IsReadable(const CPointer< T, B > &ptr)
ros::ServiceServer dynamicsStopService
void setOut1Alternate(bool alternate)
DynamicsCmd
Commands taken by handleDynamicsStateChangeRequest()
std::atomic_bool imageRequested
bool saveSlamMap(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Save the onboard SLAM map.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::string gev_packet_size
ros::NodeHandle & getNodeHandle() const
#define ROS_WARN_STREAM(args)
ros::Publisher trajPublisher
bool loadSlamMap(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Load the onboard SLAM map.
void publish(const rcg::Buffer *buffer, uint32_t part, uint64_t pixelformat) override
Offers a buffer for publication.
bool setBoolean(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool value, bool exception=false)
std::shared_ptr< rcg::Device > rcgdev
ros::ServiceServer dynamicsStartService
std::string strip_leading_slash(const std::string &frame_name)
std::atomic_bool stopImageThread
ros::ServiceServer dynamicsRestartService
dynamic_reconfigure::Server< rc_visard_driver::rc_visard_driverConfig > * reconfig
bool getContainsChunkdata() const
double getFloat(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, double *vmin=0, double *vmax=0, bool exception=false, bool igncache=false)
#define ROS_INFO_STREAM(args)
std::atomic_bool stopRecoverThread
void setDisprange(int disprange)
Set the disparity range for scaling of images.
rc::dynamics::RemoteInterface::Ptr dynamicsInterface
void publish(const rcg::Buffer *buffer, uint32_t part, uint64_t pixelformat) override
Offers a buffer for publication.
bool callCommand(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception=false)
bool getImagePresent(std::uint32_t part) const
bool getIsIncomplete() const
bool dynamicsStop(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Stop Stereo INS(+SLAM if running)
Specific implementation for roboception::msgs::Dynamics messages.
bool setInteger(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, int64_t value, bool exception=false)
std::thread recoverThread
void setOut1Alternate(bool alternate)
void add(const std::string &key, const T &val)
#define ROS_ERROR_STREAM(args)
unsigned int totalConnectionLosses
interface GENAPI_DECL_ABSTRACT INode
bool removeSlamMap(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Remove the onboard SLAM map.
std::shared_ptr< GenApi::CNodeMapRef > rcgnodemap
bool dynamicsResetSlam(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &resp)
Reset SLAM (keep Stereo INS running)
ros::ServiceServer dynamicsResetSlamService
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
bool used() override
Returns true if there are subscribers to the topic.
std::string getString(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception=false, bool igncache=false)
Specific implementation for roboception::msgs::Frame messages.
void setDisprange(int disprange)
Set the disparity range for scaling of images.
void publish(const rcg::Buffer *buffer, uint32_t part, uint64_t pixelformat) override
Offers a buffer for publication.
std::string tfPrefix
all frame names must be prefixed when using more than one rc_visard
ros::ServiceServer slamRemoveMapService
std::uint32_t getNumberOfParts() const