mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-12 07:19:50 +08:00
fix: improve LDP configuration error handling in setupDevices
This commit is contained in:
@@ -1104,24 +1104,31 @@ void OBCameraNode::setupDevices() {
|
|||||||
<< disparity_to_depth_mode_ << "', keeping default settings");
|
<< disparity_to_depth_mode_ << "', keeping default settings");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (should_apply_launch_config("enable_ldp") &&
|
try {
|
||||||
device_->isPropertySupported(OB_PROP_LDP_BOOL, OB_PERMISSION_READ_WRITE)) {
|
if (should_apply_launch_config("enable_ldp") &&
|
||||||
if (device_->isPropertySupported(OB_PROP_LASER_CONTROL_INT, OB_PERMISSION_READ_WRITE)) {
|
device_->isPropertySupported(OB_PROP_LDP_BOOL, OB_PERMISSION_READ_WRITE)) {
|
||||||
auto laser_enable = device_->getIntProperty(OB_PROP_LASER_CONTROL_INT);
|
if (device_->isPropertySupported(OB_PROP_LASER_CONTROL_INT, OB_PERMISSION_READ_WRITE)) {
|
||||||
TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_LDP_BOOL, enable_ldp_);
|
auto laser_enable = device_->getIntProperty(OB_PROP_LASER_CONTROL_INT);
|
||||||
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_LASER_CONTROL_INT, laser_enable);
|
device_->setBoolProperty(OB_PROP_LDP_BOOL, enable_ldp_);
|
||||||
} else if (device_->isPropertySupported(OB_PROP_LASER_BOOL, OB_PERMISSION_READ_WRITE)) {
|
device_->setIntProperty(OB_PROP_LASER_CONTROL_INT, laser_enable);
|
||||||
if (!enable_ldp_) {
|
} else if (device_->isPropertySupported(OB_PROP_LASER_BOOL, OB_PERMISSION_READ_WRITE)) {
|
||||||
auto laser_enable = device_->getIntProperty(OB_PROP_LASER_BOOL);
|
if (!enable_ldp_) {
|
||||||
TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_LDP_BOOL, enable_ldp_);
|
auto laser_enable = device_->getIntProperty(OB_PROP_LASER_BOOL);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(3));
|
device_->setBoolProperty(OB_PROP_LDP_BOOL, enable_ldp_);
|
||||||
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_LASER_BOOL, laser_enable);
|
std::this_thread::sleep_for(std::chrono::milliseconds(3));
|
||||||
} else {
|
device_->setIntProperty(OB_PROP_LASER_BOOL, laser_enable);
|
||||||
TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_LDP_BOOL, enable_ldp_);
|
} else {
|
||||||
|
device_->setBoolProperty(OB_PROP_LDP_BOOL, enable_ldp_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
RCLCPP_INFO_STREAM(
|
||||||
|
logger_, "Current LDP: " << (device_->getBoolProperty(OB_PROP_LDP_BOOL) ? "ON" : "OFF"));
|
||||||
}
|
}
|
||||||
RCLCPP_INFO_STREAM(
|
} catch (const ob::Error &e) {
|
||||||
logger_, "Current LDP: " << (device_->getBoolProperty(OB_PROP_LDP_BOOL) ? "ON" : "OFF"));
|
RCLCPP_WARN_STREAM(logger_,
|
||||||
|
"Skipping LDP configuration: " << orbbec_camera::formatObErrorWithStatus(e));
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
RCLCPP_WARN_STREAM(logger_, "Skipping LDP configuration: " << e.what());
|
||||||
}
|
}
|
||||||
if (ldp_power_level_ != -1 &&
|
if (ldp_power_level_ != -1 &&
|
||||||
device_->isPropertySupported(OB_PROP_LASER_POWER_LEVEL_CONTROL_INT, OB_PERMISSION_WRITE)) {
|
device_->isPropertySupported(OB_PROP_LASER_POWER_LEVEL_CONTROL_INT, OB_PERMISSION_WRITE)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user