diff --git a/src/CameraNode.cpp b/src/CameraNode.cpp index f9979835..35bf2a36 100644 --- a/src/CameraNode.cpp +++ b/src/CameraNode.cpp @@ -459,8 +459,16 @@ CameraNode::declareParameters() throw std::runtime_error("minimum and maximum parameter array sizes do not match"); // clamp default ControlValue to min/max range and cast ParameterValue - const rclcpp::ParameterValue value = - cv_to_pv(clamp(info.def(), info.min(), info.max())); + rclcpp::ParameterValue value; + try { + value = cv_to_pv(clamp(info.def(), info.min(), info.max())); + } + catch (const invalid_conversion &e) { + RCLCPP_ERROR_STREAM(get_logger(), "unsupported control '" << id->name() << "' (type: " + << std::to_string(info.def().type()) + << "): " << e.what()); + continue; + } // get smallest bounds for minimum and maximum set rcl_interfaces::msg::IntegerRange range_int; diff --git a/src/cv_to_pv.cpp b/src/cv_to_pv.cpp index 2ff34221..bc5f97ed 100644 --- a/src/cv_to_pv.cpp +++ b/src/cv_to_pv.cpp @@ -48,7 +48,7 @@ template & /*values*/) { - throw std::runtime_error("ParameterValue only supported for arithmetic types"); + throw invalid_conversion("ParameterValue only supported for arithmetic types"); } template +class invalid_conversion : public std::runtime_error +{ +public: + explicit invalid_conversion(const std::string &msg) : std::runtime_error(msg) {}; +}; + + rclcpp::ParameterValue cv_to_pv(const libcamera::ControlValue &value);