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

#include <free_move_predictor.h>

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

Public 成员函数

 FreeMovePredictor ()
 Constructor
 
virtual ~FreeMovePredictor ()=default
 Destructor
 
bool Predict (const ADCTrajectoryContainer *adc_trajectory_container, Obstacle *obstacle, ObstaclesContainer *obstacles_container) override
 Make prediction
 
- Public 成员函数 继承自 apollo::prediction::Predictor
 Predictor ()=default
 Constructor
 
virtual ~Predictor ()=default
 Destructor
 
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 成员函数 继承自 apollo::prediction::Predictor
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 成员函数 继承自 apollo::prediction::Predictor
static Trajectory GenerateTrajectory (const std::vector< apollo::common::TrajectoryPoint > &points)
 Generate trajectory from trajectory points
 
- Protected 属性 继承自 apollo::prediction::Predictor
ObstacleConf::PredictorType predictor_type_
 

详细描述

在文件 free_move_predictor.h32 行定义.

构造及析构函数说明

◆ FreeMovePredictor()

apollo::prediction::FreeMovePredictor::FreeMovePredictor ( )

Constructor

在文件 free_move_predictor.cc29 行定义.

◆ ~FreeMovePredictor()

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

Destructor

成员函数说明

◆ Predict()

bool apollo::prediction::FreeMovePredictor::Predict ( const ADCTrajectoryContainer adc_trajectory_container,
Obstacle obstacle,
ObstaclesContainer obstacles_container 
)
overridevirtual

Make prediction

参数
ADCtrajectory container
Obstaclepointer
Obstaclescontainer
返回
If predicted successfully

实现了 apollo::prediction::Predictor.

在文件 free_move_predictor.cc33 行定义.

35 {
36 Clear();
37
38 CHECK_NOTNULL(obstacle);
39 CHECK_GT(obstacle->history_size(), 0U);
40
41 obstacle->SetPredictorType(predictor_type_);
42
43 const Feature& feature = obstacle->latest_feature();
44
45 if (!feature.has_position() || !feature.has_velocity() ||
46 !feature.position().has_x() || !feature.position().has_y()) {
47 AERROR << "Obstacle [" << obstacle->id()
48 << " is missing position or velocity";
49 return false;
50 }
51
52 double prediction_total_time = FLAGS_prediction_trajectory_time_length;
53 if (obstacle->type() == PerceptionObstacle::PEDESTRIAN) {
54 prediction_total_time = FLAGS_prediction_trajectory_time_length;
55 }
56
57 if (feature.predicted_trajectory().empty()) {
58 std::vector<TrajectoryPoint> points;
59 Eigen::Vector2d position(feature.position().x(), feature.position().y());
60 Eigen::Vector2d velocity(feature.velocity().x(), feature.velocity().y());
61 Eigen::Vector2d acc(feature.acceleration().x(), feature.acceleration().y());
62 double theta = feature.velocity_heading();
63
64 DrawFreeMoveTrajectoryPoints(
65 position, velocity, acc, theta, 0.0, prediction_total_time,
66 FLAGS_prediction_trajectory_time_resolution, &points);
67
68 Trajectory trajectory = GenerateTrajectory(points);
69 obstacle->mutable_latest_feature()->add_predicted_trajectory()->CopyFrom(
70 trajectory);
71 SetEqualProbability(1.0, 0, obstacle);
72 } else {
73 for (int i = 0; i < feature.predicted_trajectory_size(); ++i) {
74 Trajectory* trajectory =
75 obstacle->mutable_latest_feature()->mutable_predicted_trajectory(i);
76 int traj_size = trajectory->trajectory_point_size();
77 if (traj_size == 0) {
78 AERROR << "Empty predicted trajectory found";
79 continue;
80 }
81 std::vector<TrajectoryPoint> points;
82 const TrajectoryPoint& last_point =
83 trajectory->trajectory_point(traj_size - 1);
84 double theta = last_point.path_point().theta();
85 Eigen::Vector2d position(last_point.path_point().x(),
86 last_point.path_point().y());
87 Eigen::Vector2d velocity(last_point.v() * std::cos(theta),
88 last_point.v() * std::sin(theta));
89 Eigen::Vector2d acc(last_point.a() * std::cos(theta),
90 last_point.a() * std::sin(theta));
91 double last_relative_time = last_point.relative_time();
92 DrawFreeMoveTrajectoryPoints(
93 position, velocity, acc, theta, last_relative_time,
94 prediction_total_time - last_relative_time,
95 FLAGS_prediction_trajectory_time_resolution, &points);
96 // The following for-loop starts from index 1 because the vector points
97 // includes the last point in the existing predicted trajectory
98 for (size_t i = 1; i < points.size(); ++i) {
99 trajectory->add_trajectory_point()->CopyFrom(points[i]);
100 }
101 }
102 }
103 return true;
104}
void SetEqualProbability(const double probability, const int start_index, Obstacle *obstacle_ptr)
Set equal probability to prediction trajectories
Definition predictor.cc:41
static Trajectory GenerateTrajectory(const std::vector< apollo::common::TrajectoryPoint > &points)
Generate trajectory from trajectory points
Definition predictor.cc:34
virtual void Clear()
Clear all trajectories
Definition predictor.cc:55
#define AERROR
Definition log.h:44

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