Apollo 10.0
自动驾驶开放平台
alignment.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16#pragma once
17
18#include <memory>
19#include <vector>
20
21#include "modules/map/tools/map_datachecker/proto/collection_error_code.pb.h"
23
24namespace apollo {
25namespace hdmap {
26
27typedef struct BadOrGoodPoseInfo {
29 double start_time;
30 double end_time;
32} BadOrGoodPoseInfo;
33
34class Alignment {
35 public:
36 explicit Alignment(std::shared_ptr<JsonConf> sp_conf)
38 sp_conf_(sp_conf),
40 sp_bad_pose_info_(std::make_shared<BadOrGoodPoseInfo>()) {}
41
42 virtual ~Alignment() {}
43 virtual ErrorCode Process(const std::vector<FramePose>& poses) = 0;
44 virtual void Reset() = 0;
45
46 virtual double GetProgress() const { return progress_; }
47
48 virtual void SetStartTime(double start_time) { start_time_ = start_time; }
49
50 virtual void SetEndTime(double end_time) { end_time_ = end_time; }
51
52 virtual void UpdateBadPoseInfo(const FramePose& pose) {
54 }
55
57
58 virtual void UpdateGoodPoseInfo(const FramePose& pose) {
60 }
61
63
64 virtual bool IsGoodPose(const std::vector<FramePose>& poses, int pose_index) {
65 if (pose_index <= 0 || pose_index >= static_cast<int>(poses.size())) {
66 AINFO << "params error. poses size:" << poses.size()
67 << ",pose_index:" << pose_index;
68 return false;
69 }
70
71 unsigned int position_type = poses[pose_index].position_type;
72 float diff_age = poses[pose_index].diff_age;
73 double local_std = poses[pose_index].local_std;
74
75 if (sp_conf_->position_type_range.find(position_type) !=
76 sp_conf_->position_type_range.end() &&
77 diff_age >= sp_conf_->diff_age_range.first &&
78 diff_age <= sp_conf_->diff_age_range.second &&
79 local_std <= sp_conf_->local_std_upper_limit) {
80 return true;
81 }
82 return false;
83 }
84
86
87 protected:
88 void UpdatePoseInfo(const FramePose& pose,
89 std::shared_ptr<BadOrGoodPoseInfo> sp_pose_info) {
90 if (sp_pose_info == nullptr) {
91 AERROR << "sp_pose_info is nullptr";
92 return;
93 }
94 BadOrGoodPoseInfo& pose_info = *sp_pose_info;
95 if (pose_info.pose_count == 0) {
96 pose_info.start_time = pose.time_stamp;
97 ++pose_info.pose_count;
98 AINFO << "update start time: " << pose_info.start_time
99 << ",pose count: " << pose_info.pose_count;
100 } else {
101 pose_info.end_time = pose.time_stamp;
102 ++pose_info.pose_count;
103 AINFO << "update start time: " << pose_info.start_time
104 << ",pose count: " << pose_info.pose_count;
105 }
106 }
107
108 void ClearPoseInfo(std::shared_ptr<BadOrGoodPoseInfo> sp_pose_info) {
109 if (sp_pose_info == nullptr) {
110 AERROR << "sp_pose_info is nullptr";
111 return;
112 }
113 BadOrGoodPoseInfo& pose_info = *sp_pose_info;
114 pose_info.start_time = -1.0;
115 pose_info.end_time = -1.0;
116 pose_info.pose_count = 0;
117 }
118
119 int TimeToIndex(const std::vector<FramePose>& poses, double time) {
120 size_t size = poses.size();
121 if (size == 0 || time <= 0) {
122 return -1;
123 }
124
125 for (size_t i = 0; i < size; ++i) {
126 if (poses[i].time_stamp >= time) {
127 return static_cast<int>(i);
128 }
129 }
130 return static_cast<int>(size);
131 }
132
133 protected:
134 double progress_;
137 double end_time_;
141 std::shared_ptr<JsonConf> sp_conf_ = nullptr;
142 // BadOrGoodPoseInfo _bad_pose_info, _good_pose_info;
143 std::shared_ptr<BadOrGoodPoseInfo> sp_good_pose_info_ = nullptr;
144 std::shared_ptr<BadOrGoodPoseInfo> sp_bad_pose_info_ = nullptr;
145};
146
147} // namespace hdmap
148} // namespace apollo
void ClearPoseInfo(std::shared_ptr< BadOrGoodPoseInfo > sp_pose_info)
Definition alignment.h:108
virtual double GetProgress() const
Definition alignment.h:46
virtual void SetStartTime(double start_time)
Definition alignment.h:48
virtual ErrorCode Process(const std::vector< FramePose > &poses)=0
Alignment(std::shared_ptr< JsonConf > sp_conf)
Definition alignment.h:36
std::shared_ptr< JsonConf > sp_conf_
Definition alignment.h:141
virtual void ClearGoodPoseInfo()
Definition alignment.h:62
virtual void Reset()=0
virtual void ClearBadPoseInfo()
Definition alignment.h:56
virtual void UpdateBadPoseInfo(const FramePose &pose)
Definition alignment.h:52
int TimeToIndex(const std::vector< FramePose > &poses, double time)
Definition alignment.h:119
virtual bool IsGoodPose(const std::vector< FramePose > &poses, int pose_index)
Definition alignment.h:64
void UpdatePoseInfo(const FramePose &pose, std::shared_ptr< BadOrGoodPoseInfo > sp_pose_info)
Definition alignment.h:88
std::shared_ptr< BadOrGoodPoseInfo > sp_good_pose_info_
Definition alignment.h:143
ErrorCode GetReturnState() const
Definition alignment.h:85
std::shared_ptr< BadOrGoodPoseInfo > sp_bad_pose_info_
Definition alignment.h:144
virtual void UpdateGoodPoseInfo(const FramePose &pose)
Definition alignment.h:58
virtual void SetEndTime(double end_time)
Definition alignment.h:50
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37
Definition future.h:29