修复quequ报错

This commit is contained in:
cyy_mac
2026-03-28 04:39:02 +08:00
parent 9367f6e92a
commit 5a7e8425f6
2 changed files with 3 additions and 28 deletions

View File

@@ -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<YoloObject>& yolo_objects);
void callSetExposureService(double exposure_time);

View File

@@ -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<Detector> 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<rclcpp::CallbackQueue>();
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<int>(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<rclcpp::CallbackQueue>();
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<int>(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<int>(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();