fix: preserve dependent property configuration order

This commit is contained in:
slz
2026-09-03 19:50:35 +08:00
parent a4a48e0509
commit c5be5d88c5
2 changed files with 64 additions and 42 deletions
+36 -15
View File
@@ -1148,22 +1148,42 @@ void OBCameraNode::setupDevices() {
sensors_.find(DEPTH) != sensors_.end() && sensors_.find(DEPTH) != sensors_.end() &&
device_->isPropertySupported(OB_PROP_DISPARITY_TO_DEPTH_BOOL, OB_PERMISSION_READ_WRITE) && device_->isPropertySupported(OB_PROP_DISPARITY_TO_DEPTH_BOOL, OB_PERMISSION_READ_WRITE) &&
device_->isPropertySupported(OB_PROP_SDK_DISPARITY_TO_DEPTH_BOOL, OB_PERMISSION_READ_WRITE)) { device_->isPropertySupported(OB_PROP_SDK_DISPARITY_TO_DEPTH_BOOL, OB_PERMISSION_READ_WRITE)) {
TRY_EXECUTE_BLOCK({
bool expected_hardware_enabled = false;
bool expected_software_enabled = false;
bool mode_supported = true;
if (disparity_to_depth_mode_ == "HW") { if (disparity_to_depth_mode_ == "HW") {
TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_DISPARITY_TO_DEPTH_BOOL, 1); expected_hardware_enabled = true;
TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_SDK_DISPARITY_TO_DEPTH_BOOL, 0); device_->setBoolProperty(OB_PROP_SDK_DISPARITY_TO_DEPTH_BOOL, false);
RCLCPP_INFO_STREAM(logger_, "Disparity to depth mode: HW"); device_->setBoolProperty(OB_PROP_DISPARITY_TO_DEPTH_BOOL, true);
} else if (disparity_to_depth_mode_ == "SW") { } else if (disparity_to_depth_mode_ == "SW") {
TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_DISPARITY_TO_DEPTH_BOOL, 0); expected_software_enabled = true;
TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_SDK_DISPARITY_TO_DEPTH_BOOL, 1); device_->setBoolProperty(OB_PROP_DISPARITY_TO_DEPTH_BOOL, false);
RCLCPP_INFO_STREAM(logger_, "Disparity to depth mode: SW"); device_->setBoolProperty(OB_PROP_SDK_DISPARITY_TO_DEPTH_BOOL, true);
} else if (disparity_to_depth_mode_ == "disable") { } else if (disparity_to_depth_mode_ == "disable") {
TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_DISPARITY_TO_DEPTH_BOOL, 0); device_->setBoolProperty(OB_PROP_DISPARITY_TO_DEPTH_BOOL, false);
TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_SDK_DISPARITY_TO_DEPTH_BOOL, 0); device_->setBoolProperty(OB_PROP_SDK_DISPARITY_TO_DEPTH_BOOL, false);
RCLCPP_INFO_STREAM(logger_, "Disparity to depth mode: disabled");
} else { } else {
RCLCPP_WARN_STREAM(logger_, "Unknown disparity to depth mode '" RCLCPP_WARN_STREAM(logger_, "Unknown disparity to depth mode '"
<< disparity_to_depth_mode_ << "', keeping default settings"); << disparity_to_depth_mode_
<< "', keeping default settings");
mode_supported = false;
} }
if (mode_supported) {
const bool hardware_enabled = device_->getBoolProperty(OB_PROP_DISPARITY_TO_DEPTH_BOOL);
const bool software_enabled = device_->getBoolProperty(OB_PROP_SDK_DISPARITY_TO_DEPTH_BOOL);
if (hardware_enabled != expected_hardware_enabled ||
software_enabled != expected_software_enabled) {
RCLCPP_ERROR_STREAM(logger_, "Failed to apply disparity to depth mode "
<< disparity_to_depth_mode_
<< ": device reports hardware=" << hardware_enabled
<< ", software=" << software_enabled);
} else {
RCLCPP_INFO_STREAM(logger_, "Disparity to depth mode: " << disparity_to_depth_mode_);
}
}
});
} }
try { try {
if (should_apply_launch_config("enable_ldp") && if (should_apply_launch_config("enable_ldp") &&
@@ -1219,8 +1239,10 @@ void OBCameraNode::setupDevices() {
"Current laser control: " << (device_->getIntProperty(OB_PROP_LASER_BOOL) ? "ON" : "OFF"))); "Current laser control: " << (device_->getIntProperty(OB_PROP_LASER_BOOL) ? "ON" : "OFF")));
} }
if (!sync_mode_str_.empty()) { if (!sync_mode_str_.empty()) {
TRY_EXECUTE_BLOCK({
auto sync_config = device_->getMultiDeviceSyncConfig(); auto sync_config = device_->getMultiDeviceSyncConfig();
std::transform(sync_mode_str_.begin(), sync_mode_str_.end(), sync_mode_str_.begin(), ::toupper); std::transform(sync_mode_str_.begin(), sync_mode_str_.end(), sync_mode_str_.begin(),
::toupper);
sync_mode_ = OBSyncModeFromString(sync_mode_str_); sync_mode_ = OBSyncModeFromString(sync_mode_str_);
sync_config.syncMode = sync_mode_; sync_config.syncMode = sync_mode_;
sync_config.depthDelayUs = depth_delay_us_; sync_config.depthDelayUs = depth_delay_us_;
@@ -1229,13 +1251,11 @@ void OBCameraNode::setupDevices() {
sync_config.triggerOutDelayUs = trigger_out_delay_us_; sync_config.triggerOutDelayUs = trigger_out_delay_us_;
sync_config.triggerOutEnable = trigger_out_enabled_; sync_config.triggerOutEnable = trigger_out_enabled_;
sync_config.framesPerTrigger = frames_per_trigger_; sync_config.framesPerTrigger = frames_per_trigger_;
TRY_EXECUTE_BLOCK(device_->setMultiDeviceSyncConfig(sync_config)); device_->setMultiDeviceSyncConfig(sync_config);
TRY_EXECUTE_BLOCK({
sync_config = device_->getMultiDeviceSyncConfig(); sync_config = device_->getMultiDeviceSyncConfig();
RCLCPP_INFO_STREAM(logger_, RCLCPP_INFO_STREAM(logger_,
"Current sync mode: " << magic_enum::enum_name(sync_config.syncMode)); "Current sync mode: " << magic_enum::enum_name(sync_config.syncMode));
}); if (sync_config.syncMode == OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING) {
if (sync_mode_ == OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING) {
RCLCPP_INFO_STREAM(logger_, "Frames per trigger: " << sync_config.framesPerTrigger); RCLCPP_INFO_STREAM(logger_, "Frames per trigger: " << sync_config.framesPerTrigger);
RCLCPP_INFO_STREAM(logger_, RCLCPP_INFO_STREAM(logger_,
"Software trigger period " << software_trigger_period_.count() << " ms"); "Software trigger period " << software_trigger_period_.count() << " ms");
@@ -1245,6 +1265,7 @@ void OBCameraNode::setupDevices() {
} }
}); });
} }
});
} }
if (should_apply_launch_config("enable_ptp_config") && if (should_apply_launch_config("enable_ptp_config") &&
device_->isPropertySupported(OB_DEVICE_PTP_CLOCK_SYNC_ENABLE_BOOL, device_->isPropertySupported(OB_DEVICE_PTP_CLOCK_SYNC_ENABLE_BOOL,
+6 -5
View File
@@ -245,11 +245,12 @@ void OBLidarNode::setupDevices() {
RCLCPP_ERROR(logger_, "filter level value is out of range[%d,%d], please check the value", RCLCPP_ERROR(logger_, "filter level value is out of range[%d,%d], please check the value",
range.min, range.max); range.min, range.max);
} else { } else {
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_LIDAR_TAIL_FILTER_LEVEL_INT, filter_level_); TRY_EXECUTE_BLOCK({
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_LIDAR_APPLY_CONFIGS_INT, 1); device_->setIntProperty(OB_PROP_LIDAR_TAIL_FILTER_LEVEL_INT, filter_level_);
TRY_EXECUTE_BLOCK(RCLCPP_INFO_STREAM( device_->setIntProperty(OB_PROP_LIDAR_APPLY_CONFIGS_INT, 1);
logger_, "Current filter level: " RCLCPP_INFO_STREAM(logger_, "Current filter level: " << device_->getIntProperty(
<< device_->getIntProperty(OB_PROP_LIDAR_TAIL_FILTER_LEVEL_INT))); OB_PROP_LIDAR_TAIL_FILTER_LEVEL_INT));
});
} }
} }