21#include "modules/prediction/proto/prediction_conf.pb.h"
38 CHECK_NOTNULL(obstacle);
45 if (!feature.has_position() || !feature.has_velocity() ||
47 AERROR <<
"Obstacle [" << obstacle->
id()
48 <<
" is missing position or velocity";
52 double prediction_total_time = FLAGS_prediction_trajectory_time_length;
54 prediction_total_time = FLAGS_prediction_trajectory_time_length;
58 std::vector<TrajectoryPoint> points;
64 DrawFreeMoveTrajectoryPoints(
65 position, velocity, acc, theta, 0.0, prediction_total_time,
66 FLAGS_prediction_trajectory_time_resolution, &points);
73 for (
int i = 0; i < feature.predicted_trajectory_size(); ++i) {
76 int traj_size = trajectory->trajectory_point_size();
78 AERROR <<
"Empty predicted trajectory found";
81 std::vector<TrajectoryPoint> points;
85 Eigen::Vector2d position(last_point.
path_point().
x(),
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));
92 DrawFreeMoveTrajectoryPoints(
93 position, velocity, acc, theta, last_relative_time,
94 prediction_total_time - last_relative_time,
95 FLAGS_prediction_trajectory_time_resolution, &points);
98 for (
size_t i = 1; i < points.size(); ++i) {
99 trajectory->add_trajectory_point()->CopyFrom(points[i]);
106void FreeMovePredictor::DrawFreeMoveTrajectoryPoints(
107 const Eigen::Vector2d& position,
const Eigen::Vector2d& velocity,
108 const Eigen::Vector2d& acc,
const double theta,
const double start_time,
109 const double total_time,
const double period,
110 std::vector<TrajectoryPoint>* points) {
111 Eigen::Matrix<double, 6, 1> state;
115 state(2, 0) = velocity(0);
116 state(3, 0) = velocity(1);
118 FLAGS_vehicle_max_linear_acc);
120 FLAGS_vehicle_max_linear_acc);
122 Eigen::Matrix<double, 6, 6> transition;
123 transition.setIdentity();
124 transition(0, 2) = period;
125 transition(0, 4) = 0.5 * period * period;
126 transition(1, 3) = period;
127 transition(1, 5) = 0.5 * period * period;
128 transition(2, 4) = period;
129 transition(3, 5) = period;
131 size_t num =
static_cast<size_t>(total_time / period);
133 &state, transition, theta, start_time, num, period, points);
135 for (
size_t i = 0; i < points->size(); ++i) {
137 position[0], position[1], &(points->operator[](i)));
FreeMovePredictor()
Constructor
bool Predict(const ADCTrajectoryContainer *adc_trajectory_container, Obstacle *obstacle, ObstaclesContainer *obstacles_container) override
Make prediction
Feature * mutable_latest_feature()
Get a pointer to the latest feature.
perception::PerceptionObstacle::Type type() const
Get the type of perception obstacle's type.
int id() const
Get the obstacle's ID.
size_t history_size() const
Get the number of historical features.
void SetPredictorType(const ObstacleConf::PredictorType &predictor_type)
const Feature & latest_feature() const
Get the latest feature.
void SetEqualProbability(const double probability, const int start_index, Obstacle *obstacle_ptr)
Set equal probability to prediction trajectories
static Trajectory GenerateTrajectory(const std::vector< apollo::common::TrajectoryPoint > &points)
Generate trajectory from trajectory points
ObstacleConf::PredictorType predictor_type_
virtual void Clear()
Clear all trajectories
Define lane sequence predictor
T Clamp(const T value, T bound1, T bound2)
Clamp a value between two bounds.
void GenerateFreeMoveTrajectoryPoints(Eigen::Matrix< double, 6, 1 > *state, const Eigen::Matrix< double, 6, 6 > &transition, double theta, const double start_time, const std::size_t num, const double period, std::vector< TrajectoryPoint > *points)
Generate a set of free move trajectory points
void TranslatePoint(const double translate_x, const double translate_y, TrajectoryPoint *point)
Translate a point.
optional double relative_time
optional PathPoint path_point
repeated Trajectory predicted_trajectory
optional apollo::common::Point3D velocity
optional double velocity_heading
optional apollo::common::Point3D position
optional apollo::common::Point3D acceleration
repeated apollo::common::TrajectoryPoint trajectory_point