diff --git a/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector_node.hpp b/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector_node.hpp index c0eb9d8..892056d 100644 --- a/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector_node.hpp +++ b/src/rm_auto_aim/armor_yolo_detect/include/armor_yolo_detect/armor_yolo_detector_node.hpp @@ -168,9 +168,6 @@ private: double exposure_min_ = 600.0; double exposure_max_ = 2000.0; double auto_exposure_control_interval_ms_ = 100.0; - rclcpp::CallbackQueue::SharedPtr exposure_callback_queue_; - rclcpp::executors::SingleThreadedExecutor exposure_executor_; - std::thread exposure_executor_thread_; void autoExposureTimerCallback(); double computeBrightnessInRois(const cv::Mat& gray_img, const std::vector& yolo_objects); void callSetExposureService(double exposure_time); diff --git a/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector_node.cpp b/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector_node.cpp index 9f6aae3..50ddb40 100644 --- a/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector_node.cpp +++ b/src/rm_auto_aim/armor_yolo_detect/src/armor_yolo_detector_node.cpp @@ -188,10 +188,6 @@ ArmorYoloDetectorNode::~ArmorYoloDetectorNode() { if (image_processing_thread_.joinable()) { image_processing_thread_.join(); } - if (exposure_executor_thread_.joinable()) { - exposure_executor_.cancel(); - exposure_executor_thread_.join(); - } } void ArmorYoloDetectorNode::imageCallback(const sensor_msgs::msg::Image::ConstSharedPtr img_msg) { @@ -431,15 +427,9 @@ std::unique_ptr ArmorYoloDetectorNode::initDetector() { current_exposure_time_ = this->declare_parameter("auto_exposure.init_exposure_time", 5000.0); if (auto_exposure_enable_) { - exposure_callback_queue_ = std::make_shared(); - exposure_executor_.add_callback_queue(exposure_callback_queue_); - exposure_executor_thread_ = std::thread([this]() { - exposure_executor_.spin(); - }); auto_exposure_timer_ = this->create_wall_timer( std::chrono::milliseconds(static_cast(auto_exposure_control_interval_ms_)), - [this]() { this->autoExposureTimerCallback(); }, - exposure_callback_queue_); + [this]() { this->autoExposureTimerCallback(); }); FYT_INFO("armor_yolo_detect", "Auto exposure enabled (target_brightness={}, interval={}ms)", target_brightness_, auto_exposure_control_interval_ms_); } @@ -577,23 +567,12 @@ rcl_interfaces::msg::SetParametersResult ArmorYoloDetectorNode::onSetParameters( if (new_enable != auto_exposure_enable_) { auto_exposure_enable_ = new_enable; if (auto_exposure_enable_) { - exposure_callback_queue_ = std::make_shared(); - exposure_executor_.add_callback_queue(exposure_callback_queue_); - exposure_executor_thread_ = std::thread([this]() { - exposure_executor_.spin(); - }); auto_exposure_timer_ = this->create_wall_timer( std::chrono::milliseconds(static_cast(auto_exposure_control_interval_ms_)), - [this]() { this->autoExposureTimerCallback(); }, - exposure_callback_queue_); + [this]() { this->autoExposureTimerCallback(); }); FYT_INFO("armor_yolo_detect", "Auto exposure enabled"); } else { auto_exposure_timer_.reset(); - exposure_callback_queue_.reset(); - if (exposure_executor_thread_.joinable()) { - exposure_executor_.cancel(); - exposure_executor_thread_.join(); - } FYT_INFO("armor_yolo_detect", "Auto exposure disabled"); } } @@ -615,8 +594,7 @@ rcl_interfaces::msg::SetParametersResult ArmorYoloDetectorNode::onSetParameters( auto_exposure_timer_->cancel(); auto_exposure_timer_ = this->create_wall_timer( std::chrono::milliseconds(static_cast(auto_exposure_control_interval_ms_)), - [this]() { this->autoExposureTimerCallback(); }, - exposure_callback_queue_); + [this]() { this->autoExposureTimerCallback(); }); } } else if (param.get_name() == "auto_exposure.init_exposure_time") { current_exposure_time_ = param.as_double();