未验证 提交 aab16153 编写于 作者: L lishuanghua 提交者: GitHub

D-Kit : Add localization timer (#12796)

上级 f2fef815
......@@ -59,8 +59,7 @@ cc_binary(
cc_test(
name = "msf_localization_test",
size = "small",
timeout = "short",
size = "enormous",
srcs = ["msf_localization_test.cc"],
copts = [
"-fno-access-control",
......
......@@ -185,6 +185,10 @@ void MSFLocalization::InitParams() {
FLAGS_localization_std_x_threshold_2;
localization_param_.localization_std_y_threshold_2 =
FLAGS_localization_std_y_threshold_2;
localization_timer_.reset(new cyber::Timer(
10, [this]() { this->OnLocalizationTimer(); }, false));
localization_timer_->Start();
}
void MSFLocalization::OnPointCloud(
......@@ -304,7 +308,7 @@ void MSFLocalization::OnGnssHeading(
localization_integ_.GnssHeadingProcess(*gnss_heading_msg);
}
void MSFLocalization::OnGps() {
void MSFLocalization::OnLocalizationTimer() {
if (!raw_imu_msg_) {
return;
}
......
......@@ -75,9 +75,9 @@ class MSFLocalization {
const std::shared_ptr<drivers::gnss::GnssBestPose> &bestgnsspos_msg);
void OnGnssHeading(
const std::shared_ptr<drivers::gnss::Heading> &gnss_heading_msg);
void OnGps();
void SetPublisher(const std::shared_ptr<LocalizationMsgPublisher> &publisher);
void OnLocalizationTimer();
private:
bool LoadGnssAntennaExtrinsic(const std::string &file_path, double *offset_x,
......@@ -105,6 +105,7 @@ class MSFLocalization {
std::shared_ptr<LocalizationMsgPublisher> publisher_;
std::shared_ptr<drivers::gnss::Imu> raw_imu_msg_;
std::mutex mutex_imu_msg_;
std::unique_ptr<cyber::Timer> localization_timer_ = nullptr;
};
} // namespace localization
......
......@@ -49,7 +49,6 @@ bool MSFLocalizationComponent::InitConfig() {
lidar_topic_ = FLAGS_lidar_topic;
bestgnsspos_topic_ = FLAGS_gnss_best_pose_topic;
gnss_heading_topic_ = FLAGS_heading_topic;
gps_topic_ = FLAGS_gps_topic;
if (!publisher_->InitConfig()) {
AERROR << "Init publisher config failed.";
......@@ -90,10 +89,6 @@ bool MSFLocalizationComponent::InitIO() {
gnss_heading_listener_ = this->node_->CreateReader<drivers::gnss::Heading>(
gnss_heading_topic_, gnss_heading_call);
std::function<void(const std::shared_ptr<Gps>& gps_msg)> gps_call =
std::bind(&MSFLocalization::OnGps, &localization_);
gps_listener_ = this->node_->CreateReader<Gps>(gps_topic_, gps_call);
// init writer
if (!publisher_->InitIO()) {
AERROR << "Init publisher io failed.";
......
......@@ -63,9 +63,6 @@ class MSFLocalizationComponent final
gnss_heading_listener_ = nullptr;
std::string gnss_heading_topic_ = "";
std::shared_ptr<cyber::Reader<Gps>> gps_listener_ = nullptr;
std::string gps_topic_ = "";
private:
std::shared_ptr<LocalizationMsgPublisher> publisher_;
MSFLocalization localization_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册