Apollo  6.0
Open source self driving car software
visibility.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 #include <map>
18 #include <set>
19 #include <vector>
22 
23 namespace apollo {
24 namespace perception {
25 namespace benchmark {
26 
27 enum class UpdateOperation { add = 0, remove = 1 };
28 
29 class Visibility {
30  public:
31  Visibility(float half_length, float half_width)
32  : half_length_(half_length), half_width_(half_width) {}
33  ~Visibility() = default;
34 
35  void set_car_pos(const Eigen::Vector3d& car_pos);
36 
37  void fill_objects(std::vector<ObjectPtr>* objs, float thresh);
38 
39  private:
40  float calculate(std::vector<ObjectPtr>* objs, float thresh);
41 
42  void reset_state();
43 
44  void add_region();
45 
46  void add_segment(const VisPoint& a, const VisPoint& b, int idx);
47 
48  void query_segments(const VisPoint& p);
49 
50  void update_candidate_segment(const VisPoint& p, UpdateOperation op);
51 
52  float calculate_area(const VisPoint& a, const VisPoint& b);
53 
54  float calculate_visual_angle(const VisPoint& a, const VisPoint& b);
55 
56  private:
57  VisPoint latest_query_point_;
58  std::vector<Segment> latest_query_segments_cache_;
59  std::multimap<VisPoint, Segment> points_;
60  std::set<Segment> candidate_segment_;
61 
62  Eigen::Vector3d car_pos_;
63  std::vector<float> full_visual_angle_;
64  std::vector<float> visual_angle_;
65 
66  float half_length_ = 0;
67  float half_width_ = 0;
68  float area_sum_ = 0;
69  static std::map<int, std::vector<size_t>> s_lut_;
70 };
71 
72 } // namespace benchmark
73 } // namespace perception
74 } // namespace apollo
UpdateOperation
Definition: visibility.h:27
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Eigen::Vector3d Vector3d
Definition: frame_transform.h:27
Visibility(float half_length, float half_width)
Definition: visibility.h:31