From ad81dd99b3768417b2f8ce6b948abfa0f2a7c9fb Mon Sep 17 00:00:00 2001 From: Krishna Krothapalli Date: Mon, 8 Jun 2026 11:43:31 +0200 Subject: [PATCH] Update RT-DETR confidence threshold dynamically Signed-off-by: Krishna Krothapalli --- .../isaac_ros_rtdetr/rtdetr_decoder_node.hpp | 6 ++++++ isaac_ros_rtdetr/src/rtdetr_decoder_node.cpp | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/isaac_ros_rtdetr/include/isaac_ros_rtdetr/rtdetr_decoder_node.hpp b/isaac_ros_rtdetr/include/isaac_ros_rtdetr/rtdetr_decoder_node.hpp index 68b71e2..92d959d 100644 --- a/isaac_ros_rtdetr/include/isaac_ros_rtdetr/rtdetr_decoder_node.hpp +++ b/isaac_ros_rtdetr/include/isaac_ros_rtdetr/rtdetr_decoder_node.hpp @@ -20,8 +20,10 @@ #include #include +#include #include "rclcpp/rclcpp.hpp" +#include "rcl_interfaces/msg/set_parameters_result.hpp" #include "isaac_ros_common/qos.hpp" #include "isaac_ros_managed_nitros/managed_nitros_subscriber.hpp" @@ -45,6 +47,9 @@ class RtDetrDecoderNode : public rclcpp::Node private: void InputCallback(const nvidia::isaac_ros::nitros::NitrosTensorListView & msg); + rcl_interfaces::msg::SetParametersResult ParametersCallback( + const std::vector & parameters); + // QOS settings rclcpp::QoS input_qos_; rclcpp::QoS output_qos_; @@ -60,6 +65,7 @@ class RtDetrDecoderNode : public rclcpp::Node std::string boxes_tensor_name_{}; std::string scores_tensor_name_{}; double confidence_threshold_{}; + rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr parameter_callback_handle_; cudaStream_t stream_; }; diff --git a/isaac_ros_rtdetr/src/rtdetr_decoder_node.cpp b/isaac_ros_rtdetr/src/rtdetr_decoder_node.cpp index be8ccf9..62e2b95 100644 --- a/isaac_ros_rtdetr/src/rtdetr_decoder_node.cpp +++ b/isaac_ros_rtdetr/src/rtdetr_decoder_node.cpp @@ -68,6 +68,12 @@ RtDetrDecoderNode::RtDetrDecoderNode(const rclcpp::NodeOptions options) confidence_threshold_{declare_parameter("confidence_threshold", 0.9)} { cudaStreamCreate(&stream_); + + parameter_callback_handle_ = add_on_set_parameters_callback( + std::bind( + &RtDetrDecoderNode::ParametersCallback, + this, + std::placeholders::_1)); } RtDetrDecoderNode::~RtDetrDecoderNode() @@ -75,6 +81,21 @@ RtDetrDecoderNode::~RtDetrDecoderNode() cudaStreamDestroy(stream_); } +rcl_interfaces::msg::SetParametersResult RtDetrDecoderNode::ParametersCallback( + const std::vector & parameters) +{ + rcl_interfaces::msg::SetParametersResult result; + result.successful = true; + + for (const auto ¶meter : parameters) { + if (parameter.get_name() == "confidence_threshold") { + confidence_threshold_ = parameter.as_double(); + } + } + + return result; +} + void RtDetrDecoderNode::InputCallback( const nvidia::isaac_ros::nitros::NitrosTensorListView & msg) {