mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-09-13 03:30:18 +08:00
fix: update setupDevices to prioritize depth_work_mode over device_preset
This commit is contained in:
@@ -260,7 +260,15 @@ void OBCameraNode::clean() noexcept {
|
||||
}
|
||||
|
||||
void OBCameraNode::setupDevices() {
|
||||
if (!device_preset_.empty()) {
|
||||
if (!depth_work_mode_.empty() &&
|
||||
device_->isPropertySupported(OB_STRUCT_CURRENT_DEPTH_ALG_MODE, OB_PERMISSION_READ_WRITE)) {
|
||||
auto depthModeList = device_->getDepthWorkModeList();
|
||||
for (uint32_t i = 0; i < depthModeList->getCount(); i++) {
|
||||
RCLCPP_INFO_STREAM(logger_, "depthModeList[" << i << "]: " << (*depthModeList)[i].name);
|
||||
}
|
||||
TRY_EXECUTE_BLOCK(device_->switchDepthWorkMode(depth_work_mode_.c_str()));
|
||||
RCLCPP_INFO_STREAM(logger_, "Set device preset: " << depth_work_mode_);
|
||||
} else if (!device_preset_.empty()) {
|
||||
try {
|
||||
RCLCPP_INFO_STREAM(logger_, "Available presets:");
|
||||
auto preset_list = device_->getAvailablePresetList();
|
||||
@@ -431,32 +439,6 @@ void OBCameraNode::setupDevices() {
|
||||
RCLCPP_INFO_STREAM(logger_, "Setting laser control to " << enable_laser_);
|
||||
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_LASER_BOOL, enable_laser_);
|
||||
}
|
||||
if (!depth_work_mode_.empty() &&
|
||||
device_->isPropertySupported(OB_STRUCT_CURRENT_DEPTH_ALG_MODE, OB_PERMISSION_READ_WRITE)) {
|
||||
auto depthModeList = device_->getDepthWorkModeList();
|
||||
for (uint32_t i = 0; i < depthModeList->getCount(); i++) {
|
||||
RCLCPP_INFO_STREAM(logger_, "depthModeList[" << i << "]: " << (*depthModeList)[i].name);
|
||||
}
|
||||
TRY_EXECUTE_BLOCK(device_->switchDepthWorkMode(depth_work_mode_.c_str()));
|
||||
RCLCPP_INFO_STREAM(logger_, "Set device preset: " << depth_work_mode_);
|
||||
} else if (!device_preset_.empty()) {
|
||||
try {
|
||||
RCLCPP_INFO_STREAM(logger_, "Available presets:");
|
||||
auto preset_list = device_->getAvailablePresetList();
|
||||
for (uint32_t i = 0; i < preset_list->getCount(); i++) {
|
||||
RCLCPP_INFO_STREAM(logger_, "Preset " << i << ": " << preset_list->getName(i));
|
||||
}
|
||||
RCLCPP_INFO_STREAM(logger_, "Load device preset: " << device_preset_);
|
||||
TRY_EXECUTE_BLOCK(device_->loadPreset(device_preset_.c_str()));
|
||||
RCLCPP_INFO_STREAM(logger_, "Device preset " << device_->getCurrentPresetName() << " loaded");
|
||||
} catch (const ob::Error &e) {
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to load device preset: " << e.getMessage());
|
||||
} catch (const std::exception &e) {
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to load device preset: " << e.what());
|
||||
} catch (...) {
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to load device preset");
|
||||
}
|
||||
}
|
||||
if (!sync_mode_str_.empty()) {
|
||||
auto sync_config = device_->getMultiDeviceSyncConfig();
|
||||
RCLCPP_INFO_STREAM(logger_,
|
||||
|
||||
Reference in New Issue
Block a user