diff --git a/src/CameraNode.cpp b/src/CameraNode.cpp index 2992b52b..8b63bdc3 100644 --- a/src/CameraNode.cpp +++ b/src/CameraNode.cpp @@ -462,7 +462,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 0902ca03..82568424 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< diff --git a/src/cv_to_pv.hpp b/src/cv_to_pv.hpp index 0e565eb4..fc5d910f 100644 --- a/src/cv_to_pv.hpp +++ b/src/cv_to_pv.hpp @@ -4,6 +4,13 @@ #include +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);