41 boost::function<
void ()> resolutionChangeCallback,
42 boost::function<
void (
int,
int)> borderClipChangeCallback) :
44 resolution_change_callback_(resolutionChangeCallback),
47 imu_samples_per_message_(0),
49 server_sl_bm_cmv2000_(),
50 server_sl_bm_cmv2000_imu_(),
51 server_sl_bm_cmv4000_(),
52 server_sl_bm_cmv4000_imu_(),
53 server_sl_sgm_cmv2000_imu_(),
54 server_sl_sgm_cmv4000_imu_(),
55 server_bcam_imx104_(),
57 lighting_supported_(false),
58 motor_supported_(false),
59 border_clip_type_(RECTANGULAR),
60 border_clip_value_(0.0),
61 border_clip_change_callback_(borderClipChangeCallback),
62 crop_mode_changed_(false)
71 if (Status_Ok != status) {
72 ROS_ERROR(
"Reconfigure: failed to query version info: %s",
73 Channel::statusString(status));
77 if (Status_Ok != status) {
78 ROS_ERROR(
"Reconfigure: failed to query device info: %s",
79 Channel::statusString(status));
99 new dynamic_reconfigure::Server<multisense_ros::bcam_imx104Config>(
device_nh_));
102 }
else if (system::DeviceInfo::HARDWARE_REV_MULTISENSE_ST21 == deviceInfo.
hardwareRevision) {
106 new dynamic_reconfigure::Server<multisense_ros::st21_sgm_vga_imuConfig>(
device_nh_));
109 }
else if (system::DeviceInfo::HARDWARE_REV_MULTISENSE_M == deviceInfo.
hardwareRevision) {
112 case system::DeviceInfo::IMAGER_TYPE_CMV2000_GREY:
113 case system::DeviceInfo::IMAGER_TYPE_CMV2000_COLOR:
117 new dynamic_reconfigure::Server<multisense_ros::mono_cmv2000Config>(
device_nh_));
121 case system::DeviceInfo::IMAGER_TYPE_CMV4000_GREY:
122 case system::DeviceInfo::IMAGER_TYPE_CMV4000_COLOR:
126 new dynamic_reconfigure::Server<multisense_ros::mono_cmv4000Config>(
device_nh_));
135 case system::DeviceInfo::IMAGER_TYPE_CMV2000_GREY:
136 case system::DeviceInfo::IMAGER_TYPE_CMV2000_COLOR:
140 new dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv2000Config>(
device_nh_));
144 case system::DeviceInfo::IMAGER_TYPE_CMV4000_GREY:
145 case system::DeviceInfo::IMAGER_TYPE_CMV4000_COLOR:
149 new dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv4000Config>(
device_nh_));
162 case system::DeviceInfo::IMAGER_TYPE_CMV2000_GREY:
163 case system::DeviceInfo::IMAGER_TYPE_CMV2000_COLOR:
167 new dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv2000_imuConfig>(
device_nh_));
171 case system::DeviceInfo::IMAGER_TYPE_CMV4000_GREY:
172 case system::DeviceInfo::IMAGER_TYPE_CMV4000_COLOR:
176 new dynamic_reconfigure::Server<multisense_ros::sl_bm_cmv4000_imuConfig>(
device_nh_));
189 case system::DeviceInfo::IMAGER_TYPE_CMV2000_GREY:
190 case system::DeviceInfo::IMAGER_TYPE_CMV2000_COLOR:
194 new dynamic_reconfigure::Server<multisense_ros::sl_sgm_cmv2000_imuConfig>(
device_nh_));
198 case system::DeviceInfo::IMAGER_TYPE_CMV4000_GREY:
199 case system::DeviceInfo::IMAGER_TYPE_CMV4000_COLOR:
203 new dynamic_reconfigure::Server<multisense_ros::sl_sgm_cmv4000_imuConfig>(
device_nh_));
229 if (width == static_cast<int32_t>(cfg.
width()) &&
230 height == static_cast<int32_t>(cfg.
height()) &&
231 disparities == static_cast<int32_t>(cfg.
disparities()))
240 if (Status_Ok != status) {
241 ROS_ERROR(
"Reconfigure: failed to query sensor modes: %s",
242 Channel::statusString(status));
250 bool supported =
false;
251 std::vector<system::DeviceMode>::const_iterator it =
device_modes_.begin();
256 if (width == static_cast<int32_t>(m.
width) &&
257 height ==
static_cast<int32_t
>(m.
height) &&
258 disparities == static_cast<int32_t>(m.
disparities)) {
265 if (
false == supported) {
266 ROS_ERROR(
"Reconfigure: sensor does not support a resolution of: %dx%d (%d disparities)",
267 width, height, disparities);
271 ROS_WARN(
"Reconfigure: changing sensor resolution to %dx%d (%d disparities), from %dx%d " 272 "(%d disparities): reconfiguration may take up to 30 seconds",
273 width, height, disparities,
284 cfg.
setCamMode(dyn.crop_mode == 1 ? 2000 : 4000);
286 ROS_WARN(
"Reconfigure: changing cam mode to %s with offset %d: reconfiguration may take up to 30 seconds",
287 dyn.crop_mode == 1 ?
"ON" :
"OFF" , cfg.
offset());
299 int32_t width, height, disparities;
300 bool resolutionChange=
false;
306 if (3 != sscanf(dyn.resolution.c_str(),
"%dx%dx%d", &width, &height, &disparities)) {
307 ROS_ERROR(
"Reconfigure: malformed resolution string: \"%s\"", dyn.resolution.c_str());
319 if (Status_Ok != status) {
320 ROS_ERROR(
"Reconfigure: failed to get enabled streams: %s",
321 Channel::statusString(status));
325 if (Status_Ok != status) {
326 ROS_ERROR(
"Reconfigure: failed to stop streams for a resolution change: %s",
327 Channel::statusString(status));
343 dyn.white_balance_blue);
347 cfg.
setHdr(dyn.hdr_enable);
353 if (Status_Ok != status)
354 ROS_ERROR(
"Reconfigure: failed to set image config: %s",
355 Channel::statusString(status));
360 if (resolutionChange) {
365 if (Status_Ok != status)
366 ROS_ERROR(
"Reconfigure: failed to restart streams after a resolution change: %s",
367 Channel::statusString(status));
375 const float radiansPerSecondToRpm = 9.54929659643;
378 if (Status_Ok != status) {
379 if (Status_Unsupported == status)
382 ROS_ERROR(
"Reconfigure: failed to set motor speed: %s",
383 Channel::statusString(status));
394 if (
false == dyn.lighting) {
403 if (Status_Ok != status) {
404 if (Status_Unsupported == status)
407 ROS_ERROR(
"Reconfigure: failed to set lighting config: %s",
408 Channel::statusString(status));
429 d.
delay = dyn.desired_transmit_delay;
431 if (Status_Ok != status) {
432 ROS_ERROR(
"Reconfigure: failed to set transmit delay: %s",
433 Channel::statusString(status));
442 if (Status_Ok != status) {
443 ROS_ERROR(
"Reconfigure: failed to query IMU config: %s",
444 Channel::statusString(status));
449 std::vector<imu::Config> changedConfigs;
450 std::vector<imu::Config>::iterator it =
imu_configs_.begin();
455 if (
"accelerometer" == c.
name &&
456 (c.
enabled != dyn.accelerometer_enabled ||
460 c.
enabled = dyn.accelerometer_enabled;
463 changedConfigs.push_back(c);
466 if (
"gyroscope" == c.
name &&
467 (c.
enabled != dyn.gyroscope_enabled ||
471 c.
enabled = dyn.gyroscope_enabled;
474 changedConfigs.push_back(c);
477 if (
"magnetometer" == c.
name &&
478 (c.
enabled != dyn.magnetometer_enabled ||
482 c.
enabled = dyn.magnetometer_enabled;
485 changedConfigs.push_back(c);
489 if (changedConfigs.size() > 0 ||
492 ROS_WARN(
"Reconfigure: IMU configuration changes will take effect after all IMU " 493 "topic subscriptions have been closed.");
500 if (Status_Ok != status) {
501 ROS_ERROR(
"Reconfigure: failed to set IMU configuration: %s",
502 Channel::statusString(status));
510 bool regenerate =
false;
534 #define GET_CONFIG() \ 536 Status status = driver_->getImageConfig(cfg); \ 537 if (Status_Ok != status) { \ 538 ROS_ERROR("Reconfigure: failed to query image config: %s", \ 539 Channel::statusString(status)); \ 543 #define SL_BM() do { \ 545 configureCamera(cfg, dyn); \ 546 configureBorderClip(dyn); \ 549 #define SL_BM_IMU() do { \ 551 configureCamera(cfg, dyn); \ 553 configureBorderClip(dyn); \ 556 #define SL_SGM_IMU() do { \ 558 configureSgm(cfg, dyn); \ 559 configureCamera(cfg, dyn); \ 561 configureBorderClip(dyn); \ 564 #define SL_SGM_IMU_CMV4000() do { \ 566 configureSgm(cfg, dyn); \ 567 configureCropMode(cfg, dyn); \ 568 configureCamera(cfg, dyn); \ 570 configureBorderClip(dyn); \ 595 int32_t width, height;
596 bool resolutionChange=
false;
601 if (2 != sscanf(dyn.resolution.c_str(),
"%dx%dx", &width, &height)) {
602 ROS_ERROR(
"Reconfigure: malformed resolution string: \"%s\"", dyn.resolution.c_str());
615 if (Status_Ok != status) {
616 ROS_ERROR(
"Reconfigure: failed to get enabled streams: %s",
617 Channel::statusString(status));
621 if (Status_Ok != status) {
622 ROS_ERROR(
"Reconfigure: failed to stop streams for a resolution change: %s",
623 Channel::statusString(status));
631 cfg.setFps(static_cast<float>(dyn.fps));
632 cfg.setGain(dyn.gain);
633 cfg.setExposure(dyn.exposure_time * 1e6);
634 cfg.setAutoExposure(dyn.auto_exposure);
635 cfg.setAutoExposureMax(dyn.auto_exposure_max_time * 1e6);
636 cfg.setAutoExposureDecay(dyn.auto_exposure_decay);
637 cfg.setAutoExposureThresh(dyn.auto_exposure_thresh);
638 cfg.setWhiteBalance(dyn.white_balance_red,
639 dyn.white_balance_blue);
640 cfg.setAutoWhiteBalance(dyn.auto_white_balance);
641 cfg.setAutoWhiteBalanceDecay(dyn.auto_white_balance_decay);
642 cfg.setAutoWhiteBalanceThresh(dyn.auto_white_balance_thresh);
648 if (Status_Ok != status)
649 ROS_ERROR(
"Reconfigure: failed to set image config: %s",
650 Channel::statusString(status));
655 if (resolutionChange) {
661 if (Status_Ok != status)
662 ROS_ERROR(
"Reconfigure: failed to restart streams after a resolution change: %s",
663 Channel::statusString(status));
677 int32_t width, height, disparities;
678 bool resolutionChange=
false;
685 if (3 != sscanf(dyn.resolution.c_str(),
"%dx%dx%d", &width, &height, &disparities)) {
686 ROS_ERROR(
"Reconfigure: malformed resolution string: \"%s\"", dyn.resolution.c_str());
693 if ((resolutionChange =
changeResolution(cfg, width, height, disparities))) {
699 if (Status_Ok != status) {
700 ROS_ERROR(
"Reconfigure: failed to get enabled streams: %s",
701 Channel::statusString(status));
705 if (Status_Ok != status) {
706 ROS_ERROR(
"Reconfigure: failed to stop streams for a resolution change: %s",
707 Channel::statusString(status));
721 if (Status_Ok != status)
722 ROS_ERROR(
"Reconfigure: failed to set image config: %s",
723 Channel::statusString(status));
728 if (resolutionChange) {
734 if (Status_Ok != status)
735 ROS_ERROR(
"Reconfigure: failed to restart streams after a resolution change: %s",
736 Channel::statusString(status));
virtual Status startStreams(DataSource mask)=0
void setStereoPostFilterStrength(float s)
virtual Status getEnabledStreams(DataSource &mask)=0
virtual Status setMotorSpeed(float rpm)=0
void setAutoWhiteBalanceThresh(float t)
void setAutoWhiteBalanceDecay(uint32_t d)
virtual Status stopStreams(DataSource mask)=0
void setResolution(uint32_t w, uint32_t h)
uint32_t disparities() const
virtual Status networkTimeSynchronization(bool enabled)=0
bool setDutyCycle(float percent)
virtual Status getVersionInfo(system::VersionInfo &v)=0
virtual Status getImuConfig(uint32_t &samplesPerMessage, std::vector< imu::Config > &c)=0
virtual Status setImuConfig(bool storeSettingsInFlash, uint32_t samplesPerMessage, const std::vector< imu::Config > &c)=0
void setExposure(uint32_t e)
void setFlash(bool onOff)
uint32_t hardwareRevision
virtual Status getDeviceModes(std::vector< system::DeviceMode > &m)=0
void setAutoExposure(bool e)
void setDisparities(uint32_t d)
virtual Status setLightingConfig(const lighting::Config &c)=0
virtual Status setImageConfig(const image::Config &c)=0
void setAutoExposureMax(uint32_t m)
void setWhiteBalance(float r, float b)
VersionType sensorFirmwareVersion
virtual Status setTransmitDelay(const image::TransmitDelay &c)=0
virtual Status getDeviceInfo(system::DeviceInfo &info)=0
void setAutoExposureDecay(uint32_t d)
void setAutoWhiteBalance(bool e)
void setAutoExposureThresh(float t)