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

#include <single_lane_predictor.h>

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

Public 成员函数

 SingleLanePredictor ()
 Constructor
 
virtual ~SingleLanePredictor ()=default
 Destructor
 
bool Predict (const ADCTrajectoryContainer *adc_trajectory_container, Obstacle *obstacle, ObstaclesContainer *obstacles_container) override
 Make prediction
 
- Public 成员函数 继承自 apollo::prediction::SequencePredictor
 SequencePredictor ()=default
 Constructor
 
virtual ~SequencePredictor ()=default
 Destructor
 
 FRIEND_TEST (SequencePredictorTest, General)
 
- Public 成员函数 继承自 apollo::prediction::Predictor
 Predictor ()=default
 Constructor
 
virtual ~Predictor ()=default
 Destructor
 
int NumOfTrajectories (const Obstacle &obstacle)
 Get trajectory size
 
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 GenerateTrajectoryPoints (const Obstacle &obstacle, const LaneSequence &lane_sequence, const double total_time, const double period, std::vector< apollo::common::TrajectoryPoint > *points)
 Draw lane sequence trajectory points
 
- Protected 成员函数 继承自 apollo::prediction::SequencePredictor
bool GetLongitudinalPolynomial (const Obstacle &obstacle, const LaneSequence &lane_sequence, const std::pair< double, double > &lon_end_state, std::array< double, 5 > *coefficients)
 
bool GetLateralPolynomial (const Obstacle &obstacle, const LaneSequence &lane_sequence, const double time_to_end_state, std::array< double, 4 > *coefficients)
 
void FilterLaneSequences (const Feature &feature, const std::string &lane_id, const Obstacle *ego_vehicle_ptr, const ADCTrajectoryContainer *adc_trajectory_container, std::vector< bool > *enable_lane_sequence)
 Filter lane sequences
 
LaneChangeType GetLaneChangeType (const std::string &lane_id, const LaneSequence &lane_sequence)
 Get lane change type
 
double GetLaneChangeDistanceWithADC (const LaneSequence &lane_sequence, const Obstacle *ego_vehicle_ptr, const ADCTrajectoryContainer *adc_trajectory_container)
 Get lane change distance with ADC
 
void DrawConstantAccelerationTrajectory (const Obstacle &obstacle, const LaneSequence &lane_sequence, const double total_time, const double period, const double acceleration, std::vector< apollo::common::TrajectoryPoint > *points)
 Draw constant acceleration trajectory points
 
double GetLaneSequenceCurvatureByS (const LaneSequence &lane_sequence, const double s)
 Get lane sequence curvature by s
 
void Clear ()
 Clear private members
 
std::string ToString (const LaneSequence &sequence)
 Convert a lane sequence to string
 
- 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
 

额外继承的成员函数

- Public 类型 继承自 apollo::prediction::SequencePredictor
enum class  LaneChangeType {
  LEFT , RIGHT , STRAIGHT , ONTO_LANE ,
  INVALID
}
 
- 静态 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_
 

详细描述

在文件 single_lane_predictor.h29 行定义.

构造及析构函数说明

◆ SingleLanePredictor()

apollo::prediction::SingleLanePredictor::SingleLanePredictor ( )

Constructor

在文件 single_lane_predictor.cc32 行定义.

◆ ~SingleLanePredictor()

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

Destructor

成员函数说明

◆ GenerateTrajectoryPoints()

void apollo::prediction::SingleLanePredictor::GenerateTrajectoryPoints ( const Obstacle obstacle,
const LaneSequence lane_sequence,
const double  total_time,
const double  period,
std::vector< apollo::common::TrajectoryPoint > *  points 
)
protected

Draw lane sequence trajectory points

参数
Obstacle
Lanesequence
Totalprediction time
Predictionperiod
Avector of generated trajectory points

在文件 single_lane_predictor.cc87 行定义.

