mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-09 14:27:02 +08:00
fix: validate color powerline frequency parameter and log warnings for invalid values
This commit is contained in:
@@ -1652,24 +1652,38 @@ void OBCameraNode::setupDevices() {
|
||||
"Current color anti-flicker to "
|
||||
<< (device_->getBoolProperty(OB_PROP_COLOR_ANTI_FLICKER_BOOL) ? "ON" : "OFF")));
|
||||
}
|
||||
if (!color_powerline_freq_.empty() &&
|
||||
device_->isPropertySupported(OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT, OB_PERMISSION_WRITE)) {
|
||||
if (color_powerline_freq_ == "disable") {
|
||||
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT, 0);
|
||||
} else if (color_powerline_freq_ == "50hz") {
|
||||
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT, 1);
|
||||
} else if (color_powerline_freq_ == "60hz") {
|
||||
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT, 2);
|
||||
} else if (color_powerline_freq_ == "auto") {
|
||||
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT, 3);
|
||||
if (!color_powerline_freq_.empty()) {
|
||||
const auto normalized_color_powerline_freq = lowerParameterValue(color_powerline_freq_);
|
||||
int color_powerline_freq_value = -1;
|
||||
if (normalized_color_powerline_freq == "disable") {
|
||||
color_powerline_freq_value = 0;
|
||||
} else if (normalized_color_powerline_freq == "50hz") {
|
||||
color_powerline_freq_value = 1;
|
||||
} else if (normalized_color_powerline_freq == "60hz") {
|
||||
color_powerline_freq_value = 2;
|
||||
} else if (normalized_color_powerline_freq == "auto") {
|
||||
color_powerline_freq_value = 3;
|
||||
} else {
|
||||
RCLCPP_WARN_STREAM(logger_,
|
||||
"Invalid parameter color_powerline_freq "
|
||||
<< formatParameterValue(color_powerline_freq_) << ". Valid values: "
|
||||
<< formatValidParameterValues({"disable", "50hz", "60hz", "auto"})
|
||||
<< ". Skip setting.");
|
||||
color_powerline_freq_.clear();
|
||||
}
|
||||
if (color_powerline_freq_value >= 0 &&
|
||||
device_->isPropertySupported(OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT, OB_PERMISSION_WRITE)) {
|
||||
color_powerline_freq_ = normalized_color_powerline_freq;
|
||||
TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT,
|
||||
color_powerline_freq_value);
|
||||
TRY_EXECUTE_BLOCK({
|
||||
const auto current_color_powerline_freq =
|
||||
device_->getIntProperty(OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT);
|
||||
RCLCPP_INFO_STREAM(logger_,
|
||||
"Current color powerline freq: "
|
||||
<< colorPowerLineFrequencyToString(current_color_powerline_freq));
|
||||
});
|
||||
}
|
||||
TRY_EXECUTE_BLOCK({
|
||||
const auto current_color_powerline_freq =
|
||||
device_->getIntProperty(OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT);
|
||||
RCLCPP_INFO_STREAM(logger_,
|
||||
"Current color powerline freq: "
|
||||
<< colorPowerLineFrequencyToString(current_color_powerline_freq));
|
||||
});
|
||||
}
|
||||
if (depth_exposure_ != -1 &&
|
||||
device_->isPropertySupported(OB_PROP_DEPTH_EXPOSURE_INT, OB_PERMISSION_WRITE)) {
|
||||
|
||||
Reference in New Issue
Block a user