From bf1fa07942640f345d07d0e129d126b3de1e528c Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 5 Aug 2024 21:24:41 +0200 Subject: [PATCH] remove array parameter from 'cv_to_pv_type' --- src/CameraNode.cpp | 2 +- src/cv_to_pv.cpp | 9 +++++---- src/cv_to_pv.hpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/CameraNode.cpp b/src/CameraNode.cpp index 8f83933a..01729796 100644 --- a/src/CameraNode.cpp +++ b/src/CameraNode.cpp @@ -508,7 +508,7 @@ CameraNode::declareParameters() RCLCPP_DEBUG_STREAM(get_logger(), "declare " << id->name() << " with default " << rclcpp::to_string(value)); if (value.get_type() == rclcpp::ParameterType::PARAMETER_NOT_SET) { - declare_parameter(id->name(), cv_to_pv_type(id->type(), extent > 0), param_descr); + declare_parameter(id->name(), cv_to_pv_type(id), param_descr); } else { declare_parameter(id->name(), value, param_descr); diff --git a/src/cv_to_pv.cpp b/src/cv_to_pv.cpp index 195dac42..2a78dca3 100644 --- a/src/cv_to_pv.cpp +++ b/src/cv_to_pv.cpp @@ -1,4 +1,5 @@ #include "cv_to_pv.hpp" +#include "type_extent.hpp" #include "types.hpp" #include #include @@ -109,10 +110,10 @@ cv_to_pv(const libcamera::ControlValue &value) } rclcpp::ParameterType -cv_to_pv_type(const libcamera::ControlType &type, const bool is_array) +cv_to_pv_type(const libcamera::ControlId *const id) { - if (!is_array) { - switch (type) { + if (get_extent(id) == 0) { + switch (id->type()) { case libcamera::ControlType::ControlTypeNone: return rclcpp::ParameterType::PARAMETER_NOT_SET; case libcamera::ControlType::ControlTypeBool: @@ -132,7 +133,7 @@ cv_to_pv_type(const libcamera::ControlType &type, const bool is_array) } } else { - switch (type) { + switch (id->type()) { case libcamera::ControlType::ControlTypeNone: return rclcpp::ParameterType::PARAMETER_NOT_SET; case libcamera::ControlType::ControlTypeBool: diff --git a/src/cv_to_pv.hpp b/src/cv_to_pv.hpp index 7a3892af..b750c214 100644 --- a/src/cv_to_pv.hpp +++ b/src/cv_to_pv.hpp @@ -15,4 +15,4 @@ rclcpp::ParameterValue cv_to_pv(const libcamera::ControlValue &value); rclcpp::ParameterType -cv_to_pv_type(const libcamera::ControlType &type, const bool is_array); +cv_to_pv_type(const libcamera::ControlId *const id);