41 CHECK_NOTNULL(obstacle);
48 if (!feature.has_lane() || !feature.
lane().has_lane_graph()) {
49 AERROR <<
"Obstacle [" << obstacle->
id() <<
"] has no lane graph.";
53 std::string lane_id =
"";
54 if (feature.
lane().has_lane_feature()) {
55 lane_id = feature.
lane().lane_feature().lane_id();
57 int num_lane_sequence = feature.
lane().lane_graph().lane_sequence_size();
59 for (
int i = 0; i < num_lane_sequence; ++i) {
62 AERROR <<
"Empty lane segments.";
66 ADEBUG <<
"Obstacle [" << obstacle->
id()
67 <<
"] will draw a lane sequence trajectory [" <<
ToString(sequence)
68 <<
"] with probability [" << sequence.
probability() <<
"].";
70 std::vector<TrajectoryPoint> points;
72 *obstacle, sequence, FLAGS_prediction_trajectory_time_length,
73 FLAGS_prediction_trajectory_time_resolution, &points);
89 const double time_length,
const double time_resolution,
90 std::vector<TrajectoryPoint>* points) {
92 if (!feature.has_position() || !feature.has_velocity() ||
94 AERROR <<
"Obstacle [" << obstacle.
id()
95 <<
" is missing position or velocity";
100 double approach_rate = FLAGS_go_approach_rate;
101 if (probability < FLAGS_lane_sequence_threshold_cruise) {
106 double speed = feature.
speed();
108 int lane_segment_index = 0;
109 std::string lane_id =
115 AERROR <<
"Failed in getting lane s and lane l";
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;
125 AERROR <<
"Unable to get smooth point from lane [" << lane_id
126 <<
"] with s [" << lane_s <<
"] and l [" << lane_l <<
"]";
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));
142 lane_s += speed * time_resolution;
145 lane_segment_index + 1 < lane_sequence.lane_segment_size()) {
146 lane_segment_index += 1;
151 lane_l *= approach_rate;
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 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.
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