reconfigure.cpp
Go to the documentation of this file.
1 
35 
36 using namespace crl::multisense;
37 
38 namespace multisense_ros {
39 
40 Reconfigure::Reconfigure(Channel* driver,
41  std::function<void (crl::multisense::image::Config)> resolutionChangeCallback,
42  std::function<void (BorderClip, double)> borderClipChangeCallback,
43  std::function<void (double)> maxPointCloudRangeCallback):
44  driver_(driver),
45  resolution_change_callback_(resolutionChangeCallback),
46  device_nh_(""),
47  imu_samples_per_message_(0),
48  lighting_supported_(false),
49  motor_supported_(false),
50  crop_mode_changed_(false),
51  ptp_supported_(false),
52  border_clip_type_(BorderClip::NONE),
53  border_clip_value_(0.0),
54  border_clip_change_callback_(borderClipChangeCallback),
55  max_point_cloud_range_callback_(maxPointCloudRangeCallback)
56 {
57  system::DeviceInfo deviceInfo;
58  system::VersionInfo versionInfo;
59 
60  //
61  // Query device and version information from sensor
62 
63  Status status = driver_->getVersionInfo(versionInfo);
64  if (Status_Ok != status) {
65  ROS_ERROR("Reconfigure: failed to query version info: %s",
66  Channel::statusString(status));
67  return;
68  }
69  status = driver_->getDeviceInfo(deviceInfo);
70  if (Status_Ok != status) {
71  ROS_ERROR("Reconfigure: failed to query device info: %s",
72  Channel::statusString(status));
73  return;
74  }
75 
76  if (deviceInfo.lightingType != 0)
77  {
78  lighting_supported_ = true;
79  }
80  if (deviceInfo.motorType != 0)
81  {
82  motor_supported_ = true;
83  }
84  if (system::DeviceInfo::HARDWARE_REV_MULTISENSE_C6S2_S27 == deviceInfo.hardwareRevision ||
85  system::DeviceInfo::HARDWARE_REV_MULTISENSE_S30 == deviceInfo.hardwareRevision ||
86  system::DeviceInfo::HARDWARE_REV_MULTISENSE_KS21 == deviceInfo.hardwareRevision)
87  {
88  ptp_supported_ = true;
89  }
90 
91  //
92  // Launch the correct reconfigure server for this device configuration.
93 
94  if (system::DeviceInfo::HARDWARE_REV_BCAM == deviceInfo.hardwareRevision) {
95 
97  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::bcam_imx104Config> > (
98  new dynamic_reconfigure::Server<multisense_ros::bcam_imx104Config>(device_nh_));
99  server_bcam_imx104_->setCallback(std::bind(&Reconfigure::callback_bcam_imx104, this,
100  std::placeholders::_1, std::placeholders::_2));
101 
102  } else if (system::DeviceInfo::HARDWARE_REV_MULTISENSE_ST21 == deviceInfo.hardwareRevision) {
103 
105  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::st21_sgm_vga_imuConfig> > (
106  new dynamic_reconfigure::Server<multisense_ros::st21_sgm_vga_imuConfig>(device_nh_));
107  server_st21_vga_->setCallback(std::bind(&Reconfigure::callback_st21_vga, this,
108  std::placeholders::_1, std::placeholders::_2));
109 
110  } else if (system::DeviceInfo::HARDWARE_REV_MULTISENSE_M == deviceInfo.hardwareRevision) {
111 
112  switch(deviceInfo.imagerType) {
113  case system::DeviceInfo::IMAGER_TYPE_CMV2000_GREY:
114  case system::DeviceInfo::IMAGER_TYPE_CMV2000_COLOR:
115 
117  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::mono_cmv2000Config> > (
118  new dynamic_reconfigure::Server<multisense_ros::mono_cmv2000Config>(device_nh_));
119  server_mono_cmv2000_->setCallback(std::bind(&Reconfigure::callback_mono_cmv2000, this,
120  std::placeholders::_1, std::placeholders::_2));
121 
122  break;
123  case system::DeviceInfo::IMAGER_TYPE_CMV4000_GREY:
124  case system::DeviceInfo::IMAGER_TYPE_CMV4000_COLOR:
125 
127  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::mono_cmv4000Config> > (
128  new dynamic_reconfigure::Server<multisense_ros::mono_cmv4000Config>(device_nh_));
129  server_mono_cmv4000_->setCallback(std::bind(&Reconfigure::callback_mono_cmv4000, this,
130  std::placeholders::_1, std::placeholders::_2));
131 
132  break;
133  }
134 
135  } else if (versionInfo.sensorFirmwareVersion <= 0x0202) {
136 
137  switch(deviceInfo.imagerType) {
138  case system::DeviceInfo::IMAGER_TYPE_CMV2000_GREY:
139  case system::DeviceInfo::IMAGER_TYPE_CMV2000_COLOR:
140 
142  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv2000Config> > (
143  new dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv2000Config>(device_nh_));
144  server_sl_bm_cmv2000_->setCallback(std::bind(&Reconfigure::callback_sl_bm_cmv2000, this,
145  std::placeholders::_1, std::placeholders::_2));
146 
147  break;
148  case system::DeviceInfo::IMAGER_TYPE_CMV4000_GREY:
149  case system::DeviceInfo::IMAGER_TYPE_CMV4000_COLOR:
150 
152  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv4000Config> > (
153  new dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv4000Config>(device_nh_));
154  server_sl_bm_cmv4000_->setCallback(std::bind(&Reconfigure::callback_sl_bm_cmv4000, this,
155  std::placeholders::_1, std::placeholders::_2));
156 
157  break;
158  case system::DeviceInfo::IMAGER_TYPE_AR0239_COLOR:
159  case system::DeviceInfo::IMAGER_TYPE_AR0234_GREY:
160 
162  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::s27_sgm_AR0234Config> > (
163  new dynamic_reconfigure::Server<multisense_ros::s27_sgm_AR0234Config>(device_nh_));
164  server_s27_AR0234_->setCallback(std::bind(&Reconfigure::callback_s27_AR0234, this,
165  std::placeholders::_1, std::placeholders::_2));
166 
167  break;
168  default:
169 
170  ROS_ERROR("Reconfigure: unsupported imager type \"%d\"", deviceInfo.imagerType);
171  return;
172  }
173 
174  } else if (versionInfo.sensorFirmwareVersion < 0x0300) {
175 
176  switch(deviceInfo.imagerType) {
177  case system::DeviceInfo::IMAGER_TYPE_CMV2000_GREY:
178  case system::DeviceInfo::IMAGER_TYPE_CMV2000_COLOR:
179 
181  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv2000_imuConfig> > (
182  new dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv2000_imuConfig>(device_nh_));
184  std::placeholders::_1, std::placeholders::_2));
185 
186  break;
187  case system::DeviceInfo::IMAGER_TYPE_CMV4000_GREY:
188  case system::DeviceInfo::IMAGER_TYPE_CMV4000_COLOR:
189 
191  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv4000_imuConfig> > (
192  new dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv4000_imuConfig>(device_nh_));
194  std::placeholders::_1, std::placeholders::_2));
195 
196  break;
197  case system::DeviceInfo::IMAGER_TYPE_AR0239_COLOR:
198  case system::DeviceInfo::IMAGER_TYPE_AR0234_GREY:
199 
201  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::s27_sgm_AR0234Config> > (
202  new dynamic_reconfigure::Server<multisense_ros::s27_sgm_AR0234Config>(device_nh_));
203  server_s27_AR0234_->setCallback(std::bind(&Reconfigure::callback_s27_AR0234, this,
204  std::placeholders::_1, std::placeholders::_2));
205 
206  break;
207  default:
208 
209  ROS_ERROR("Reconfigure: unsupported imager type \"%d\"", deviceInfo.imagerType);
210  return;
211  }
212 
213  } else {
214 
215  switch(deviceInfo.imagerType) {
216  case system::DeviceInfo::IMAGER_TYPE_CMV2000_GREY:
217  case system::DeviceInfo::IMAGER_TYPE_CMV2000_COLOR:
218 
220  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::sl_sgm_cmv2000_imuConfig> > (
221  new dynamic_reconfigure::Server<multisense_ros::sl_sgm_cmv2000_imuConfig>(device_nh_));
223  std::placeholders::_1, std::placeholders::_2));
224 
225  break;
226  case system::DeviceInfo::IMAGER_TYPE_CMV4000_GREY:
227  case system::DeviceInfo::IMAGER_TYPE_CMV4000_COLOR:
228 
230  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::sl_sgm_cmv4000_imuConfig> > (
231  new dynamic_reconfigure::Server<multisense_ros::sl_sgm_cmv4000_imuConfig>(device_nh_));
233  std::placeholders::_1, std::placeholders::_2));
234  break;
235  case system::DeviceInfo::IMAGER_TYPE_AR0239_COLOR:
236  case system::DeviceInfo::IMAGER_TYPE_AR0234_GREY:
237 
239  std::shared_ptr< dynamic_reconfigure::Server<multisense_ros::s27_sgm_AR0234Config> > (
240  new dynamic_reconfigure::Server<multisense_ros::s27_sgm_AR0234Config>(device_nh_));
241  server_s27_AR0234_->setCallback(std::bind(&Reconfigure::callback_s27_AR0234, this,
242  std::placeholders::_1, std::placeholders::_2));
243 
244  break;
245  default:
246 
247  ROS_ERROR("Reconfigure: unsupported imager type \"%d\"", deviceInfo.imagerType);
248  return;
249  }
250  }
251 }
252 
254 {
255 }
256 
257 //
258 // Helper to change resolution. Will check against supported device modes
259 
261  int32_t width,
262  int32_t height,
263  int32_t disparities)
264 {
265  //
266  // See if we need to change resolutions
267  if (width == static_cast<int32_t>(cfg.width()) &&
268  height == static_cast<int32_t>(cfg.height()) &&
269  disparities == static_cast<int32_t>(cfg.disparities()))
270  return false;
271 
272  //
273  // Query all supported resolutions from the sensor, if we haven't already
274 
275  if (device_modes_.empty()) {
276 
278  if (Status_Ok != status) {
279  ROS_ERROR("Reconfigure: failed to query sensor modes: %s",
280  Channel::statusString(status));
281  return false;
282  }
283  }
284 
285  //
286  // Verify that this resolution is supported
287 
288  bool supported = false;
289  std::vector<system::DeviceMode>::const_iterator it = device_modes_.begin();
290  for(; it != device_modes_.end(); ++it) {
291 
292  const system::DeviceMode& m = *it;
293 
294  if (width == static_cast<int32_t>(m.width) &&
295  height == static_cast<int32_t>(m.height) &&
296  disparities == static_cast<int32_t>(m.disparities)) {
297 
298  supported = true;
299  break;
300  }
301  }
302 
303  if (false == supported) {
304  ROS_ERROR("Reconfigure: sensor does not support a resolution of: %dx%d (%d disparities)",
305  width, height, disparities);
306  return false;
307  }
308 
309  ROS_WARN("Reconfigure: changing sensor resolution to %dx%d (%d disparities), from %dx%d "
310  "(%d disparities): reconfiguration may take up to 30 seconds",
311  width, height, disparities,
312  cfg.width(), cfg.height(), cfg.disparities());
313 
314  cfg.setResolution(width, height);
315  cfg.setDisparities(disparities);
316 
317  return true;
318 }
319 
320 template<class T> void Reconfigure::configureCropMode(crl::multisense::image::Config& cfg, const T& dyn)
321 {
322  cfg.setCamMode(dyn.crop_mode == 1 ? 2000 : 4000);
323  cfg.setOffset(dyn.crop_offset);
324  ROS_WARN("Reconfigure: changing cam mode to %s with offset %d: reconfiguration may take up to 30 seconds",
325  dyn.crop_mode == 1 ? "ON" : "OFF" , cfg.offset());
326  crop_mode_changed_ = true;
327 }
328 
329 template<class T> void Reconfigure::configureSgm(image::Config& cfg, const T& dyn)
330 {
331  cfg.setStereoPostFilterStrength(dyn.stereo_post_filtering);
332 }
333 
334 template<class T> void Reconfigure::configureCamera(image::Config& cfg, const T& dyn)
335 {
336  DataSource streamsEnabled = 0;
337  int32_t width, height, disparities;
338  bool resolutionChange=false;
339  Status status=Status_Ok;
340 
341  //
342  // Decode the resolution string
343 
344  if (3 != sscanf(dyn.resolution.c_str(), "%dx%dx%d", &width, &height, &disparities)) {
345  ROS_ERROR("Reconfigure: malformed resolution string: \"%s\"", dyn.resolution.c_str());
346  return;
347  }
348 
349  //
350  // If a resolution change is desired
351 
352  if ((resolutionChange = changeResolution(cfg, width, height, disparities) || crop_mode_changed_)) {
353  crop_mode_changed_ = false;
354  //
355  // Halt streams during the resolution change
356  status = driver_->getEnabledStreams(streamsEnabled);
357  if (Status_Ok != status) {
358  ROS_ERROR("Reconfigure: failed to get enabled streams: %s",
359  Channel::statusString(status));
360  return;
361  }
362  status = driver_->stopStreams(streamsEnabled);
363  if (Status_Ok != status) {
364  ROS_ERROR("Reconfigure: failed to stop streams for a resolution change: %s",
365  Channel::statusString(status));
366  return;
367  }
368  }
369 
370  //
371  // Set all other image config from dynamic reconfigure
372 
373  cfg.setFps(dyn.fps);
374  cfg.setGain(dyn.gain);
375  cfg.setExposure(dyn.exposure_time * 1e6);
376  cfg.setAutoExposure(dyn.auto_exposure);
377  cfg.setAutoExposureMax(dyn.auto_exposure_max_time * 1e6);
378  cfg.setAutoExposureDecay(dyn.auto_exposure_decay);
379  cfg.setAutoExposureThresh(dyn.auto_exposure_thresh);
380  cfg.setWhiteBalance(dyn.white_balance_red,
381  dyn.white_balance_blue);
382  cfg.setAutoWhiteBalance(dyn.auto_white_balance);
383  cfg.setAutoWhiteBalanceDecay(dyn.auto_white_balance_decay);
384  cfg.setAutoWhiteBalanceThresh(dyn.auto_white_balance_thresh);
385  cfg.setHdr(dyn.hdr_enable);
386 
387  //
388  // Apply, sensor enforces limits per setting.
389 
390  status = driver_->setImageConfig(cfg);
391  if (Status_Ok != status)
392  ROS_ERROR("Reconfigure: failed to set image config: %s",
393  Channel::statusString(status));
394 
395  status = driver_->getImageConfig(cfg);
396  if (Status_Ok != status)
397  ROS_ERROR("Reconfigure: failed to query image config: %s",
398  Channel::statusString(status));
399 
400 
402 
403  //
404  // If we are changing the resolution, let others know about it
405 
406  if (resolutionChange) {
407  status = driver_->startStreams(streamsEnabled);
408  if (Status_Ok != status)
409  ROS_ERROR("Reconfigure: failed to restart streams after a resolution change: %s",
410  Channel::statusString(status));
411  }
412 
413  //
414  // Enable/disable network-based time synchronization.
415  //
416  // If enabled, sensor timestamps will be reported in the local
417  // system clock's frame, using a continuously updated offset from
418  // the sensor's internal clock.
419  //
420  // If disabled, sensor timestamps will be reported in the sensor
421  // clock's frame, which is free-running from zero on power up.
422  //
423  // Enabled by default.
424 
425  driver_->networkTimeSynchronization(dyn.network_time_sync);
426 
427  //
428  // Set our transmit delay
430  d.delay = dyn.desired_transmit_delay;
431  status = driver_->setTransmitDelay(d);
432  if (Status_Ok != status) {
433  ROS_ERROR("Reconfigure: failed to set transmit delay: %s",
434  Channel::statusString(status));
435  }
436 }
437 
438 template<class T> void Reconfigure::configureMotor(const T& dyn)
439 {
440  //
441  // Send the desired motor speed
442 
443  if (motor_supported_) {
444 
445  const float radiansPerSecondToRpm = 9.54929659643;
446 
447  Status status = driver_->setMotorSpeed(radiansPerSecondToRpm * dyn.motor_speed);
448  if (Status_Ok != status) {
449  if (Status_Unsupported == status)
450  motor_supported_ = false;
451  else
452  ROS_ERROR("Reconfigure: failed to set motor speed: %s",
453  Channel::statusString(status));
454  }
455  }
456 
457 }
458 
459 template<class T> void Reconfigure::configureLeds(const T& dyn)
460 {
461  //
462  // Send the desired lighting configuration
463 
464  if (lighting_supported_) {
465 
466  lighting::Config leds;
467 
468  if (false == dyn.lighting) {
469  leds.setFlash(false);
470  leds.setDutyCycle(0.0);
471  } else {
472  leds.setFlash(dyn.flash);
473  leds.setDutyCycle(dyn.led_duty_cycle * 100.0);
474  }
475 
476  Status status = driver_->setLightingConfig(leds);
477  if (Status_Ok != status) {
478  if (Status_Unsupported == status)
479  lighting_supported_ = false;
480  else
481  ROS_ERROR("Reconfigure: failed to set lighting config: %s",
482  Channel::statusString(status));
483  }
484  }
485 
486 }
487 
488 template<class T> void Reconfigure::configureImu(const T& dyn)
489 {
490  if (imu_configs_.empty()) {
492  imu_configs_);
493  if (Status_Ok != status) {
494  ROS_ERROR("Reconfigure: failed to query IMU config: %s",
495  Channel::statusString(status));
496  return;
497  }
498  }
499 
500  std::vector<imu::Config> changedConfigs;
501  std::vector<imu::Config>::iterator it = imu_configs_.begin();
502  for(; it!=imu_configs_.end(); ++it) {
503 
504  imu::Config& c = *it;
505 
506  if ("accelerometer" == c.name &&
507  (c.enabled != dyn.accelerometer_enabled ||
508  static_cast<int>(c.rateTableIndex) != dyn.accelerometer_rate ||
509  static_cast<int>(c.rangeTableIndex) != dyn.accelerometer_range)) {
510 
511  c.enabled = dyn.accelerometer_enabled;
512  c.rateTableIndex = dyn.accelerometer_rate;
513  c.rangeTableIndex = dyn.accelerometer_range;
514  changedConfigs.push_back(c);
515  }
516 
517  if ("gyroscope" == c.name &&
518  (c.enabled != dyn.gyroscope_enabled ||
519  static_cast<int>(c.rateTableIndex) != dyn.gyroscope_rate ||
520  static_cast<int>(c.rangeTableIndex) != dyn.gyroscope_range)) {
521 
522  c.enabled = dyn.gyroscope_enabled;
523  c.rateTableIndex = dyn.gyroscope_rate;
524  c.rangeTableIndex = dyn.gyroscope_range;
525  changedConfigs.push_back(c);
526  }
527 
528  if ("magnetometer" == c.name &&
529  (c.enabled != dyn.magnetometer_enabled ||
530  static_cast<int>(c.rateTableIndex) != dyn.magnetometer_rate ||
531  static_cast<int>(c.rangeTableIndex) != dyn.magnetometer_range)) {
532 
533  c.enabled = dyn.magnetometer_enabled;
534  c.rateTableIndex = dyn.magnetometer_rate;
535  c.rangeTableIndex = dyn.magnetometer_range;
536  changedConfigs.push_back(c);
537  }
538  }
539 
540  if (changedConfigs.size() > 0 ||
541  static_cast<int>(imu_samples_per_message_) != dyn.imu_samples_per_message) {
542 
543  ROS_WARN("Reconfigure: IMU configuration changes will take effect after all IMU "
544  "topic subscriptions have been closed.");
545 
546  imu_samples_per_message_ = dyn.imu_samples_per_message;
547 
548  Status status = driver_->setImuConfig(false, // store in non-volatile flash
550  changedConfigs); // can be empty
551  if (Status_Ok != status) {
552  ROS_ERROR("Reconfigure: failed to set IMU configuration: %s",
553  Channel::statusString(status));
554  imu_configs_.clear();
555  }
556  }
557 }
558 
559 template<class T> void Reconfigure::configureBorderClip(const T& dyn)
560 {
561 
562  if (static_cast<BorderClip>(dyn.border_clip_type) != border_clip_type_ ||
563  dyn.border_clip_value != border_clip_value_) {
564  border_clip_type_ = static_cast<BorderClip>(dyn.border_clip_type);
565  border_clip_value_ = dyn.border_clip_value;
567  }
568 }
569 
570 template<class T> void Reconfigure::configurePointCloudRange(const T& dyn)
571 {
572  max_point_cloud_range_callback_(dyn.max_point_cloud_range);
573 }
574 
575 template<class T> void Reconfigure::configurePtp(const T& dyn)
576 {
577  if (ptp_supported_) {
578  Status status = driver_->ptpTimeSynchronization(dyn.ptp_time_sync);
579  if (Status_Ok != status) {
580  if (Status_Unsupported == status || Status_Unknown == status) {
581  ptp_supported_ = false;
582  } else {
583  ROS_ERROR("Reconfigure: enable PTP time synchronization: %s",
584  Channel::statusString(status));
585  }
586  }
587  }
588 
589  if (dyn.trigger_source != 3 || (ptp_supported_ && dyn.trigger_source == 3)) {
590  Status status = driver_->setTriggerSource(dyn.trigger_source);
591  if (Status_Ok != status) {
592  if (Status_Unsupported == status || Status_Unknown == status) {
593  ptp_supported_ = false;
594  } else {
595  ROS_ERROR("Reconfigure: failed to set trigger source: %s",
596  Channel::statusString(status));
597  }
598  }
599  }
600 }
601 
602 template<class T> void Reconfigure::configureStereoProfile(crl::multisense::image::Config &cfg, const T& dyn)
603 {
604  cfg.setCameraProfile(dyn.stereo_profile);
605 }
606 
607 #define GET_CONFIG() \
608  image::Config cfg; \
609  Status status = driver_->getImageConfig(cfg); \
610  if (Status_Ok != status) { \
611  ROS_ERROR("Reconfigure: failed to query image config: %s", \
612  Channel::statusString(status)); \
613  return; \
614  } \
615 
616 #define SL_BM() do { \
617  GET_CONFIG(); \
618  configureCamera(cfg, dyn); \
619  configureMotor(dyn); \
620  configureLeds(dyn); \
621  configureBorderClip(dyn); \
622  configurePointCloudRange(dyn); \
623  } while(0)
624 
625 #define SL_BM_IMU() do { \
626  GET_CONFIG(); \
627  configureCamera(cfg, dyn); \
628  configureMotor(dyn); \
629  configureLeds(dyn); \
630  configureImu(dyn); \
631  configureBorderClip(dyn); \
632  configurePointCloudRange(dyn); \
633  } while(0)
634 
635 #define SL_SGM_IMU() do { \
636  GET_CONFIG(); \
637  configureSgm(cfg, dyn); \
638  configureCamera(cfg, dyn); \
639  configureMotor(dyn); \
640  configureLeds(dyn); \
641  configureImu(dyn); \
642  configureBorderClip(dyn); \
643  configurePointCloudRange(dyn); \
644  } while(0)
645 
646 #define SL_SGM() do { \
647  GET_CONFIG(); \
648  configureSgm(cfg, dyn); \
649  configureCamera(cfg, dyn); \
650  configureBorderClip(dyn); \
651  } while(0)
652 
653 #define SL_SGM_IMU_CMV4000() do { \
654  GET_CONFIG(); \
655  configureSgm(cfg, dyn); \
656  configureCropMode(cfg, dyn); \
657  configureCamera(cfg, dyn); \
658  configureMotor(dyn); \
659  configureLeds(dyn); \
660  configureImu(dyn); \
661  configureBorderClip(dyn); \
662  configurePointCloudRange(dyn); \
663  } while(0)
664 
665 #define S27_SGM() do { \
666  GET_CONFIG(); \
667  configureSgm(cfg, dyn); \
668  configureStereoProfile(cfg, dyn); \
669  configureCamera(cfg, dyn); \
670  configureBorderClip(dyn); \
671  configurePtp(dyn); \
672  } while(0)
673 
674 
675 
676 //
677 // The dynamic reconfigure callbacks (MultiSense S* variations)
678 
679 void Reconfigure::callback_sl_bm_cmv2000 (multisense_ros::sl_bm_cmv2000Config& dyn, uint32_t level) { (void) level; SL_BM(); }
680 void Reconfigure::callback_sl_bm_cmv2000_imu (multisense_ros::sl_bm_cmv2000_imuConfig& dyn, uint32_t level) { (void) level; SL_BM_IMU(); }
681 void Reconfigure::callback_sl_bm_cmv4000 (multisense_ros::sl_bm_cmv4000Config& dyn, uint32_t level) { (void) level; SL_BM(); }
682 void Reconfigure::callback_sl_bm_cmv4000_imu (multisense_ros::sl_bm_cmv4000_imuConfig& dyn, uint32_t level) { (void) level; SL_BM_IMU(); }
683 void Reconfigure::callback_sl_sgm_cmv2000_imu (multisense_ros::sl_sgm_cmv2000_imuConfig& dyn, uint32_t level) { (void) level; SL_SGM_IMU(); }
684 void Reconfigure::callback_sl_sgm_cmv4000_imu (multisense_ros::sl_sgm_cmv4000_imuConfig& dyn, uint32_t level) { (void) level; SL_SGM_IMU_CMV4000(); }
685 void Reconfigure::callback_mono_cmv2000 (multisense_ros::mono_cmv2000Config& dyn, uint32_t level) { (void) level; SL_BM_IMU(); }
686 void Reconfigure::callback_mono_cmv4000 (multisense_ros::mono_cmv4000Config& dyn, uint32_t level) { (void) level; SL_BM_IMU(); }
687 void Reconfigure::callback_s27_AR0234 (multisense_ros::s27_sgm_AR0234Config& dyn, uint32_t level) { (void) level; S27_SGM(); }
688 
689 //
690 // BCAM (Sony IMX104)
691 
692 void Reconfigure::callback_bcam_imx104(multisense_ros::bcam_imx104Config& dyn,
693  uint32_t level)
694 {
695  (void) level;
696 
697  GET_CONFIG();
698  DataSource streamsEnabled = 0;
699  int32_t width, height;
700  bool resolutionChange=false;
701 
702  //
703  // Decode the resolution string
704 
705  if (2 != sscanf(dyn.resolution.c_str(), "%dx%dx", &width, &height)) {
706  ROS_ERROR("Reconfigure: malformed resolution string: \"%s\"", dyn.resolution.c_str());
707  return;
708  }
709 
710  //
711  // If a resolution change is desired
712 
713  if ((resolutionChange = changeResolution(cfg, width, height, 0))) {
714 
715  //
716  // Halt streams during the resolution change
717 
718  status = driver_->getEnabledStreams(streamsEnabled);
719  if (Status_Ok != status) {
720  ROS_ERROR("Reconfigure: failed to get enabled streams: %s",
721  Channel::statusString(status));
722  return;
723  }
724  status = driver_->stopStreams(streamsEnabled);
725  if (Status_Ok != status) {
726  ROS_ERROR("Reconfigure: failed to stop streams for a resolution change: %s",
727  Channel::statusString(status));
728  return;
729  }
730  }
731 
732  //
733  // Set all other image config from dynamic reconfigure
734 
735  cfg.setFps(static_cast<float>(dyn.fps));
736  cfg.setGain(dyn.gain);
737  cfg.setExposure(dyn.exposure_time * 1e6);
738  cfg.setAutoExposure(dyn.auto_exposure);
739  cfg.setAutoExposureMax(dyn.auto_exposure_max_time * 1e6);
740  cfg.setAutoExposureDecay(dyn.auto_exposure_decay);
741  cfg.setAutoExposureThresh(dyn.auto_exposure_thresh);
742  cfg.setWhiteBalance(dyn.white_balance_red,
743  dyn.white_balance_blue);
744  cfg.setAutoWhiteBalance(dyn.auto_white_balance);
745  cfg.setAutoWhiteBalanceDecay(dyn.auto_white_balance_decay);
746  cfg.setAutoWhiteBalanceThresh(dyn.auto_white_balance_thresh);
747 
748  //
749  // Apply, sensor enforces limits per setting.
750 
751  status = driver_->setImageConfig(cfg);
752  if (Status_Ok != status)
753  ROS_ERROR("Reconfigure: failed to set image config: %s",
754  Channel::statusString(status));
755 
756  status = driver_->getImageConfig(cfg);
757  if (Status_Ok != status)
758  ROS_ERROR("Reconfigure: failed to query image config: %s",
759  Channel::statusString(status));
760 
762 
763  //
764  // If we are changing the resolution, let others know about it
765 
766  if (resolutionChange) {
767 
768  status = driver_->startStreams(streamsEnabled);
769  if (Status_Ok != status)
770  ROS_ERROR("Reconfigure: failed to restart streams after a resolution change: %s",
771  Channel::statusString(status));
772  }
773 }
774 
775 //
776 // ST21 FLIR Thermal Imagers
777 // Seperate callback required due to limited subset of dyn parameters
778 // in st21_sgm_vga_imuConfig. configureCamera results in SFINAE errors
779 
780 void Reconfigure::callback_st21_vga(multisense_ros::st21_sgm_vga_imuConfig& dyn,
781  uint32_t level)
782 {
783  (void) level;
784  DataSource streamsEnabled = 0;
785  int32_t width, height, disparities;
786  bool resolutionChange=false;
787 
788  GET_CONFIG();
789 
790  //
791  // Decode the resolution string
792 
793  if (3 != sscanf(dyn.resolution.c_str(), "%dx%dx%d", &width, &height, &disparities)) {
794  ROS_ERROR("Reconfigure: malformed resolution string: \"%s\"", dyn.resolution.c_str());
795  return;
796  }
797 
798  //
799  // If a resolution change is desired
800 
801  if ((resolutionChange = changeResolution(cfg, width, height, disparities))) {
802 
803  //
804  // Halt streams during the resolution change
805 
806  status = driver_->getEnabledStreams(streamsEnabled);
807  if (Status_Ok != status) {
808  ROS_ERROR("Reconfigure: failed to get enabled streams: %s",
809  Channel::statusString(status));
810  return;
811  }
812  status = driver_->stopStreams(streamsEnabled);
813  if (Status_Ok != status) {
814  ROS_ERROR("Reconfigure: failed to stop streams for a resolution change: %s",
815  Channel::statusString(status));
816  return;
817  }
818  }
819 
820  cfg.setFps(dyn.fps);
821 
822  configureSgm(cfg, dyn);
823  configureImu(dyn);
824 
825  //
826  // Apply, sensor enforces limits per setting.
827 
828  status = driver_->setImageConfig(cfg);
829  if (Status_Ok != status)
830  ROS_ERROR("Reconfigure: failed to set image config: %s",
831  Channel::statusString(status));
832 
833  status = driver_->getImageConfig(cfg);
834  if (Status_Ok != status)
835  ROS_ERROR("Reconfigure: failed to query image config: %s",
836  Channel::statusString(status));
837 
838 
840 
841  //
842  // If we are changing the resolution, let others know about it
843 
844  if (resolutionChange) {
845 
846  status = driver_->startStreams(streamsEnabled);
847  if (Status_Ok != status)
848  ROS_ERROR("Reconfigure: failed to restart streams after a resolution change: %s",
849  Channel::statusString(status));
850  }
851 
852  configureBorderClip(dyn);
854 }
855 
856 } // namespace
virtual Status startStreams(DataSource mask)=0
d
void callback_sl_bm_cmv4000(multisense_ros::sl_bm_cmv4000Config &config, uint32_t level)
void callback_s27_AR0234(multisense_ros::s27_sgm_AR0234Config &config, uint32_t level)
std::shared_ptr< dynamic_reconfigure::Server< multisense_ros::sl_bm_cmv2000_imuConfig > > server_sl_bm_cmv2000_imu_
Definition: reconfigure.h:128
void configureCamera(crl::multisense::image::Config &cfg, const T &dyn)
void setStereoPostFilterStrength(float s)
std::function< void(BorderClip, double)> border_clip_change_callback_
Definition: reconfigure.h:158
#define SL_BM_IMU()
std::shared_ptr< dynamic_reconfigure::Server< multisense_ros::mono_cmv4000Config > > server_mono_cmv4000_
Definition: reconfigure.h:136
void configureBorderClip(const T &dyn)
virtual Status getEnabledStreams(DataSource &mask)=0
virtual Status setMotorSpeed(float rpm)=0
void setAutoWhiteBalanceThresh(float t)
std::shared_ptr< dynamic_reconfigure::Server< multisense_ros::sl_bm_cmv4000_imuConfig > > server_sl_bm_cmv4000_imu_
Definition: reconfigure.h:130
std::vector< crl::multisense::system::DeviceMode > device_modes_
Definition: reconfigure.h:120
NONE
void setAutoWhiteBalanceDecay(uint32_t d)
crl::multisense::Channel * driver_
Definition: reconfigure.h:105
std::shared_ptr< dynamic_reconfigure::Server< multisense_ros::bcam_imx104Config > > server_bcam_imx104_
Definition: reconfigure.h:133
void callback_mono_cmv4000(multisense_ros::mono_cmv4000Config &config, uint32_t level)
virtual Status stopStreams(DataSource mask)=0
#define SL_SGM_IMU()
void callback_mono_cmv2000(multisense_ros::mono_cmv2000Config &config, uint32_t level)
void configurePointCloudRange(const T &dyn)
void callback_sl_sgm_cmv4000_imu(multisense_ros::sl_sgm_cmv4000_imuConfig &config, uint32_t level)
std::shared_ptr< dynamic_reconfigure::Server< multisense_ros::st21_sgm_vga_imuConfig > > server_st21_vga_
Definition: reconfigure.h:134
void callback_st21_vga(multisense_ros::st21_sgm_vga_imuConfig &config, uint32_t level)
void setResolution(uint32_t w, uint32_t h)
uint32_t disparities() const
virtual Status networkTimeSynchronization(bool enabled)=0
bool setDutyCycle(float percent)
#define GET_CONFIG()
virtual Status ptpTimeSynchronization(bool enabled)=0
#define ROS_WARN(...)
virtual Status getVersionInfo(system::VersionInfo &v)=0
virtual Status getImuConfig(uint32_t &samplesPerMessage, std::vector< imu::Config > &c)=0
void callback_sl_sgm_cmv2000_imu(multisense_ros::sl_sgm_cmv2000_imuConfig &config, uint32_t level)
std::shared_ptr< dynamic_reconfigure::Server< multisense_ros::sl_sgm_cmv2000_imuConfig > > server_sl_sgm_cmv2000_imu_
Definition: reconfigure.h:131
ros::NodeHandle device_nh_
Definition: reconfigure.h:115
void callback_sl_bm_cmv4000_imu(multisense_ros::sl_bm_cmv4000_imuConfig &config, uint32_t level)
virtual Status setImuConfig(bool storeSettingsInFlash, uint32_t samplesPerMessage, const std::vector< imu::Config > &c)=0
void configureMotor(const T &dyn)
#define SL_BM()
void configureImu(const T &dyn)
void configureCropMode(crl::multisense::image::Config &cfg, const T &dyn)
virtual Status setTriggerSource(TriggerSource s)=0
virtual Status getDeviceModes(std::vector< system::DeviceMode > &m)=0
void setDisparities(uint32_t d)
#define S27_SGM()
std::shared_ptr< dynamic_reconfigure::Server< multisense_ros::sl_bm_cmv4000Config > > server_sl_bm_cmv4000_
Definition: reconfigure.h:129
virtual Status setLightingConfig(const lighting::Config &c)=0
std::shared_ptr< dynamic_reconfigure::Server< multisense_ros::sl_bm_cmv2000Config > > server_sl_bm_cmv2000_
Definition: reconfigure.h:127
virtual Status setImageConfig(const image::Config &c)=0
void setAutoExposureMax(uint32_t m)
void setWhiteBalance(float r, float b)
std::function< void(crl::multisense::image::Config)> resolution_change_callback_
Definition: reconfigure.h:110
void configureSgm(crl::multisense::image::Config &cfg, const T &dyn)
uint32_t DataSource
void configureStereoProfile(crl::multisense::image::Config &cfg, const T &dyn)
bool changeResolution(crl::multisense::image::Config &cfg, int32_t width, int32_t height, int32_t disparities)
std::shared_ptr< dynamic_reconfigure::Server< multisense_ros::s27_sgm_AR0234Config > > server_s27_AR0234_
Definition: reconfigure.h:137
virtual Status setTransmitDelay(const image::TransmitDelay &c)=0
#define SL_SGM_IMU_CMV4000()
void callback_sl_bm_cmv2000(multisense_ros::sl_bm_cmv2000Config &config, uint32_t level)
virtual Status getDeviceInfo(system::DeviceInfo &info)=0
void callback_bcam_imx104(multisense_ros::bcam_imx104Config &config, uint32_t level)
void setAutoExposureDecay(uint32_t d)
void callback_sl_bm_cmv2000_imu(multisense_ros::sl_bm_cmv2000_imuConfig &config, uint32_t level)
void configurePtp(const T &dyn)
std::shared_ptr< dynamic_reconfigure::Server< multisense_ros::mono_cmv2000Config > > server_mono_cmv2000_
Definition: reconfigure.h:135
std::vector< crl::multisense::imu::Config > imu_configs_
Definition: reconfigure.h:122
std::function< void(double)> max_point_cloud_range_callback_
Definition: reconfigure.h:163
#define ROS_ERROR(...)
virtual Status getImageConfig(image::Config &c)=0
std::shared_ptr< dynamic_reconfigure::Server< multisense_ros::sl_sgm_cmv4000_imuConfig > > server_sl_sgm_cmv4000_imu_
Definition: reconfigure.h:132
void configureLeds(const T &dyn)
void setCameraProfile(const CameraProfile &profile)


multisense_ros
Author(s):
autogenerated on Sun Mar 14 2021 02:34:55