44 const std::string &config_dir,
const std::string &name,
45 const std::shared_ptr<DependencyInjector> &injector) {
50 return Decider::LoadConfig<SpeedBoundsDeciderConfig>(&config_);
53Status SpeedBoundsDecider::Process(
62 auto time1 = std::chrono::system_clock::now();
67 if (!FLAGS_use_st_drivable_boundary) {
71 if (boundary_mapper.ComputeSTBoundary(path_decision).code() ==
72 ErrorCode::PLANNING_ERROR) {
73 const std::string msg =
"Mapping obstacle failed.";
75 return Status(ErrorCode::PLANNING_ERROR, msg);
77 auto time2 = std::chrono::system_clock::now();
78 std::chrono::duration<double> diff = time2 - time1;
79 ADEBUG <<
"Time for ST Boundary Mapping = " << diff.count() * 1000
82 std::vector<const STBoundary *> boundaries;
83 for (
auto *obstacle : path_decision->obstacles().Items()) {
84 const auto &
id = obstacle->Id();
85 const auto &st_boundary = obstacle->path_st_boundary();
86 if (!st_boundary.IsEmpty()) {
92 st_boundary.PrintDebug(
"_obs_st_bounds");
93 boundaries.push_back(&st_boundary);
97 const double min_s_on_st_boundaries = SetSpeedFallbackDistance(path_decision);
100 SpeedLimitDecider speed_limit_decider(config_, reference_line, path_data);
102 SpeedLimit speed_limit;
103 if (!speed_limit_decider
104 .GetSpeedLimits(path_decision->
obstacles(), &speed_limit)
106 const std::string msg =
"Getting speed limits failed!";
108 return Status(ErrorCode::PLANNING_ERROR, msg);
115 const double total_time_by_conf = config_.
total_time();
123 STGraphDebug *st_graph_debug = debug->mutable_planning_data()->add_st_graph();
125 st_graph_data->LoadData(boundaries, min_s_on_st_boundaries, init_point,
127 path_data_length, total_time_by_conf, st_graph_debug);
130 RecordSTGraphDebug(*st_graph_data, st_graph_debug);
135double SpeedBoundsDecider::SetSpeedFallbackDistance(
136 PathDecision *
const path_decision) {
138 static constexpr double kEpsilon = 1.0e-6;
139 double min_s_non_reverse = std::numeric_limits<double>::infinity();
140 double min_s_reverse = std::numeric_limits<double>::infinity();
142 for (
auto *obstacle : path_decision->obstacles().Items()) {
143 const auto &st_boundary = obstacle->path_st_boundary();
145 if (st_boundary.IsEmpty()) {
149 const auto left_bottom_point_s = st_boundary.bottom_left_point().s();
150 const auto right_bottom_point_s = st_boundary.bottom_right_point().s();
151 const auto lowest_s = std::min(left_bottom_point_s, right_bottom_point_s);
153 if (left_bottom_point_s - right_bottom_point_s > kEpsilon) {
154 if (min_s_reverse > lowest_s) {
155 min_s_reverse = lowest_s;
157 }
else if (min_s_non_reverse > lowest_s) {
158 min_s_non_reverse = lowest_s;
162 min_s_reverse = std::max(min_s_reverse, 0.0);
163 min_s_non_reverse = std::max(min_s_non_reverse, 0.0);
165 return min_s_non_reverse > min_s_reverse ? 0.0 : min_s_non_reverse;
168void SpeedBoundsDecider::RecordSTGraphDebug(
169 const StGraphData &st_graph_data, STGraphDebug *st_graph_debug)
const {
170 if (!FLAGS_enable_record_debug || !st_graph_debug) {
171 ADEBUG <<
"Skip record debug info";
175 for (
const auto &boundary : st_graph_data.st_boundaries()) {
176 auto boundary_debug = st_graph_debug->add_boundary();
177 boundary_debug->set_name(boundary->id());
178 switch (boundary->boundary_type()) {
183 boundary_debug->set_type(
190 boundary_debug->set_type(
197 boundary_debug->set_type(
202 for (
const auto &point : boundary->points()) {
203 auto point_debug = boundary_debug->add_point();
204 point_debug->set_t(point.x());
205 point_debug->set_s(point.y());
209 for (
const auto &point : st_graph_data.speed_limit().speed_limit_points()) {
210 common::SpeedPoint *speed_point = st_graph_debug->add_speed_limit();
211 speed_point->set_s(point.first);
212 speed_point->set_v(point.second);
A general class to denote the return status of an API call.
static Status OK()
generate a success status.
Frame holds all data for one planning cycle.
const common::TrajectoryPoint & PlanningStartPoint() const
void SetBlockingObstacle(bool blocking)
const DiscretizedPath & discretized_path() const
PathDecision represents all obstacle decisions on one path.
const Obstacle * Find(const std::string &object_id) const
const IndexedList< std::string, Obstacle > & obstacles() const
ReferenceLineInfo holds all data for one reference line.
PathDecision * path_decision()
StGraphData * mutable_st_graph_data()
double GetCruiseSpeed() const
const ReferenceLine & reference_line() const
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
std::shared_ptr< DependencyInjector > injector_
ReferenceLineInfo * reference_line_info_
virtual bool Init(const std::string &config_dir, const std::string &name, const std::shared_ptr< DependencyInjector > &injector)
Planning module main class.
: data with map info and obstacle info
optional double total_time
@ ST_BOUNDARY_TYPE_OVERTAKE
@ ST_BOUNDARY_TYPE_UNKNOWN
@ ST_BOUNDARY_TYPE_FOLLOW
@ ST_BOUNDARY_TYPE_KEEP_CLEAR