修复quequ报错
This commit is contained in:
@@ -168,9 +168,6 @@ private:
|
|||||||
double exposure_min_ = 600.0;
|
double exposure_min_ = 600.0;
|
||||||
double exposure_max_ = 2000.0;
|
double exposure_max_ = 2000.0;
|
||||||
double auto_exposure_control_interval_ms_ = 100.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();
|
void autoExposureTimerCallback();
|
||||||
double computeBrightnessInRois(const cv::Mat& gray_img, const std::vector<YoloObject>& yolo_objects);
|
double computeBrightnessInRois(const cv::Mat& gray_img, const std::vector<YoloObject>& yolo_objects);
|
||||||
void callSetExposureService(double exposure_time);
|
void callSetExposureService(double exposure_time);
|
||||||
|
|||||||
@@ -188,10 +188,6 @@ ArmorYoloDetectorNode::~ArmorYoloDetectorNode() {
|
|||||||
if (image_processing_thread_.joinable()) {
|
if (image_processing_thread_.joinable()) {
|
||||||
image_processing_thread_.join();
|
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) {
|
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);
|
current_exposure_time_ = this->declare_parameter("auto_exposure.init_exposure_time", 5000.0);
|
||||||
|
|
||||||
if (auto_exposure_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(
|
auto_exposure_timer_ = this->create_wall_timer(
|
||||||
std::chrono::milliseconds(static_cast<int>(auto_exposure_control_interval_ms_)),
|
std::chrono::milliseconds(static_cast<int>(auto_exposure_control_interval_ms_)),
|
||||||
[this]() { this->autoExposureTimerCallback(); },
|
[this]() { this->autoExposureTimerCallback(); });
|
||||||
exposure_callback_queue_);
|
|
||||||
FYT_INFO("armor_yolo_detect", "Auto exposure enabled (target_brightness={}, interval={}ms)",
|
FYT_INFO("armor_yolo_detect", "Auto exposure enabled (target_brightness={}, interval={}ms)",
|
||||||
target_brightness_, auto_exposure_control_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_) {
|
if (new_enable != auto_exposure_enable_) {
|
||||||
auto_exposure_enable_ = new_enable;
|
auto_exposure_enable_ = new_enable;
|
||||||
if (auto_exposure_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(
|
auto_exposure_timer_ = this->create_wall_timer(
|
||||||
std::chrono::milliseconds(static_cast<int>(auto_exposure_control_interval_ms_)),
|
std::chrono::milliseconds(static_cast<int>(auto_exposure_control_interval_ms_)),
|
||||||
[this]() { this->autoExposureTimerCallback(); },
|
[this]() { this->autoExposureTimerCallback(); });
|
||||||
exposure_callback_queue_);
|
|
||||||
FYT_INFO("armor_yolo_detect", "Auto exposure enabled");
|
FYT_INFO("armor_yolo_detect", "Auto exposure enabled");
|
||||||
} else {
|
} else {
|
||||||
auto_exposure_timer_.reset();
|
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");
|
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_->cancel();
|
||||||
auto_exposure_timer_ = this->create_wall_timer(
|
auto_exposure_timer_ = this->create_wall_timer(
|
||||||
std::chrono::milliseconds(static_cast<int>(auto_exposure_control_interval_ms_)),
|
std::chrono::milliseconds(static_cast<int>(auto_exposure_control_interval_ms_)),
|
||||||
[this]() { this->autoExposureTimerCallback(); },
|
[this]() { this->autoExposureTimerCallback(); });
|
||||||
exposure_callback_queue_);
|
|
||||||
}
|
}
|
||||||
} else if (param.get_name() == "auto_exposure.init_exposure_time") {
|
} else if (param.get_name() == "auto_exposure.init_exposure_time") {
|
||||||
current_exposure_time_ = param.as_double();
|
current_exposure_time_ = param.as_double();
|
||||||
|
|||||||
Reference in New Issue
Block a user