Apollo 10.0
自动驾驶开放平台
apollo::prediction::Predictor类 参考abstract

#include <predictor.h>

类 apollo::prediction::Predictor 继承关系图:
apollo::prediction::Predictor 的协作图:

Public 成员函数

 Predictor ()=default
 Constructor
 
virtual ~Predictor ()=default
 Destructor
 
virtual bool Predict (const ADCTrajectoryContainer *adc_trajectory_container, Obstacle *obstacle, ObstaclesContainer *obstacles_container)=0
 Make prediction
 
int NumOfTrajectories (const Obstacle &obstacle)
 Get trajectory size
 
virtual void Clear ()
 Clear all trajectories
 
void TrimTrajectories (const ADCTrajectoryContainer &adc_trajectory_container, Obstacle *obstacle)
 Trim prediction trajectories by adc trajectory
 
const ObstacleConf::PredictorTypepredictor_type ()
 get the predictor type
 

Protected 成员函数

void SetEqualProbability (const double probability, const int start_index, Obstacle *obstacle_ptr)
 Set equal probability to prediction trajectories
 
bool TrimTrajectory (const ADCTrajectoryContainer &adc_trajectory_container, Obstacle *obstacle, Trajectory *trajectory)
 Trim a single prediction trajectory, keep the portion that is not in junction.
 
bool SupposedToStop (const Feature &feature, const double stop_distance, double *acceleration)
 Determine if an obstacle is supposed to stop within a distance
 

静态 Protected 成员函数

static Trajectory GenerateTrajectory (const std::vector< apollo::common::TrajectoryPoint > &points)
 Generate trajectory from trajectory points
 

Protected 属性

ObstacleConf::PredictorType predictor_type_
 

详细描述

在文件 predictor.h38 行定义.

构造及析构函数说明

◆ Predictor()

apollo::prediction::Predictor::Predictor ( )
default

Constructor

◆ ~Predictor()

virtual apollo::prediction::Predictor::~Predictor ( )
virtualdefault

Destructor

成员函数说明

◆ Clear()

void apollo::prediction::Predictor::Clear ( )
virtual

Clear all trajectories

apollo::prediction::SequencePredictor 重载.

在文件 predictor.cc55 行定义.

55{}

◆ GenerateTrajectory()

Trajectory apollo::prediction::Predictor::GenerateTrajectory ( const std::vector< apollo::common::TrajectoryPoint > &  points)
staticprotected

Generate trajectory from trajectory points

参数
Avector of trajectory points
返回
Generated trajectory

在文件 predictor.cc34 行定义.

35 {
36 Trajectory trajectory;
37 *trajectory.mutable_trajectory_point() = {points.begin(), points.end()};
38 return trajectory;
39}

◆ NumOfTrajectories()

int apollo::prediction::Predictor::NumOfTrajectories ( const Obstacle obstacle)

Get trajectory size

返回
Size of trajectories

在文件 predictor.cc29 行定义.

29 {
30 CHECK_GT(obstacle.history_size(), 0U);
31 return obstacle.latest_feature().predicted_trajectory_size();
32}

◆ Predict()

virtual bool apollo::prediction::Predictor::Predict ( const ADCTrajectoryContainer adc_trajectory_container,
Obstacle obstacle,
ObstaclesContainer obstacles_container 
)
pure virtual

◆ predictor_type()

const ObstacleConf::PredictorType & apollo::prediction::Predictor::predictor_type ( )

get the predictor type

返回
the predictor type

在文件 predictor.cc140 行定义.

140 {
141 return predictor_type_;
142}
ObstacleConf::PredictorType predictor_type_
Definition predictor.h:125

◆ SetEqualProbability()

void apollo::prediction::Predictor::SetEqualProbability ( const double  probability,
const int  start_index,
Obstacle obstacle_ptr 
)
protected

Set equal probability to prediction trajectories

参数
probabilitytotal probability
start_indexThe start index to set equal probability
obstacle

在文件 predictor.cc41 行定义.

43 {
44 int num = NumOfTrajectories(*obstacle_ptr);
45 ACHECK(num > start_index);
46
47 const auto prob = total_probability / static_cast<double>(num - start_index);
48 for (int i = start_index; i < num; ++i) {
49 obstacle_ptr->mutable_latest_feature()
50 ->mutable_predicted_trajectory(i)
51 ->set_probability(prob);
52 }
53}
int NumOfTrajectories(const Obstacle &obstacle)
Get trajectory size
Definition predictor.cc:29
#define ACHECK(cond)
Definition log.h:80

