Apollo  6.0
Open source self driving car software
predictor_manager.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 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 
22 #pragma once
23 
24 #include <map>
25 #include <memory>
26 
29 #include "modules/prediction/proto/prediction_conf.pb.h"
30 
35 namespace apollo {
36 namespace prediction {
37 
39  public:
44 
48  virtual ~PredictorManager() = default;
49 
54  void Init(const PredictionConf& config);
55 
60  Predictor* GetPredictor(const ObstacleConf::PredictorType& type);
61 
67  void Run(const apollo::perception::PerceptionObstacles& perception_obstacles,
68  const ADCTrajectoryContainer* adc_trajectory_container,
69  ObstaclesContainer* obstacles_container);
70 
78  void PredictObstacle(const ADCTrajectoryContainer* adc_trajectory_container,
79  Obstacle* obstacle,
80  ObstaclesContainer* obstacles_container,
81  PredictionObstacle* const prediction_obstacle);
82 
87  const PredictionObstacles& prediction_obstacles();
88 
89  private:
94  void RegisterPredictor(const ObstacleConf::PredictorType& type);
95 
101  std::unique_ptr<Predictor> CreatePredictor(
102  const ObstacleConf::PredictorType& type);
103 
107  void RegisterPredictors();
108 
109  void PredictObstacles(
110  const apollo::perception::PerceptionObstacles& perception_obstacles,
111  const ADCTrajectoryContainer* adc_trajectory_container,
112  ObstaclesContainer* obstacles_container);
113 
114  void PredictObstaclesInParallel(
115  const apollo::perception::PerceptionObstacles& perception_obstacles,
116  const ADCTrajectoryContainer* adc_trajectory_container,
117  ObstaclesContainer* obstacles_container);
118 
119  void InitVehiclePredictors(const ObstacleConf& conf);
120 
121  void InitCyclistPredictors(const ObstacleConf& conf);
122 
123  void InitDefaultPredictors(const ObstacleConf& conf);
124 
125  void RunVehiclePredictor(
126  const ADCTrajectoryContainer* adc_trajectory_container,
127  Obstacle* obstacle, ObstaclesContainer* obstacles_container);
128 
129  void RunPedestrianPredictor(
130  const ADCTrajectoryContainer* adc_trajectory_container,
131  Obstacle* obstacle, ObstaclesContainer* obstacles_container);
132 
133  void RunCyclistPredictor(
134  const ADCTrajectoryContainer* adc_trajectory_container,
135  Obstacle* obstacle, ObstaclesContainer* obstacles_container);
136 
137  void RunDefaultPredictor(
138  const ADCTrajectoryContainer* adc_trajectory_container,
139  Obstacle* obstacle, ObstaclesContainer* obstacles_container);
140 
141  void RunEmptyPredictor(const ADCTrajectoryContainer* adc_trajectory_container,
142  Obstacle* obstacle,
143  ObstaclesContainer* obstacles_container);
144 
145  private:
146  std::map<ObstacleConf::PredictorType, std::unique_ptr<Predictor>> predictors_;
147 
148  ObstacleConf::PredictorType vehicle_on_lane_predictor_ =
149  ObstacleConf::LANE_SEQUENCE_PREDICTOR;
150 
151  ObstacleConf::PredictorType vehicle_off_lane_predictor_ =
152  ObstacleConf::FREE_MOVE_PREDICTOR;
153 
154  ObstacleConf::PredictorType vehicle_in_junction_predictor_ =
155  ObstacleConf::LANE_SEQUENCE_PREDICTOR;
156 
157  ObstacleConf::PredictorType cyclist_on_lane_predictor_ =
158  ObstacleConf::LANE_SEQUENCE_PREDICTOR;
159 
160  ObstacleConf::PredictorType cyclist_off_lane_predictor_ =
161  ObstacleConf::FREE_MOVE_PREDICTOR;
162 
163  ObstacleConf::PredictorType pedestrian_predictor_ =
164  ObstacleConf::FREE_MOVE_PREDICTOR;
165 
166  ObstacleConf::PredictorType default_on_lane_predictor_ =
167  ObstacleConf::LANE_SEQUENCE_PREDICTOR;
168 
169  ObstacleConf::PredictorType default_off_lane_predictor_ =
170  ObstacleConf::FREE_MOVE_PREDICTOR;
171 
172  ObstacleConf::PredictorType vehicle_on_lane_caution_predictor_ =
173  ObstacleConf::MOVE_SEQUENCE_PREDICTOR;
174 
175  ObstacleConf::PredictorType vehicle_in_junction_caution_predictor_ =
176  ObstacleConf::INTERACTION_PREDICTOR;
177 
178  ObstacleConf::PredictorType vehicle_default_caution_predictor_ =
179  ObstacleConf::EXTRAPOLATION_PREDICTOR;
180 
181  PredictionObstacles prediction_obstacles_;
182 };
183 
184 } // namespace prediction
185 } // namespace apollo
Define the predictor base class.
Prediction obstacle.
Definition: obstacle.h:52
Definition: obstacles_container.h:39
Definition: predictor_manager.h:38
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Predictor * GetPredictor(const ObstacleConf::PredictorType &type)
Get predictor.
void Run(const apollo::perception::PerceptionObstacles &perception_obstacles, const ADCTrajectoryContainer *adc_trajectory_container, ObstaclesContainer *obstacles_container)
Execute the predictor generation.
void Init(const PredictionConf &config)
Initializer.
Definition: predictor.h:38
virtual ~PredictorManager()=default
Destructor.
const PredictionObstacles & prediction_obstacles()
Get prediction obstacles.
void PredictObstacle(const ADCTrajectoryContainer *adc_trajectory_container, Obstacle *obstacle, ObstaclesContainer *obstacles_container, PredictionObstacle *const prediction_obstacle)
Predict a single obstacle.
Obstacles container.
Definition: adc_trajectory_container.h:37