90 {
91 const Feature& feature = obstacle.latest_feature();
92 if (!feature.has_position() || !feature.has_velocity() ||
93 !feature.position().has_x() || !feature.position().has_y()) {
94 AERROR << "Obstacle [" << obstacle.id()
95 << " is missing position or velocity";
96 return;
97 }
98
99 double probability = lane_sequence.probability();
100 double approach_rate = FLAGS_go_approach_rate;
101 if (probability < FLAGS_lane_sequence_threshold_cruise) {
102 approach_rate = 1.0;
103 }
104
105 Eigen::Vector2d position(feature.position().x(), feature.position().y());
106 double speed = feature.speed();
107
108 int lane_segment_index = 0;
109 std::string lane_id =
110 lane_sequence.lane_segment(lane_segment_index).lane_id();
111 std::shared_ptr<const LaneInfo> lane_info = PredictionMap::LaneById(lane_id);
112 double lane_s = 0.0;
113 double lane_l = 0.0;
114 if (!PredictionMap::GetProjection(position, lane_info, &lane_s, &lane_l)) {
115 AERROR << "Failed in getting lane s and lane l";
116 return;
117 }
118 size_t num_of_points = static_cast<size_t>(time_length / time_resolution);
119 for (size_t i = 0; i < num_of_points; ++i) {
120 double relative_time = static_cast<double>(i) * time_resolution;
121 Eigen::Vector2d point;
122 double theta = M_PI;
123 if (!PredictionMap::SmoothPointFromLane(lane_id, lane_s, lane_l, &point,
124 &theta)) {
125 AERROR << "Unable to get smooth point from lane [" << lane_id
126 << "] with s [" << lane_s << "] and l [" << lane_l << "]";
127 break;
128 }
129 TrajectoryPoint trajectory_point;
130 PathPoint path_point;
131 path_point.set_x(point.x());
132 path_point.set_y(point.y());
133 path_point.set_z(0.0);
134 path_point.set_theta(theta);
135 path_point.set_lane_id(lane_id);
136 trajectory_point.mutable_path_point()->CopyFrom(path_point);
137 trajectory_point.set_v(speed);
138 trajectory_point.set_a(0.0);
139 trajectory_point.set_relative_time(relative_time);
140 points->emplace_back(std::move(trajectory_point));
141
142 lane_s += speed * time_resolution;
143
144 while (lane_s > PredictionMap::LaneById(lane_id)->total_length() &&
145 lane_segment_index + 1 < lane_sequence.lane_segment_size()) {
146 lane_segment_index += 1;
147 lane_s = lane_s - PredictionMap::LaneById(lane_id)->total_length();
148 lane_id = lane_sequence.lane_segment(lane_segment_index).lane_id();
149 }
150
151 lane_l *= approach_rate;
152 }
153}
static bool SmoothPointFromLane(const std::string &id, const double s, const double l, Eigen::Vector2d *point, double *heading)
Get the smooth point on a lane by a longitudinal coordinate.
static std::shared_ptr< const hdmap::LaneInfo > LaneById(const std::string &id)
Get a shared pointer to a lane by lane ID.
static bool GetProjection(const Eigen::Vector2d &position, const std::shared_ptr< const hdmap::LaneInfo > lane_info, double *s, double *l)
Get the frenet coordinates (s, l) on a lane by a position.
#define AERROR
Definition log.h:44

◆ Predict()

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

Make prediction

参数
ADCtrajectory container
Obstaclepointer
Obstaclescontainer
返回
If predicted successfully

重载 apollo::prediction::SequencePredictor .

在文件 single_lane_predictor.cc36 行定义.

38 {
39 Clear();
40
41 CHECK_NOTNULL(obstacle);
42 CHECK_GT(obstacle->history_size(), 0U);
43
44 obstacle->SetPredictorType(predictor_type_);
45
46 const Feature& feature = obstacle->latest_feature();
47
48 if (!feature.has_lane() || !feature.lane().has_lane_graph()) {
49 AERROR << "Obstacle [" << obstacle->id() << "] has no lane graph.";
50 return false;
51 }
52
53 std::string lane_id = "";
54 if (feature.lane().has_lane_feature()) {
55 lane_id = feature.lane().lane_feature().lane_id();
56 }
57 int num_lane_sequence = feature.lane().lane_graph().lane_sequence_size();
58
59 for (int i = 0; i < num_lane_sequence; ++i) {
60 const LaneSequence& sequence = feature.lane().lane_graph().lane_sequence(i);
61 if (sequence.lane_segment().empty()) {
62 AERROR << "Empty lane segments.";
63 continue;
64 }
65
66 ADEBUG << "Obstacle [" << obstacle->id()
67 << "] will draw a lane sequence trajectory [" << ToString(sequence)
68 << "] with probability [" << sequence.probability() << "].";
69
70 std::vector<TrajectoryPoint> points;
72 *obstacle, sequence, FLAGS_prediction_trajectory_time_length,
73 FLAGS_prediction_trajectory_time_resolution, &points);
74
75 if (points.empty()) {
76 continue;
77 }
78
79 Trajectory trajectory = GenerateTrajectory(points);
80 trajectory.set_probability(sequence.probability());
81 obstacle->mutable_latest_feature()->add_predicted_trajectory()->CopyFrom(
82 trajectory);
83 }
84 return true;
85}
static Trajectory GenerateTrajectory(const std::vector< apollo::common::TrajectoryPoint > &points)
Generate trajectory from trajectory points
Definition predictor.cc:34
std::string ToString(const LaneSequence &sequence)
Convert a lane sequence to string
void GenerateTrajectoryPoints(const Obstacle &obstacle, const LaneSequence &lane_sequence, const double total_time, const double period, std::vector< apollo::common::TrajectoryPoint > *points)
Draw lane sequence trajectory points
#define ADEBUG
Definition log.h:41

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