◆ SupposedToStop()

bool apollo::prediction::Predictor::SupposedToStop ( const Feature feature,
const double  stop_distance,
double *  acceleration 
)
protected

Determine if an obstacle is supposed to stop within a distance

参数
Thelatest feature of obstacle
Thedistance to stop
Theoutput param of acceleration
返回
If the obstacle is supposed to stop within a distance

在文件 predictor.cc125 行定义.

127 {
128 if (stop_distance < std::max(feature.length() * 0.5, 1.0)) {
129 return false;
130 }
131 if (stop_distance > FLAGS_distance_to_slow_down_at_stop_sign) {
132 return false;
133 }
134 double speed = feature.speed();
135 *acceleration = -speed * speed / (2.0 * stop_distance);
136 return *acceleration <= -FLAGS_double_precision &&
137 *acceleration >= FLAGS_vehicle_min_linear_acc;
138}

◆ TrimTrajectories()

void apollo::prediction::Predictor::TrimTrajectories ( const ADCTrajectoryContainer adc_trajectory_container,
Obstacle obstacle 
)

Trim prediction trajectories by adc trajectory

参数
ADCtrajectory container
obstacle

在文件 predictor.cc57 行定义.

59 {
60 for (auto& predicted_trajectory :
61 *obstacle->mutable_latest_feature()->mutable_predicted_trajectory()) {
62 TrimTrajectory(adc_trajectory_container, obstacle, &predicted_trajectory);
63 }
64}
bool TrimTrajectory(const ADCTrajectoryContainer &adc_trajectory_container, Obstacle *obstacle, Trajectory *trajectory)
Trim a single prediction trajectory, keep the portion that is not in junction.
Definition predictor.cc:66

◆ TrimTrajectory()

bool apollo::prediction::Predictor::TrimTrajectory ( const ADCTrajectoryContainer adc_trajectory_container,
Obstacle obstacle,
Trajectory trajectory 
)
protected

Trim a single prediction trajectory, keep the portion that is not in junction.

参数
adc_segmentstrajectory segments of ADC trajectory
obstacle
trajectoryThe trimed prediction trajectory
返回
If the prediction trajectory is trimed

在文件 predictor.cc66 行定义.

68 {
69 if (!adc_trajectory_container.IsProtected()) {
70 ADEBUG << "Not in protection mode.";
71 return false;
72 }
73 if (obstacle == nullptr || obstacle->history_size() == 0) {
74 AERROR << "Invalid obstacle.";
75 return false;
76 }
77 int num_of_point = trajectory->trajectory_point_size();
78 if (num_of_point == 0) {
79 return false;
80 }
81 const Feature& feature = obstacle->latest_feature();
82 double vehicle_length = feature.length();
83 double vehicle_heading = feature.velocity_heading();
84 double forward_length =
85 std::fmax(vehicle_length / 2.0 - FLAGS_distance_beyond_junction, 0.0);
86
87 double front_x = trajectory->trajectory_point(0).path_point().x() +
88 forward_length * std::cos(vehicle_heading);
89 double front_y = trajectory->trajectory_point(0).path_point().y() +
90 forward_length * std::sin(vehicle_heading);
91 PathPoint front_point;
92 front_point.set_x(front_x);
93 front_point.set_y(front_y);
94 bool front_in_junction =
95 adc_trajectory_container.IsPointInJunction(front_point);
96
97 const PathPoint& start_point = trajectory->trajectory_point(0).path_point();
98 bool start_in_junction =
99 adc_trajectory_container.IsPointInJunction(start_point);
100
101 if (front_in_junction || start_in_junction) {
102 return false;
103 }
104
105 int index = 0;
106 while (index < num_of_point) {
107 const PathPoint& point = trajectory->trajectory_point(index).path_point();
108 if (adc_trajectory_container.IsPointInJunction(point)) {
109 break;
110 }
111 ++index;
112 }
113
114 // if no intersect
115 if (index == num_of_point) {
116 return false;
117 }
118
119 for (int i = index; i < num_of_point; ++i) {
120 trajectory->mutable_trajectory_point()->RemoveLast();
121 }
122 return true;
123}
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44

类成员变量说明

◆ predictor_type_

ObstacleConf::PredictorType apollo::prediction::Predictor::predictor_type_
protected

在文件 predictor.h125 行定义.


该类的文档由以下文件生成: