[launch]Add disparity_range_mode param

This commit is contained in:
jj
2025-01-14 18:48:01 +08:00
parent 640abcb0d1
commit 11c0422bc3
5 changed files with 44 additions and 27 deletions
@@ -639,6 +639,7 @@ class OBCameraNode {
int laser_index0_ir_brightness_ = 60;
int laser_index0_ir_ae_max_exposure_ = 17000;
int disparity_range_mode_ = -1;
int disparity_search_offset_ = 0;
bool disparity_offset_config_ = false;
int offset_index0_ = 0;
@@ -173,6 +173,12 @@ def generate_launch_description():
DeclareLaunchArgument('enable_heartbeat', default_value='false'),
DeclareLaunchArgument('gmsl_trigger_fps', default_value='3000'),
DeclareLaunchArgument('enable_gmsl_trigger', default_value='false'),
DeclareLaunchArgument('disparity_range_mode', default_value='-1'),
DeclareLaunchArgument('disparity_search_offset', default_value='0'),
DeclareLaunchArgument('disparity_offset_config', default_value='false'),
DeclareLaunchArgument('offset_index0', default_value='0'),
DeclareLaunchArgument('offset_index1', default_value='0'),
DeclareLaunchArgument('frame_aggregate_mode', default_value='ANY'), # full_frame、color_frame、ANY or disable
DeclareLaunchArgument('interleave_ae_mode', default_value='laser'), # 'hdr' or 'laser'
DeclareLaunchArgument('interleave_frame_enable', default_value='false'),
DeclareLaunchArgument('interleave_skip_enable', default_value='false'),
@@ -199,12 +205,6 @@ def generate_launch_description():
DeclareLaunchArgument('laser_index0_depth_gain', default_value='16'),
DeclareLaunchArgument('laser_index0_ir_brightness', default_value='60'),
DeclareLaunchArgument('laser_index0_ir_ae_max_exposure', default_value='30000'),
DeclareLaunchArgument('disparity_search_offset', default_value='0'),
DeclareLaunchArgument('disparity_offset_config', default_value='false'),
DeclareLaunchArgument('offset_index0', default_value='0'),
DeclareLaunchArgument('offset_index1', default_value='0'),
DeclareLaunchArgument('frame_aggregate_mode', default_value='ANY'), # full_frame、color_frame、ANY or disable
]
def get_params(context, args):
+25 -13
View File
@@ -455,6 +455,19 @@ void OBCameraNode::setupDevices() {
<< new_noise_removal_filter_max_size);
}
}
if (disparity_range_mode_ != -1 &&
device_->isPropertySupported(OB_PROP_DISP_SEARCH_RANGE_MODE_INT, OB_PERMISSION_WRITE)) {
RCLCPP_INFO_STREAM(logger_, "Setting disparity_range_mode: " << disparity_range_mode_);
if (disparity_range_mode_ == 64) {
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_DISP_SEARCH_RANGE_MODE_INT, 0);
} else if (disparity_range_mode_ == 128) {
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_DISP_SEARCH_RANGE_MODE_INT, 1);
} else if (disparity_range_mode_ == 256) {
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_DISP_SEARCH_RANGE_MODE_INT, 2);
} else {
RCLCPP_ERROR(logger_, "disparity_range_mode does not support this setting");
}
}
}
void OBCameraNode::setupDepthPostProcessFilter() {
@@ -1302,6 +1315,7 @@ void OBCameraNode::getParameters() {
setAndGetNodeParameter<int>(laser_index0_ir_brightness_, "laser_index0_ir_brightness", 60);
setAndGetNodeParameter<int>(laser_index0_ir_ae_max_exposure_, "laser_index0_ir_ae_max_exposure",
17000);
setAndGetNodeParameter<int>(disparity_range_mode_, "disparity_range_mode", -1);
setAndGetNodeParameter<int>(disparity_search_offset_, "disparity_search_offset", 0);
setAndGetNodeParameter<bool>(disparity_offset_config_, "disparity_offset_config", false);
setAndGetNodeParameter<int>(offset_index0_, "offset_index0", 0);
@@ -1857,21 +1871,19 @@ void OBCameraNode::setDisparitySearchOffset() {
}
if (device_->isPropertySupported(OB_PROP_DISP_SEARCH_OFFSET_INT, OB_PERMISSION_WRITE)) {
device_->setIntProperty(OB_PROP_DISP_SEARCH_OFFSET_INT, disparity_search_offset_);
RCLCPP_INFO_STREAM(logger_, "disparity_search_offset_: " << disparity_search_offset_);
RCLCPP_INFO_STREAM(logger_, "disparity_search_offset: " << disparity_search_offset_);
auto config = OBDispOffsetConfig();
if (disparity_offset_config_) {
config.enable = disparity_offset_config_;
config.offset0 = offset_index0_;
config.offset1 = offset_index1_;
config.reserved = 0;
device_->setStructuredData(OB_STRUCT_DISP_OFFSET_CONFIG,
reinterpret_cast<const uint8_t *>(&config), sizeof(config));
RCLCPP_INFO_STREAM(logger_, "disparity_offset_config_: "
<< disparity_offset_config_ << " offset_index0_:"
<< offset_index0_ << " offset_index1_:" << offset_index1_);
}
config.enable = disparity_offset_config_;
config.offset0 = offset_index0_;
config.offset1 = offset_index1_;
config.reserved = 0;
has_run = true;
device_->setStructuredData(OB_STRUCT_DISP_OFFSET_CONFIG,
reinterpret_cast<const uint8_t *>(&config), sizeof(config));
RCLCPP_INFO_STREAM(logger_, "disparity_offset_config: "
<< disparity_offset_config_ << " offset_index0:"
<< offset_index0_ << " offset_index1:" << offset_index1_);
}
has_run = true;
}
uint64_t OBCameraNode::getFrameTimestampUs(const std::shared_ptr<ob::Frame> &frame) {
+1 -1
View File
@@ -481,7 +481,7 @@ void OBCameraNodeDriver::startDevice(const std::shared_ptr<ob::DeviceList> &list
}
std::this_thread::sleep_for(std::chrono::milliseconds(connection_delay_));
int try_lock_count = 0;
int max_try_lock_count = 50;
int max_try_lock_count = 5;
while (try_lock_count < max_try_lock_count) {
int try_lock_result = pthread_mutex_trylock(orb_device_lock_);
+11 -7
View File
@@ -339,9 +339,9 @@ OBFormat OBFormatFromString(const std::string &format) {
} else if (fixed_format == "RW16") {
return OB_FORMAT_RW16;
}
// else if (fixed_format == "DISP16") {
// return OB_FORMAT_DISP16;
// }
// else if (fixed_format == "DISP16") {
// return OB_FORMAT_DISP16;
// }
else {
return OB_FORMAT_UNKNOWN;
}
@@ -436,8 +436,8 @@ std::string ObDeviceTypeToString(const OBDeviceType &type) {
case OBDeviceType::OB_TOF_CAMERA:
return "tof camera";
default:
// 处理其他未预见的情况
break;
// 处理其他未预见的情况
break;
}
return "unknown technology camera";
}
@@ -700,9 +700,9 @@ std::ostream &operator<<(std::ostream &os, const OBAccelFullScaleRange &rhs) {
}
std::string parseUsbPort(const std::string &line) {
std::string port_id;
std::string port_id;
std::regex usb_regex("(?:[^ ]+/usb[0-9]+[0-9./-]*/){0,1}([0-9.-]+)(:){0,1}[^ ]*",
std::regex_constants::ECMAScript);
std::regex_constants::ECMAScript);
std::smatch base_match;
bool found_usb = std::regex_match(line, base_match, usb_regex);
@@ -815,6 +815,10 @@ std::string metaDataTypeToString(const OBFrameMetadataType &meta_data_type) {
return "frame_emitter_mode";
case OBFrameMetadataType::OB_FRAME_METADATA_TYPE_GPIO_INPUT_DATA:
return "gpio_input_data";
case OBFrameMetadataType::OB_FRAME_METADATA_TYPE_DISPARITY_SEARCH_OFFSET:
return "disparity_search_offset";
case OBFrameMetadataType::OB_FRAME_METADATA_TYPE_DISPARITY_SEARCH_RANGE:
return "disparity search range";
default:
return "unknown_field";
}