Apollo  6.0
Open source self driving car software
laps_checker.h
Go to the documentation of this file.
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 <map>
19 #include <memory>
20 #include <utility>
21 #include <vector>
22 
23 #include "modules/map/tools/map_datachecker/proto/collection_error_code.pb.h"
25 
26 namespace apollo {
27 namespace hdmap {
28 
29 struct GridMeta {
30  double alpha;
31  std::vector<int> idxs;
32 };
33 typedef std::vector<GridMeta> Grid;
34 
35 class LapsChecker {
36  public:
37  LapsChecker(const std::vector<FramePose>& poses, int laps_to_check,
38  std::shared_ptr<JsonConf> sp_conf);
39  ErrorCode Check();
40  double GetProgress() const;
41  double GetConfidence();
42  size_t GetLap() const;
43  ErrorCode GetReturnState();
44 
45  private:
46  void DoCheck();
47  int SetupGridsMap();
48  int CheckLaps();
49  int CheckParams();
50  int GetMinMax();
51  int DoSetupGridsMap();
52  double CalcAlpha(int pose_index);
53  int PutPoseToGrid(int pose_index, int grid_y, int grid_x);
54  int PutPoseToNeighborGrid(int pose_index);
55  int GetPassedGrid(int pose_index, std::vector<int>* sp_grid_x,
56  std::vector<int>* sp_grid_y);
57  double Slope(double x1, double y1, double x2, double y2);
58  int GatherTimestamps(std::vector<double>* sp_stamps, double alpha,
59  int center_x, int center_y);
60  inline int SetProgress(double p);
61 
62  public:
63  const std::vector<FramePose>& poses_;
64  double maxx_, maxy_, minx_, miny_;
65  std::vector<std::vector<Grid>> grids_map_;
66  bool finished_;
67 
68  private:
69  std::vector<double> confidence_;
70  double progress_;
71  size_t laps_to_check_;
72  size_t possible_max_laps_;
73  size_t lap_;
74  std::shared_ptr<JsonConf> sp_conf_;
75  ErrorCode return_state_;
76 };
77 
78 } // namespace hdmap
79 } // namespace apollo
std::vector< std::vector< Grid > > grids_map_
Definition: laps_checker.h:65
double alpha
Definition: laps_checker.h:30
Definition: laps_checker.h:29
std::vector< GridMeta > Grid
Definition: laps_checker.h:33
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: laps_checker.h:35
std::vector< int > idxs
Definition: laps_checker.h:31
const std::vector< FramePose > & poses_
Definition: laps_checker.h:63
bool finished_
Definition: laps_checker.h:66
double miny_
Definition: laps_checker.h:64