51constexpr double kStraightForwardLineCost = 10.0;
56 if (!FLAGS_enable_record_debug) {
57 ADEBUG <<
"Skip record debug info";
62 const auto path_decision = reference_line_info->
path_decision();
63 for (
const auto obstacle : path_decision->obstacles().Items()) {
64 auto obstacle_debug = ptr_debug->mutable_planning_data()->add_obstacle();
65 obstacle_debug->set_id(obstacle->Id());
66 obstacle_debug->mutable_sl_boundary()->CopyFrom(
67 obstacle->PerceptionSLBoundary());
68 const auto& decider_tags = obstacle->decider_tags();
69 const auto& decisions = obstacle->decisions();
70 if (decider_tags.size() != decisions.size()) {
71 AERROR <<
"decider_tags size: " << decider_tags.size()
72 <<
" different from decisions size:" << decisions.size();
74 for (
size_t i = 0; i < decider_tags.size(); ++i) {
75 auto decision_tag = obstacle_debug->add_decision_tag();
76 decision_tag->set_decider_tag(decider_tags[i]);
77 decision_tag->mutable_decision()->CopyFrom(decisions[i]);
88 bool has_drivable_reference_line =
false;
90 ADEBUG <<
"Number of reference lines:\t"
93 unsigned int count = 0;
100 ADEBUG <<
"No: [" << count <<
"] Reference Line.";
101 ADEBUG <<
"IsChangeLanePath: " << reference_line_info.IsChangeLanePath();
103 if (has_drivable_reference_line) {
104 reference_line_info.SetDrivable(
false);
112 if (!reference_line_info.IsChangeLanePath()) {
113 ADEBUG <<
"reference line is NOT lane change ref.";
114 has_drivable_reference_line =
true;
117 if (reference_line_info.Cost() < kStraightForwardLineCost) {
120 has_drivable_reference_line =
true;
121 reference_line_info.SetDrivable(
true);
123 reference_line_info.SetDrivable(
false);
124 ADEBUG <<
"\tlane change failed";
127 reference_line_info.SetDrivable(
false);
131 return has_drivable_reference_line
140 reference_line_info->
AddCost(kStraightForwardLineCost);
142 ADEBUG <<
"planning start point:" << planning_start_point.DebugString();
143 ADEBUG <<
"Current reference_line_info is IsChangeLanePath: "
149 const auto start_planning_perf_timestamp =
150 std::chrono::duration<double>(
151 std::chrono::system_clock::now().time_since_epoch())
154 ret.
SetTaskStatus(task->Execute(frame, reference_line_info));
157 const double time_diff_ms = (end_timestamp - start_timestamp) * 1000;
158 ADEBUG <<
"after task[" << task->Name()
160 ADEBUG << task->Name() <<
" time spend: " << time_diff_ms <<
" ms.";
163 const auto end_planning_perf_timestamp =
164 std::chrono::duration<double>(
165 std::chrono::system_clock::now().time_since_epoch())
167 const auto plnning_perf_ms =
168 (end_planning_perf_timestamp - start_planning_perf_timestamp) * 1000;
169 AINFO <<
"Planning Perf: task name [" << task->Name() <<
"], "
170 << plnning_perf_ms <<
" ms.";
173 AERROR <<
"Failed to run tasks[" << task->Name()
197 planning_start_point.
path_point().
s(), &trajectory)) {
198 const std::string msg =
"Fail to aggregate planning trajectory.";
204 double dest_stop_s = -1.0;
205 for (
const auto* obstacle :
207 if (obstacle->LongitudinalDecision().has_stop() &&
208 obstacle->LongitudinalDecision().stop().reason_code() ==
209 STOP_REASON_DESTINATION) {
212 dest_stop_s = dest_sl.
s();
216 for (
const auto* obstacle :
218 if (obstacle->IsVirtual()) {
221 if (!obstacle->IsStatic()) {
224 if (obstacle->LongitudinalDecision().has_stop()) {
225 bool add_stop_obstacle_cost =
false;
226 if (dest_stop_s < 0.0) {
227 add_stop_obstacle_cost =
true;
231 if (stop_sl.
s() < dest_stop_s &&
234 add_stop_obstacle_cost =
true;
237 if (add_stop_obstacle_cost) {
238 static constexpr double kReferenceLineStaticObsCost = 1e3;
239 reference_line_info->
AddCost(kReferenceLineStaticObsCost);
244 if (FLAGS_enable_trajectory_check) {
247 const std::string msg =
"Current planning trajectory is not valid.";
262 reference_line.
XYToSL(stop_decision.stop_point(), &sl_point);
A general class to denote the return status of an API call.
const std::string & error_message() const
returns the error message of the status, empty if the status is OK.
a singleton clock that can be used to get the current timestamp.
static double NowInSeconds()
gets the current time in second.
static Result ValidTrajectory(const DiscretizedTrajectory &trajectory)
Frame holds all data for one planning cycle.
const std::list< ReferenceLineInfo > & reference_line_info() const
std::list< ReferenceLineInfo > * mutable_reference_line_info()
const std::vector< const T * > & Items() const
List all the items in the container.
StageResult PlanOnReferenceLine(const common::TrajectoryPoint &planning_start_point, Frame *frame, ReferenceLineInfo *reference_line_info)
StageResult Process(const common::TrajectoryPoint &planning_init_point, Frame *frame) override
Each stage does its business logic inside Process function.
void RecordObstacleDebugInfo(ReferenceLineInfo *reference_line_info)
common::SLPoint GetStopSL(const ObjectStop &stop_decision, const ReferenceLine &reference_line) const
const IndexedList< std::string, Obstacle > & obstacles() const
ReferenceLineInfo holds all data for one reference line.
PathDecision * path_decision()
void SetTrajectory(const DiscretizedTrajectory &trajectory)
void AddCost(double cost)
void set_trajectory_type(const ADCTrajectory::TrajectoryType trajectory_type)
void SetDrivable(bool drivable)
Set if the vehicle can drive following this reference line A planner need to set this value to true i...
bool CombinePathAndSpeedProfile(const double relative_time, const double start_s, DiscretizedTrajectory *discretized_trajectory)
const ReferenceLine & reference_line() const
planning_internal::Debug * mutable_debug()
const SLBoundary & AdcSlBoundary() const
bool IsChangeLanePath() const
Check if the current reference line is a change lane reference line, i.e., ADC's current position is ...
std::string PathSpeedDebugString() const
bool XYToSL(const common::math::Vec2d &xy_point, common::SLPoint *const sl_point, double warm_start_s=-1.0) const
Transvert Cartesian coordinates to Frenet.
const StageResult & SetStageStatus(const StageStatusType &stage_status)
Set the stage status.
bool HasError() const
Check if StageResult contains error.
const StageResult & SetTaskStatus(const common::Status &status)
Set the task execution result.
const common::Status & GetTaskStatus() const
Get the task execution result.
void RecordDebugInfo(ReferenceLineInfo *reference_line_info, const std::string &name, const double time_diff_ms)
std::shared_ptr< Task > fallback_task_
std::vector< std::shared_ptr< Task > > task_list_
Planning module main class.
Math-related util functions.
Some string util functions.
optional double relative_time
optional PathPoint path_point