44 const std::shared_ptr<DependencyInjector> &injector) {
49 return Task::LoadConfig<ReverseSpeedConfig>(&config_);
55 std::vector<const STBoundary *> boundaries;
57 const auto &path_data = reference_line_info->
path_data();
58 GetSTboundaries(path_data.discretized_path(), frame, &boundaries);
64 auto *st_graph_debug = debug->mutable_planning_data()->add_st_graph();
65 st_graph_data->
LoadData(boundaries, 0.0, init_point, speed_limit,
67 path_data.discretized_path().Length(),
72void ReverseSpeed::GetSTboundaries(
74 std::vector<const STBoundary *> *boundaries) {
75 CHECK_NOTNULL(boundaries);
77 static constexpr double kEpsilon = 1e-2;
80 for (
auto *obstacle : obstacles_by_frame->Items()) {
82 std::vector<STPoint> lower_points;
83 std::vector<STPoint> upper_points;
84 for (
const auto &curr_point_on_path : path_data) {
85 if (CheckOverlap(curr_point_on_path, obstacle->PerceptionPolygon(),
88 const double forward_distance =
89 obstacle->PerceptionBoundingBox().length();
91 std::fmax(0.0, curr_point_on_path.s() + backward_distance);
92 double high_s = std::fmax(low_s + kEpsilon,
93 std::fmin(path_data.
Length(),
94 curr_point_on_path.s() + forward_distance));
98 lower_points.emplace_back(low_s, 0.0);
99 lower_points.emplace_back(low_s, config_.
total_time());
100 upper_points.emplace_back(high_s, 0.0);
101 upper_points.emplace_back(high_s, config_.
total_time());
107 auto *origin_obstacle = frame->
Find(obstacle->Id());
109 boundaries->push_back(&origin_obstacle->path_st_boundary());
116bool ReverseSpeed::CheckOverlap(
const PathPoint &path_point,
117 const Polygon2d &obs_polygon,
118 const double l_buffer) {
126 ego_center_map_frame.SelfRotate(path_point.theta());
127 ego_center_map_frame.set_x(ego_center_map_frame.x() + path_point.x());
128 ego_center_map_frame.set_y(ego_center_map_frame.y() + path_point.y());
131 Box2d adc_box(ego_center_map_frame, path_point.theta(),
132 vehicle_param_.
length(), vehicle_param_.
width() + l_buffer * 2);
135 Polygon2d adc_polygon(adc_box);
136 return obs_polygon.HasOverlap(adc_polygon);
A general class to denote the return status of an API call.
static Status OK()
generate a success status.
Rectangular (undirected) bounding box in 2-D.
The class of polygon in 2-D.
Implements a class of 2-dimensional vectors.
Frame holds all data for one planning cycle.
ThreadSafeIndexedObstacles * GetObstacleList()
Obstacle * Find(const std::string &id)
const common::TrajectoryPoint & PlanningStartPoint() const
void set_path_st_boundary(const STBoundary &boundary)
ReferenceLineInfo holds all data for one reference line.
StGraphData * mutable_st_graph_data()
const PathData & path_data() const
planning_internal::Debug * mutable_debug()
bool Init(const std::string &config_dir, const std::string &name, const std::shared_ptr< DependencyInjector > &injector) override
apollo::common::Status Execute(Frame *frame, ReferenceLineInfo *reference_line_info) override
static STBoundary CreateInstance(const std::vector< STPoint > &lower_points, const std::vector< STPoint > &upper_points)
Wrapper of the constructor (old).
void SetCharacteristicLength(const double characteristic_length)
STBoundary ExpandByS(const double s) const
void SetBoundaryType(const BoundaryType &boundary_type)
void AppendSpeedLimit(const double s, const double v)
void LoadData(const std::vector< const STBoundary * > &st_boundaries, const double min_s_on_st_boundaries, const apollo::common::TrajectoryPoint &init_point, const SpeedLimit &speed_limit, const double cruise_speed, const double path_data_length, const double total_time_by_conf, planning_internal::STGraphDebug *st_graph_debug)
ReferenceLineInfo * reference_line_info_
virtual bool Init(const std::string &config_dir, const std::string &name, const std::shared_ptr< DependencyInjector > &injector)
virtual common::Status Execute(Frame *frame, ReferenceLineInfo *reference_line_info)
Planning module main class.
optional double left_edge_to_center
optional double back_edge_to_center
optional double front_edge_to_center
optional double right_edge_to_center
optional double speed_limit
optional double total_time