38 const std::string& name,
39 const std::shared_ptr<DependencyInjector>& injector) {
44 return Task::LoadConfig<LaneFollowPathConfig>(&config_);
51 ADEBUG <<
"Skip this time path empty:"
56 std::vector<PathBoundary> candidate_path_boundaries;
57 std::vector<PathData> candidate_path_data;
60 if (!DecidePathBounds(&candidate_path_boundaries)) {
61 AERROR <<
"Decide path bound failed";
64 if (!OptimizePath(candidate_path_boundaries, &candidate_path_data)) {
65 AERROR <<
"Optmize path failed";
68 if (!AssessPath(&candidate_path_data,
70 AERROR <<
"Path assessment failed";
76bool LaneFollowPath::DecidePathBounds(std::vector<PathBoundary>* boundary) {
77 boundary->emplace_back();
78 auto& path_bound = boundary->back();
79 std::string blocking_obstacle_id =
"";
80 std::string lane_type =
"";
81 double path_narrowest_width = 0;
85 const std::string msg =
"Failed to initialize path boundaries.";
89 std::string borrow_lane_type;
94 .is_in_path_lane_borrow_scenario();
98 AERROR <<
"Failed to decide a rough boundary based on self lane.";
101 if (is_include_adc) {
106 PrintCurves print_curve;
108 for (
const auto* obs : indexed_obstacles.Items()) {
109 const auto& sl_bound = obs->PerceptionSLBoundary();
110 for (
int i = 0; i < sl_bound.boundary_point_size(); i++) {
111 std::string name = obs->Id() +
"_obs_sl_boundary";
112 print_curve.AddPoint(name, sl_bound.boundary_point(i).s(),
113 sl_bound.boundary_point(i).l());
116 print_curve.PrintToLog();
118 path_bound.set_label(absl::StrCat(
"regular/",
"self"));
127 &blocking_obstacle_id, &path_narrowest_width)) {
128 const std::string msg =
129 "Failed to decide fine tune the boundaries after "
130 "taking into consideration all static obstacles.";
136 while (!blocking_obstacle_id.empty() &&
137 path_bound.size() < temp_path_bound.size() &&
138 counter < FLAGS_num_extra_tail_bound_point) {
139 path_bound.push_back(temp_path_bound[path_bound.size()]);
144 auto* lane_follow_status =
injector_->planning_context()
145 ->mutable_planning_status()
146 ->mutable_lane_follow();
147 if (!blocking_obstacle_id.empty()) {
149 lane_follow_status->set_block_obstacle_id(blocking_obstacle_id);
150 if (lane_follow_status->lane_follow_block()) {
151 lane_follow_status->set_block_duration(
152 lane_follow_status->block_duration() + current_time -
153 lane_follow_status->last_block_timestamp());
155 lane_follow_status->set_block_duration(0);
156 lane_follow_status->set_lane_follow_block(
true);
158 lane_follow_status->set_last_block_timestamp(current_time);
160 if (lane_follow_status->lane_follow_block()) {
161 lane_follow_status->set_block_duration(0);
162 lane_follow_status->set_lane_follow_block(
false);
163 lane_follow_status->set_last_block_timestamp(0);
167 ADEBUG <<
"Completed generating path boundaries.";
170 AINFO <<
"not in self lane maybe lane borrow or out of road. init l : "
172 << path_bound[0].l_lower.l <<
"," << path_bound[0].l_upper.l <<
" ]";
181 path_bound.set_blocking_obstacle_id(blocking_obstacle_id);
186bool LaneFollowPath::OptimizePath(
187 const std::vector<PathBoundary>& path_boundaries,
188 std::vector<PathData>* candidate_path_data) {
191 std::array<double, 3> end_state = {0.0, 0.0, 0.0};
192 for (
const auto& path_boundary : path_boundaries) {
193 size_t path_boundary_size = path_boundary.boundary().size();
194 if (path_boundary_size <= 1U) {
195 AERROR <<
"Get invalid path boundary with size: " << path_boundary_size;
198 std::vector<double> opt_l, opt_dl, opt_ddl;
199 std::vector<std::pair<double, double>> ddl_bounds;
202 PrintCurves print_debug;
203 for (
size_t i = 0; i < path_boundary_size; ++i) {
204 double s =
static_cast<double>(i) * path_boundary.delta_s() +
205 path_boundary.start_s();
206 double kappa = reference_line.GetNearestReferencePoint(s).kappa();
207 print_debug.AddPoint(
"ref_kappa", s, kappa);
209 print_debug.PrintToLog();
212 std::vector<double> ref_l(path_boundary_size, 0);
213 std::vector<double> weight_ref_l(path_boundary_size, 0);
216 path_boundary, config.path_reference_l_weight(), &ref_l, &weight_ref_l);
219 ddl_bounds, jerk_bound, config, &opt_l, &opt_dl, &opt_ddl);
222 opt_l, opt_dl, opt_ddl, path_boundary.delta_s(),
223 path_boundary.start_s());
225 path_data.SetReferenceLine(&reference_line);
226 path_data.SetFrenetPath(std::move(frenet_frame_path));
227 if (FLAGS_use_front_axe_center_in_path_planning) {
228 auto discretized_path = DiscretizedPath(
231 path_data.SetDiscretizedPath(discretized_path);
233 path_data.set_path_label(path_boundary.label());
234 path_data.set_blocking_obstacle_id(path_boundary.blocking_obstacle_id());
235 candidate_path_data->push_back(std::move(path_data));
236 PrintCurves print_path_kappa;
237 for (
const auto& p : candidate_path_data->back().discretized_path()) {
238 print_path_kappa.AddPoint(path_boundary.label() +
"_path_kappa",
241 print_path_kappa.PrintToLog();
244 if (candidate_path_data->empty()) {
250bool LaneFollowPath::AssessPath(std::vector<PathData>* candidate_path_data,
251 PathData* final_path) {
252 PathData& curr_path_data = candidate_path_data->back();
257 AINFO <<
"Lane follow path is invalid";
261 std::vector<PathPointDecision> path_decision;
264 curr_path_data.SetPathPointDecisionGuide(std::move(path_decision));
266 if (curr_path_data.Empty()) {
267 AINFO <<
"Lane follow path is empty after trimed";
270 *final_path = curr_path_data;
271 AINFO << final_path->path_label() << final_path->blocking_obstacle_id();
274 curr_path_data.blocking_obstacle_id());
A general class to denote the return status of an API call.
static Status OK()
generate a success status.
@Brief This is a helper class that can load vehicle configurations.
static double NowInSeconds()
gets the current time in second.
Frame holds all data for one planning cycle.
bool Init(const std::string &config_dir, const std::string &name, const std::shared_ptr< DependencyInjector > &injector) override
static void InitPathPointDecision(const PathData &path_data, const PathData::PathPointType type, std::vector< PathPointDecision > *const path_point_decision)
Init path_point_decision as type
static bool IsValidRegularPath(const ReferenceLineInfo &reference_line_info, const PathData &path_data)
Check if the generated path is valid
static bool GetBoundaryFromSelfLane(const ReferenceLineInfo &reference_line_info, const SLState &init_sl_state, PathBoundary *const path_bound)
generate path bound by self lane and adc position
static bool ExtendBoundaryByADC(const ReferenceLineInfo &reference_line_info, const SLState &init_sl_state, const double extend_buffer, PathBoundary *const path_bound)
extend boundary to include adc
static bool GetBoundaryFromStaticObstacles(const ReferenceLineInfo &reference_line_info, std::vector< SLPolygon > *const sl_polygons, const SLState &init_sl_state, PathBoundary *const path_boundaries, std::string *const blocking_obstacle_id, double *const narrowest_width)
Refine the boundary based on static obstacles.
static void GetSLPolygons(const ReferenceLineInfo &reference_line_info, std::vector< SLPolygon > *polygons, const SLState &init_sl_state)
static bool InitPathBoundary(const ReferenceLineInfo &reference_line_info, PathBoundary *const path_bound, SLState init_sl_state)
Starting from ADC's current position, increment until the path length, and set lateral bounds to be i...
const IndexedList< std::string, Obstacle > & obstacles() const
void RecordDebugInfo(const PathBound &path_boundaries, const std::string &debug_name, ReferenceLineInfo *const reference_line_info)
add path_boundary debug info for PnC monitor
std::vector< SLPolygon > obs_sl_polygons_
void GetStartPointSLState()
calculate init sl state by planning start point, result will store in init_sl_state_
static std::vector< common::PathPoint > ConvertPathPointRefFromFrontAxeToRearAxe(const PathData &path_data)
static void CalculateAccBound(const PathBoundary &path_boundary, const ReferenceLine &reference_line, std::vector< std::pair< double, double > > *ddl_bounds)
calculate ddl bound by referenceline kappa and adc lat accleration
static FrenetFramePath ToPiecewiseJerkPath(const std::vector< double > &x, const std::vector< double > &dx, const std::vector< double > &ddx, const double delta_s, const double start_s)
Data format tramform from raw data to FrenetFramePath
static double EstimateJerkBoundary(const double vehicle_speed)
Calculation of jerk boundary based on vehicle kinematics model.
static bool OptimizePath(const SLState &init_state, const std::array< double, 3 > &end_state, std::vector< double > l_ref, std::vector< double > l_ref_weight, const PathBoundary &path_boundary, const std::vector< std::pair< double, double > > &ddl_bounds, double dddl_bound, const PiecewiseJerkPathConfig &config, std::vector< double > *x, std::vector< double > *dx, std::vector< double > *ddx)
Piecewise jerk path optimizer.
static void UpdatePathRefWithBound(const PathBoundary &path_boundary, double weight, std::vector< double > *ref_l, std::vector< double > *weight_ref_l)
If ref_l is below or above path boundary, will update its values and weights
ReferenceLineInfo holds all data for one reference line.
void SetBlockingObstacle(const std::string &blocking_obstacle_id)
bool path_reusable() const
PathDecision * path_decision()
std::vector< SLPolygon > * mutable_obs_sl_polygons()
const ReferenceLine & reference_line() const
const PathData & path_data() const
std::vector< PathData > * MutableCandidatePathData()
PathData * mutable_path_data()
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.
std::vector< PathBoundPoint > PathBound
optional PiecewiseJerkPathConfig path_optimizer_config
optional bool is_extend_lane_bounds_to_include_adc
optional double extend_buffer