Apollo  6.0
Open source self driving car software
predictor.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 <vector>
25 
29 #include "modules/prediction/proto/prediction_obstacle.pb.h"
30 
35 namespace apollo {
36 namespace prediction {
37 
38 class Predictor {
39  public:
43  Predictor() = default;
44 
48  virtual ~Predictor() = default;
49 
56  virtual bool Predict(const ADCTrajectoryContainer* adc_trajectory_container,
57  Obstacle* obstacle,
58  ObstaclesContainer* obstacles_container) = 0;
59 
64  int NumOfTrajectories(const Obstacle& obstacle);
65 
69  virtual void Clear();
70 
76  void TrimTrajectories(const ADCTrajectoryContainer& adc_trajectory_container,
77  Obstacle* obstacle);
78 
83  const ObstacleConf::PredictorType& predictor_type();
84 
85  protected:
91  static Trajectory GenerateTrajectory(
92  const std::vector<apollo::common::TrajectoryPoint>& points);
93 
100  void SetEqualProbability(const double probability, const int start_index,
101  Obstacle* obstacle_ptr);
102 
111  bool TrimTrajectory(const ADCTrajectoryContainer& adc_trajectory_container,
112  Obstacle* obstacle, Trajectory* trajectory);
113 
121  bool SupposedToStop(const Feature& feature, const double stop_distance,
122  double* acceleration);
123 
124  protected:
125  ObstacleConf::PredictorType predictor_type_;
126 };
127 
128 } // namespace prediction
129 } // namespace apollo
static Trajectory GenerateTrajectory(const std::vector< apollo::common::TrajectoryPoint > &points)
Generate trajectory from trajectory points.
void SetEqualProbability(const double probability, const int start_index, Obstacle *obstacle_ptr)
Set equal probability to prediction trajectories.
Prediction obstacle.
Definition: obstacle.h:52
virtual ~Predictor()=default
Destructor.
Definition: obstacles_container.h:39
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
void TrimTrajectories(const ADCTrajectoryContainer &adc_trajectory_container, Obstacle *obstacle)
Trim prediction trajectories by adc trajectory.
Obstacle.
ObstacleConf::PredictorType predictor_type_
Definition: predictor.h:125
Definition: predictor.h:38
int NumOfTrajectories(const Obstacle &obstacle)
Get trajectory size.
ADC trajectory container.
bool SupposedToStop(const Feature &feature, const double stop_distance, double *acceleration)
Determine if an obstacle is supposed to stop within a distance.
const ObstacleConf::PredictorType & predictor_type()
get the predictor type
Predictor()=default
Constructor.
Obstacles container.
Definition: adc_trajectory_container.h:37
virtual void Clear()
Clear all trajectories.
virtual bool Predict(const ADCTrajectoryContainer *adc_trajectory_container, Obstacle *obstacle, ObstaclesContainer *obstacles_container)=0
Make prediction.
bool TrimTrajectory(const ADCTrajectoryContainer &adc_trajectory_container, Obstacle *obstacle, Trajectory *trajectory)
Trim a single prediction trajectory, keep the portion that is not in junction.