Apollo  6.0
Open source self driving car software
decision_data.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 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 
17 #pragma once
18 
22 #include "modules/prediction/proto/prediction_obstacle.pb.h"
23 
24 namespace apollo {
25 namespace planning {
26 
27 enum class VirtualObjectType {
28  DESTINATION = 0,
29  CROSSWALK = 1,
30  TRAFFIC_LIGHT = 2,
31  CLEAR_ZONE = 3,
32  REROUTE = 4,
33  DECISION_JUMP = 5,
34  PRIORITY = 6
35 };
36 
37 struct EnumClassHash {
38  template <typename T>
39  size_t operator()(T t) const {
40  return static_cast<size_t>(t);
41  }
42 };
43 
44 class DecisionData {
45  public:
46  DecisionData(const prediction::PredictionObstacles& prediction_obstacles,
47  const ReferenceLine& reference_line);
48  ~DecisionData() = default;
49 
50  public:
51  Obstacle* GetObstacleById(const std::string& id);
52  std::vector<Obstacle*> GetObstacleByType(const VirtualObjectType& type);
53  std::unordered_set<std::string> GetObstacleIdByType(
54  const VirtualObjectType& type);
55  const std::vector<Obstacle*>& GetStaticObstacle() const;
56  const std::vector<Obstacle*>& GetDynamicObstacle() const;
57  const std::vector<Obstacle*>& GetVirtualObstacle() const;
58  const std::vector<Obstacle*>& GetPracticalObstacle() const;
59  const std::vector<Obstacle*>& GetAllObstacle() const;
60 
61  public:
62  bool CreateVirtualObstacle(const ReferencePoint& point,
63  const VirtualObjectType& type,
64  std::string* const id);
65  bool CreateVirtualObstacle(const double point_s,
66  const VirtualObjectType& type,
67  std::string* const id);
68 
69  private:
70  bool IsValidTrajectory(const prediction::Trajectory& trajectory);
71  bool IsValidTrajectoryPoint(const common::TrajectoryPoint& point);
72  bool CreateVirtualObstacle(const common::math::Box2d& obstacle_box,
73  const VirtualObjectType& type,
74  std::string* const id);
75 
76  private:
77  std::vector<Obstacle*> static_obstacle_;
78  std::vector<Obstacle*> dynamic_obstacle_;
79  std::vector<Obstacle*> virtual_obstacle_;
80  std::vector<Obstacle*> practical_obstacle_;
81  std::vector<Obstacle*> all_obstacle_;
82 
83  private:
84  const ReferenceLine& reference_line_;
85  std::list<std::unique_ptr<Obstacle>> obstacles_;
86  std::unordered_map<std::string, Obstacle*> obstacle_map_;
87  std::unordered_map<VirtualObjectType, std::unordered_set<std::string>,
89  virtual_obstacle_id_map_;
90  std::mutex mutex_;
91  std::mutex transaction_mutex_;
92 };
93 
94 } // namespace planning
95 } // namespace apollo
This is the class that associates an Obstacle with its path properties. An obstacle&#39;s path properties...
Definition: obstacle.h:60
VirtualObjectType
Definition: decision_data.h:27
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Planning module main class. It processes GPS and IMU as input, to generate planning info...
Definition: reference_point.h:32
Rectangular (undirected) bounding box in 2-D.
Definition: box2d.h:52
size_t operator()(T t) const
Definition: decision_data.h:39
Definition: decision_data.h:37
Definition: reference_line.h:39
Definition: decision_data.h:44
The class of Box2d. Here, the x/y axes are respectively Forward/Left, as opposed to what happens in e...