28void EightRoute::Reset() {
33bool EightRoute::IsEightRoutePose(
const std::vector<FramePose>& poses,
35 if (poses.empty() || pose_index <= 0 ||
36 pose_index >=
static_cast<int>(poses.size())) {
37 AINFO <<
"params error, poses size: " << poses.size()
38 <<
", pose_index: " << pose_index;
42 double yaw =
GetYaw(poses[pose_index - 1].tx, poses[pose_index - 1].ty,
43 poses[pose_index].tx, poses[pose_index].ty);
44 double yaw_diff = fabs(last_yaw_ - yaw);
46 yaw_diff = yaw_diff < 180 ? yaw_diff : 360 - yaw_diff;
48 double xdiff = poses[pose_index].tx - poses[pose_index - 1].tx;
49 double ydiff = poses[pose_index].ty - poses[pose_index - 1].ty;
50 double zdiff = poses[pose_index].tz - poses[pose_index - 1].tz;
51 double dist = std::sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
53 poses[pose_index].time_stamp - poses[pose_index - 1].time_stamp;
55 AINFO <<
"skip back pose is bad pose";
58 double vel = dist / during;
59 AINFO << poses[pose_index].time_stamp <<
", yaw_diff:" << yaw_diff
60 <<
", dist: " << dist <<
", during: " << during <<
", vel: " << vel;
67double EightRoute::GetGoodPoseDuring() {
75double EightRoute::GetEightRouteProgress(
const std::vector<FramePose>& poses) {
76 int size =
static_cast<int>(poses.size());
79 while (start_index < size) {
81 IsEightRoutePose(poses, start_index)) {
82 AINFO <<
"find first good pose.index:" << start_index;
87 if (start_index >= size) {
89 <<
", start_index: " << start_index <<
", pose size: " << size;
92 if (start_index + 1 >= size) {
93 AINFO <<
"not have enough poses, wait for a moment";
96 last_yaw_ =
GetYaw(poses[start_index].tx, poses[start_index].ty,
97 poses[start_index + 1].tx, poses[start_index + 1].ty);
99 int not_eight_count = 0;
100 for (
int i = start_index + 2; i < size; ++i) {
102 AINFO <<
"not good pose";
105 if (!IsEightRoutePose(poses, i)) {
107 AINFO <<
"not eight route pose";
108 if (not_eight_count >
sp_conf_->eight_bad_pose_tolerance) {
109 AINFO <<
"not-eight pose count reached upper limitation";
116 AINFO <<
"good pose";
120 double eight_route_during = GetGoodPoseDuring();
121 if (eight_route_during < 1e-8) {
122 AINFO <<
"num of eight route good pose too small, during: "
123 << eight_route_during;
128 double progress = eight_route_during /
sp_conf_->eight_duration;
129 if (progress >= 1.0) {
137 AINFO <<
"[EightRoute::process] begin";
138 size_t size = poses.size();
144 progress_ = GetEightRouteProgress(poses);
146 AINFO <<
"get_eight_route_progress failed.";
154 AINFO <<
"[EightRoute::process] end, progress:" << progress_;
std::shared_ptr< JsonConf > sp_conf_
virtual void ClearGoodPoseInfo()
int TimeToIndex(const std::vector< FramePose > &poses, double time)
virtual bool IsGoodPose(const std::vector< FramePose > &poses, int pose_index)
std::shared_ptr< BadOrGoodPoseInfo > sp_good_pose_info_
virtual void UpdateGoodPoseInfo(const FramePose &pose)
double GetProgress() const
EightRoute(std::shared_ptr< JsonConf > sp_conf)
ErrorCode Process(const std::vector< FramePose > &poses)
@ ERROR_VERIFY_NO_GNSSPOS
double GetYaw(double from_x, double from_y, double to_x, double to_y)