Skip to content

Commit 313fcca

Browse files
committed
Fix the bug of disparity_search_offset setting range
1 parent aeed950 commit 313fcca

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/ros_setup.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,12 @@ void OBCameraNode::setupDevices() {
381381
ROS_ERROR_STREAM("disparity_range_mode does not support this setting");
382382
}
383383
}
384-
if (device_->isPropertySupported(OB_PROP_HW_NOISE_REMOVE_FILTER_ENABLE_BOOL, OB_PERMISSION_WRITE)) {
385-
device_->setBoolProperty(OB_PROP_HW_NOISE_REMOVE_FILTER_ENABLE_BOOL, enable_hardware_noise_removal_filter_);
386-
ROS_INFO_STREAM("Setting hardware_noise_removal_filter:" << enable_hardware_noise_removal_filter_);
384+
if (device_->isPropertySupported(OB_PROP_HW_NOISE_REMOVE_FILTER_ENABLE_BOOL,
385+
OB_PERMISSION_WRITE)) {
386+
device_->setBoolProperty(OB_PROP_HW_NOISE_REMOVE_FILTER_ENABLE_BOOL,
387+
enable_hardware_noise_removal_filter_);
388+
ROS_INFO_STREAM(
389+
"Setting hardware_noise_removal_filter:" << enable_hardware_noise_removal_filter_);
387390
}
388391
} catch (const ob::Error& e) {
389392
ROS_ERROR_STREAM("Failed to setup devices: " << e.getMessage());
@@ -896,11 +899,12 @@ void OBCameraNode::setDisparitySearchOffset() {
896899
return;
897900
}
898901
if (device_->isPropertySupported(OB_PROP_DISP_SEARCH_OFFSET_INT, OB_PERMISSION_WRITE)) {
899-
if (disparity_search_offset_ != -1) {
902+
if (disparity_search_offset_ >= 0 && disparity_search_offset_ <= 127) {
900903
device_->setIntProperty(OB_PROP_DISP_SEARCH_OFFSET_INT, disparity_search_offset_);
901904
ROS_INFO_STREAM("disparity_search_offset: " << disparity_search_offset_);
902905
}
903-
if (offset_index0_ != -1 && offset_index1_ != -1) {
906+
if (offset_index0_ >= 0 && offset_index0_ <= 127 && offset_index1_ >= 0 &&
907+
offset_index1_ <= 127) {
904908
auto config = OBDispOffsetConfig();
905909
config.enable = disparity_offset_config_;
906910
config.offset0 = offset_index0_;

0 commit comments

Comments
 (0)