Apollo 11.0
自动驾驶开放平台
speed_decider.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
22
23#include <algorithm>
24#include <memory>
25
26#include "modules/common_msgs/perception_msgs/perception_obstacle.pb.h"
27#include "modules/common_msgs/planning_msgs/decision.pb.h"
28
29#include "cyber/common/log.h"
30#include "cyber/time/clock.h"
36
37namespace apollo {
38namespace planning {
39
46
47bool SpeedDecider::Init(const std::string& config_dir, const std::string& name,
48 const std::shared_ptr<DependencyInjector>& injector) {
49 if (!Task::Init(config_dir, name, injector)) {
50 return false;
51 }
52 // Load the config this task.
53 if (!Task::LoadConfig<SpeedDeciderConfig>(&config_)) {
54 return false;
55 }
56 for (const auto& follow_function :
58 follow_distance_function_.emplace_back(
59 std::make_pair(follow_function.speed(), follow_function.slope()));
60 }
61 std::sort(follow_distance_function_.begin(), follow_distance_function_.end());
62 for (const auto& iter : follow_distance_function_) {
63 AINFO << "speed: " << iter.first << ", slope: " << iter.second;
64 }
65 return true;
66}
67
69 ReferenceLineInfo* reference_line_info) {
70 Task::Execute(frame, reference_line_info);
71 init_point_ = frame_->PlanningStartPoint();
72 adc_sl_boundary_ = reference_line_info_->AdcSlBoundary();
73 reference_line_ = &reference_line_info_->reference_line();
74 if (!MakeObjectDecision(reference_line_info->speed_data(),
75 reference_line_info->path_decision())
76 .ok()) {
77 const std::string msg = "Get object decision by speed profile failed.";
78 AERROR << msg;
79 return Status(ErrorCode::PLANNING_ERROR, msg);
80 }
81 return Status::OK();
82}
83
84SpeedDecider::STLocation SpeedDecider::GetSTLocation(
85 const PathDecision* const path_decision, const SpeedData& speed_profile,
86 const STBoundary& st_boundary) const {
87 if (st_boundary.IsEmpty()) {
88 return BELOW;
89 }
90
91 STLocation st_location = BELOW;
92 bool st_position_set = false;
93 const double start_t = st_boundary.min_t();
94 const double end_t = st_boundary.max_t();
95 for (size_t i = 0; i + 1 < speed_profile.size(); ++i) {
96 const STPoint curr_st(speed_profile[i].s(), speed_profile[i].t());
97 const STPoint next_st(speed_profile[i + 1].s(), speed_profile[i + 1].t());
98 if (curr_st.t() < start_t && next_st.t() < start_t) {
99 continue;
100 }
101 if (curr_st.t() > end_t) {
102 break;
103 }
104
105 if (!FLAGS_use_st_drivable_boundary) {
106 common::math::LineSegment2d speed_line(curr_st, next_st);
107 if (st_boundary.HasOverlap(speed_line)) {
108 ADEBUG << "speed profile cross st_boundaries.";
109 st_location = CROSS;
110
111 if (!FLAGS_use_st_drivable_boundary) {
112 if (st_boundary.boundary_type() ==
114 if (!CheckKeepClearCrossable(path_decision, speed_profile,
115 st_boundary)) {
116 st_location = BELOW;
117 }
118 }
119 }
120 break;
121 }
122 }
123
124 // note: st_position can be calculated by checking two st points once
125 // but we need iterate all st points to make sure there is no CROSS
126 if (!st_position_set) {
127 if (start_t < next_st.t() && curr_st.t() < end_t) {
128 STPoint bd_point_front = st_boundary.upper_points().front();
129 double side = common::math::CrossProd(bd_point_front, curr_st, next_st);
130 st_location = side < 0.0 ? ABOVE : BELOW;
131 st_position_set = true;
132 }
133 }
134 }
135 return st_location;
136}
137
138bool SpeedDecider::CheckKeepClearCrossable(
139 const PathDecision* const path_decision, const SpeedData& speed_profile,
140 const STBoundary& keep_clear_st_boundary) const {
141 bool keep_clear_crossable = true;
142
143 const auto& last_speed_point = speed_profile.back();
144 double last_speed_point_v = 0.0;
145 if (last_speed_point.has_v()) {
146 last_speed_point_v = last_speed_point.v();
147 } else {
148 const size_t len = speed_profile.size();
149 if (len > 1) {
150 const auto& last_2nd_speed_point = speed_profile[len - 2];
151 last_speed_point_v = (last_speed_point.s() - last_2nd_speed_point.s()) /
152 (last_speed_point.t() - last_2nd_speed_point.t());
153 }
154 }
155 ADEBUG << "last_speed_point_s[" << last_speed_point.s()
156 << "] st_boundary.max_s[" << keep_clear_st_boundary.max_s()
157 << "] last_speed_point_v[" << last_speed_point_v << "]";
158 if (last_speed_point.s() <= keep_clear_st_boundary.max_s() &&
159 last_speed_point_v < config_.keep_clear_last_point_speed()) {
160 keep_clear_crossable = false;
161 }
162 return keep_clear_crossable;
163}
164
165bool SpeedDecider::CheckKeepClearBlocked(
166 const PathDecision* const path_decision,
167 const Obstacle& keep_clear_obstacle) const {
168 bool keep_clear_blocked = false;
169
170 // check if overlap with other stop wall
171 for (const auto* obstacle : path_decision->obstacles().Items()) {
172 if (obstacle->Id() == keep_clear_obstacle.Id()) {
173 continue;
174 }
175 const double obstacle_start_s = obstacle->PerceptionSLBoundary().start_s();
176 const double adc_length =
178 const double distance =
179 obstacle_start_s - keep_clear_obstacle.PerceptionSLBoundary().end_s();
180
181 if (obstacle->IsBlockingObstacle() && distance > 0 &&
182 distance < (adc_length / 2)) {
183 keep_clear_blocked = true;
184 break;
185 }
186 }
187 return keep_clear_blocked;
188}
189
190bool SpeedDecider::IsFollowTooClose(const Obstacle& obstacle) const {
191 if (!obstacle.IsBlockingObstacle()) {
192 return false;
193 }
194
195 if (obstacle.path_st_boundary().min_t() > 0.0) {
196 return false;
197 }
198 const double obs_speed = obstacle.speed();
199 const double ego_speed = init_point_.v();
200 if (obs_speed > ego_speed) {
201 return false;
202 }
203 const double distance =
204 obstacle.path_st_boundary().min_s() - FLAGS_min_stop_distance_obstacle;
205 static constexpr double lane_follow_max_decel = 3.0;
206 static constexpr double lane_change_max_decel = 3.0;
207 auto* planning_status = injector_->planning_context()
208 ->mutable_planning_status()
209 ->mutable_change_lane();
210 double distance_numerator = std::pow((ego_speed - obs_speed), 2) * 0.5;
211 double distance_denominator = lane_follow_max_decel;
212 if (planning_status->has_status() &&
213 planning_status->status() == ChangeLaneStatus::IN_CHANGE_LANE) {
214 distance_denominator = lane_change_max_decel;
215 }
216 return distance < distance_numerator / distance_denominator;
217}
218
219Status SpeedDecider::MakeObjectDecision(
220 const SpeedData& speed_profile, PathDecision* const path_decision) const {
221 if (speed_profile.size() < 2) {
222 const std::string msg = "dp_st_graph failed to get speed profile.";
223 AERROR << msg;
224 return Status(ErrorCode::PLANNING_ERROR, msg);
225 }
226
227 for (const auto* obstacle : path_decision->obstacles().Items()) {
228 auto* mutable_obstacle = path_decision->Find(obstacle->Id());
229 const auto& boundary = mutable_obstacle->path_st_boundary();
230
231 if (boundary.IsEmpty() || boundary.max_s() < 0.0 ||
232 boundary.max_t() < 0.0 ||
233 boundary.min_t() >= speed_profile.back().t()) {
234 AppendIgnoreDecision(mutable_obstacle);
235 continue;
236 }
237 if (obstacle->HasLongitudinalDecision()) {
238 AppendIgnoreDecision(mutable_obstacle);
239 continue;
240 }
241
242 // for Virtual obstacle, skip if center point NOT "on lane"
243 if (obstacle->IsVirtual()) {
244 const auto& obstacle_box = obstacle->PerceptionBoundingBox();
245 if (!reference_line_->IsOnLane(obstacle_box.center())) {
246 continue;
247 }
248 }
249
250 // always STOP for pedestrian
251 if (config_.is_stop_for_pedestrain() &&
252 CheckStopForPedestrian(*mutable_obstacle)) {
253 ObjectDecisionType stop_decision;
254 if (CreateStopDecision(*mutable_obstacle, &stop_decision,
255 -FLAGS_min_stop_distance_obstacle)) {
256 mutable_obstacle->AddLongitudinalDecision("dp_st_graph/pedestrian",
257 stop_decision);
258 }
259 continue;
260 }
261
262 auto location = GetSTLocation(path_decision, speed_profile, boundary);
263
264 if (!FLAGS_use_st_drivable_boundary) {
265 if (boundary.boundary_type() == STBoundary::BoundaryType::KEEP_CLEAR) {
266 if (CheckKeepClearBlocked(path_decision, *obstacle)) {
267 location = BELOW;
268 }
269 }
270 }
271
272 switch (location) {
273 case BELOW:
274 if (boundary.boundary_type() == STBoundary::BoundaryType::KEEP_CLEAR) {
275 ObjectDecisionType stop_decision;
276 if (CreateStopDecision(*mutable_obstacle, &stop_decision, 0.0)) {
277 mutable_obstacle->AddLongitudinalDecision("dp_st_graph/keep_clear",
278 stop_decision);
279 }
280 } else if (obstacle->IsStatic()) {
281 // stop for static obstacle
282 ObjectDecisionType stop_decision;
283 if (CreateStopDecision(*mutable_obstacle, &stop_decision,
284 -FLAGS_min_stop_distance_obstacle)) {
285 mutable_obstacle->AddLongitudinalDecision("dp_st_graph",
286 stop_decision);
287 }
288 } else if (CheckIsFollow(*obstacle, boundary)) {
289 // stop for low_speed decelerating
290 if (IsFollowTooClose(*mutable_obstacle)) {
291 ObjectDecisionType stop_decision;
292 if (CreateStopDecision(*mutable_obstacle, &stop_decision,
293 -FLAGS_min_stop_distance_obstacle)) {
294 mutable_obstacle->AddLongitudinalDecision("dp_st_graph/too_close",
295 stop_decision);
296 }
297 } else { // high speed or low speed accelerating
298 // FOLLOW decision
299 ObjectDecisionType follow_decision;
300 if (CreateFollowDecision(*mutable_obstacle, &follow_decision)) {
301 mutable_obstacle->AddLongitudinalDecision("dp_st_graph",
302 follow_decision);
303 }
304 }
305 } else {
306 // YIELD decision
307 ObjectDecisionType yield_decision;
308 if (CreateYieldDecision(*mutable_obstacle, &yield_decision)) {
309 mutable_obstacle->AddLongitudinalDecision("dp_st_graph",
310 yield_decision);
311 }
312 }
313 break;
314 case ABOVE:
315 if (boundary.boundary_type() == STBoundary::BoundaryType::KEEP_CLEAR) {
316 ObjectDecisionType ignore;
317 ignore.mutable_ignore();
318 mutable_obstacle->AddLongitudinalDecision("dp_st_graph", ignore);
319 } else {
320 // OVERTAKE decision
321 ObjectDecisionType overtake_decision;
322 if (CreateOvertakeDecision(*mutable_obstacle, &overtake_decision)) {
323 mutable_obstacle->AddLongitudinalDecision("dp_st_graph/overtake",
324 overtake_decision);
325 }
326 }
327 break;
328 case CROSS:
329 if (mutable_obstacle->IsBlockingObstacle()) {
330 ObjectDecisionType stop_decision;
331 if (CreateStopDecision(*mutable_obstacle, &stop_decision,
332 -FLAGS_min_stop_distance_obstacle)) {
333 mutable_obstacle->AddLongitudinalDecision("dp_st_graph/cross",
334 stop_decision);
335 }
336 const std::string msg =
337 absl::StrCat("Failed to find a solution for crossing obstacle: ",
338 mutable_obstacle->Id());
339 AERROR << msg;
340 return Status(ErrorCode::PLANNING_ERROR, msg);
341 }
342 break;
343 default:
344 AERROR << "Unknown position:" << location;
345 }
346 AppendIgnoreDecision(mutable_obstacle);
347 }
348
349 return Status::OK();
350}
351
352void SpeedDecider::AppendIgnoreDecision(Obstacle* obstacle) const {
353 ObjectDecisionType ignore_decision;
354 ignore_decision.mutable_ignore();
355 if (!obstacle->HasLongitudinalDecision()) {
356 obstacle->AddLongitudinalDecision("dp_st_graph", ignore_decision);
357 }
358 if (!obstacle->HasLateralDecision()) {
359 obstacle->AddLateralDecision("dp_st_graph", ignore_decision);
360 }
361}
362
363bool SpeedDecider::CreateStopDecision(const Obstacle& obstacle,
364 ObjectDecisionType* const stop_decision,
365 double stop_distance) const {
366 const auto& boundary = obstacle.path_st_boundary();
367
368 // TODO(all): this is a bug! Cannot mix reference s and path s!
369 // Replace boundary.min_s() with computed reference line s
370 // fence is set according to reference line s.
371 double fence_s = adc_sl_boundary_.end_s() + boundary.min_s() + stop_distance;
372 if (boundary.boundary_type() == STBoundary::BoundaryType::KEEP_CLEAR) {
373 fence_s = obstacle.PerceptionSLBoundary().start_s();
374 }
375 const double main_stop_s =
377 if (main_stop_s < fence_s) {
378 ADEBUG << "Stop fence is further away, ignore.";
379 return false;
380 }
381
382 const auto fence_point = reference_line_->GetReferencePoint(fence_s);
383
384 // set STOP decision
385 auto* stop = stop_decision->mutable_stop();
386 stop->set_distance_s(stop_distance);
387 auto* stop_point = stop->mutable_stop_point();
388 stop_point->set_x(fence_point.x());
389 stop_point->set_y(fence_point.y());
390 stop_point->set_z(0.0);
391 stop->set_stop_heading(fence_point.heading());
392
393 if (boundary.boundary_type() == STBoundary::BoundaryType::KEEP_CLEAR) {
394 stop->set_reason_code(StopReasonCode::STOP_REASON_CLEAR_ZONE);
395 }
396
397 PerceptionObstacle::Type obstacle_type = obstacle.Perception().type();
398 ADEBUG << "STOP: obstacle_id[" << obstacle.Id() << "] obstacle_type["
399 << PerceptionObstacle_Type_Name(obstacle_type) << "]";
400
401 return true;
402}
403
404bool SpeedDecider::CreateFollowDecision(
405 const Obstacle& obstacle, ObjectDecisionType* const follow_decision) const {
406 const double follow_speed = init_point_.v();
407 const double follow_distance_s = -EstimateProperFollowGap(follow_speed);
408
409 const auto& boundary = obstacle.path_st_boundary();
410 const double reference_s =
411 adc_sl_boundary_.end_s() + boundary.min_s() + follow_distance_s;
412 const double main_stop_s =
414 if (main_stop_s < reference_s) {
415 ADEBUG << "Follow reference_s is further away, ignore.";
416 return false;
417 }
418
419 auto ref_point = reference_line_->GetReferencePoint(reference_s);
420
421 // set FOLLOW decision
422 auto* follow = follow_decision->mutable_follow();
423 follow->set_distance_s(follow_distance_s);
424 auto* fence_point = follow->mutable_fence_point();
425 fence_point->set_x(ref_point.x());
426 fence_point->set_y(ref_point.y());
427 fence_point->set_z(0.0);
428 follow->set_fence_heading(ref_point.heading());
429
430 PerceptionObstacle::Type obstacle_type = obstacle.Perception().type();
431 ADEBUG << "FOLLOW: obstacle_id[" << obstacle.Id() << "] obstacle_type["
432 << PerceptionObstacle_Type_Name(obstacle_type) << "]";
433
434 return true;
435}
436
437bool SpeedDecider::CreateYieldDecision(
438 const Obstacle& obstacle, ObjectDecisionType* const yield_decision) const {
439 PerceptionObstacle::Type obstacle_type = obstacle.Perception().type();
440 double yield_distance = config_.yield_distance_buffer();
441
442 const auto& obstacle_boundary = obstacle.path_st_boundary();
443 const double yield_distance_s =
444 std::max(-obstacle_boundary.min_s(), -yield_distance);
445
446 const double reference_line_fence_s =
447 adc_sl_boundary_.end_s() + obstacle_boundary.min_s() + yield_distance_s;
448 const double main_stop_s =
450 if (main_stop_s < reference_line_fence_s) {
451 ADEBUG << "Yield reference_s is further away, ignore.";
452 return false;
453 }
454
455 auto ref_point = reference_line_->GetReferencePoint(reference_line_fence_s);
456
457 // set YIELD decision
458 auto* yield = yield_decision->mutable_yield();
459 yield->set_distance_s(yield_distance_s);
460 yield->mutable_fence_point()->set_x(ref_point.x());
461 yield->mutable_fence_point()->set_y(ref_point.y());
462 yield->mutable_fence_point()->set_z(0.0);
463 yield->set_fence_heading(ref_point.heading());
464
465 ADEBUG << "YIELD: obstacle_id[" << obstacle.Id() << "] obstacle_type["
466 << PerceptionObstacle_Type_Name(obstacle_type) << "]";
467
468 return true;
469}
470
471bool SpeedDecider::CreateOvertakeDecision(
472 const Obstacle& obstacle,
473 ObjectDecisionType* const overtake_decision) const {
474 const auto& velocity = obstacle.Perception().velocity();
475 const double obstacle_speed =
477 .InnerProd(Vec2d(velocity.x(), velocity.y()));
478
479 double overtake_distance_s =
480 EstimateProperOvertakingGap(obstacle_speed, init_point_.v());
481
482 const auto& boundary = obstacle.path_st_boundary();
483 const double reference_line_fence_s =
484 adc_sl_boundary_.end_s() + boundary.min_s() + overtake_distance_s;
485 const double main_stop_s =
487 if (main_stop_s < reference_line_fence_s) {
488 ADEBUG << "Overtake reference_s is further away, ignore.";
489 return false;
490 }
491
492 auto ref_point = reference_line_->GetReferencePoint(reference_line_fence_s);
493
494 // set OVERTAKE decision
495 auto* overtake = overtake_decision->mutable_overtake();
496 overtake->set_distance_s(overtake_distance_s);
497 overtake->mutable_fence_point()->set_x(ref_point.x());
498 overtake->mutable_fence_point()->set_y(ref_point.y());
499 overtake->mutable_fence_point()->set_z(0.0);
500 overtake->set_fence_heading(ref_point.heading());
501
502 PerceptionObstacle::Type obstacle_type = obstacle.Perception().type();
503 ADEBUG << "OVERTAKE: obstacle_id[" << obstacle.Id() << "] obstacle_type["
504 << PerceptionObstacle_Type_Name(obstacle_type) << "]";
505
506 return true;
507}
508
509bool SpeedDecider::CheckIsFollow(const Obstacle& obstacle,
510 const STBoundary& boundary) const {
511 const double obstacle_l_distance =
512 std::min(std::fabs(obstacle.PerceptionSLBoundary().start_l()),
513 std::fabs(obstacle.PerceptionSLBoundary().end_l()));
514 if (obstacle_l_distance > config_.follow_min_obs_lateral_distance()) {
515 return false;
516 }
517
518 // move towards adc
519 if (boundary.bottom_left_point().s() > boundary.bottom_right_point().s()) {
520 return false;
521 }
522
523 static constexpr double kFollowTimeEpsilon = 1e-3;
524 static constexpr double kFollowCutOffTime = 0.5;
525 if (boundary.min_t() > kFollowCutOffTime ||
526 boundary.max_t() < kFollowTimeEpsilon) {
527 return false;
528 }
529
530 // cross lane but be moving to different direction
531 if (boundary.max_t() - boundary.min_t() < config_.follow_min_time_sec()) {
532 return false;
533 }
534
535 return true;
536}
537
538bool SpeedDecider::CheckStopForPedestrian(const Obstacle& obstacle) const {
539 const auto& perception_obstacle = obstacle.Perception();
540 if (perception_obstacle.type() != PerceptionObstacle::PEDESTRIAN) {
541 return false;
542 }
543
544 const auto& obstacle_sl_boundary = obstacle.PerceptionSLBoundary();
545 if (obstacle_sl_boundary.end_s() < adc_sl_boundary_.start_s()) {
546 return false;
547 }
548
549 // read pedestrian stop time from PlanningContext
550 auto* mutable_speed_decider_status = injector_->planning_context()
551 ->mutable_planning_status()
552 ->mutable_speed_decider();
553 std::unordered_map<std::string, double> stop_time_map;
554 for (const auto& pedestrian_stop_time :
555 mutable_speed_decider_status->pedestrian_stop_time()) {
556 stop_time_map[pedestrian_stop_time.obstacle_id()] =
557 pedestrian_stop_time.stop_timestamp_sec();
558 }
559
560 const std::string& obstacle_id = obstacle.Id();
561
562 // update stop timestamp on static pedestrian for watch timer
563 // check on stop timer for static pedestrians
564 static constexpr double kSDistanceStartTimer = 10.0;
565 static constexpr double kMaxStopSpeed = 0.3;
566 static constexpr double kPedestrianStopTimeout = 4.0;
567
568 bool result = true;
569 if (obstacle.path_st_boundary().min_s() < kSDistanceStartTimer) {
570 const auto obstacle_speed = std::hypot(perception_obstacle.velocity().x(),
571 perception_obstacle.velocity().y());
572 if (obstacle_speed > kMaxStopSpeed) {
573 stop_time_map.erase(obstacle_id);
574 } else {
575 if (stop_time_map.count(obstacle_id) == 0) {
576 // add timestamp
577 stop_time_map[obstacle_id] = Clock::NowInSeconds();
578 ADEBUG << "add timestamp: obstacle_id[" << obstacle_id << "] timestamp["
579 << Clock::NowInSeconds() << "]";
580 } else {
581 // check timeout
582 double stop_timer = Clock::NowInSeconds() - stop_time_map[obstacle_id];
583 ADEBUG << "stop_timer: obstacle_id[" << obstacle_id << "] stop_timer["
584 << stop_timer << "]";
585 if (stop_timer >= kPedestrianStopTimeout) {
586 result = false;
587 }
588 }
589 }
590 }
591
592 // write pedestrian stop time to PlanningContext
593 mutable_speed_decider_status->mutable_pedestrian_stop_time()->Clear();
594 for (const auto& stop_time : stop_time_map) {
595 auto pedestrian_stop_time =
596 mutable_speed_decider_status->add_pedestrian_stop_time();
597 pedestrian_stop_time->set_obstacle_id(stop_time.first);
598 pedestrian_stop_time->set_stop_timestamp_sec(stop_time.second);
599 }
600 return result;
601}
602
603double SpeedDecider::EstimateProperOvertakingGap(const double target_obs_speed,
604 const double adc_speed) const {
605 const double overtake_distance_s = std::fmax(
606 std::fmax(adc_speed, target_obs_speed) * config_.overtake_time_buffer(),
607 config_.overtake_min_distance());
608 return overtake_distance_s;
609}
610
611double SpeedDecider::EstimateProperFollowGap(const double& adc_speed) const {
612 double follow_distance = config_.stop_follow_distance();
613 for (int i = 1; i < follow_distance_function_.size(); i++) {
614 if (adc_speed <= follow_distance_function_[i].first) {
615 follow_distance += follow_distance_function_[i - 1].second *
616 (adc_speed - follow_distance_function_[i - 1].first);
617 break;
618 } else {
619 follow_distance += follow_distance_function_[i - 1].second *
620 (follow_distance_function_[i].first -
621 follow_distance_function_[i - 1].first);
622 }
623 }
624 if (adc_speed > follow_distance_function_.back().first) {
625 follow_distance += follow_distance_function_.back().second *
626 (adc_speed - follow_distance_function_.back().first);
627 }
628 AINFO << "follow_distance: " << follow_distance;
629 return follow_distance;
630}
631
632} // namespace planning
633} // namespace apollo
A general class to denote the return status of an API call.
Definition status.h:43
bool ok() const
check whether the return status is OK.
Definition status.h:67
static Status OK()
generate a success status.
Definition status.h:60
@Brief This is a helper class that can load vehicle configurations.
static const VehicleConfig & GetConfig()
Get the current vehicle configuration.
bool HasOverlap(const LineSegment2d &line_segment) const
Check if a line segment has overlap with this polygon.
Definition polygon2d.cc:377
Implements a class of 2-dimensional vectors.
Definition vec2d.h:42
void set_x(const double x)
Setter for x component
Definition vec2d.h:60
static Vec2d CreateUnitVec2d(const double angle)
Creates a unit-vector with a given angle to the positive x semi-axis
Definition vec2d.cc:29
double InnerProd(const Vec2d &other) const
Returns the inner product between these two Vec2d.
Definition vec2d.cc:61
a singleton clock that can be used to get the current timestamp.
Definition clock.h:39
static double NowInSeconds()
gets the current time in second.
Definition clock.cc:56
Frame holds all data for one planning cycle.
Definition frame.h:62
const common::TrajectoryPoint & PlanningStartPoint() const
Definition frame.cc:79
PathDecision represents all obstacle decisions on one path.
ReferenceLineInfo holds all data for one reference line.
const ReferenceLine & reference_line() const
const SLBoundary & AdcSlBoundary() const
bool IsOnLane(const common::SLPoint &sl_point) const
: check if a box/point is on lane along reference line
ReferencePoint GetReferencePoint(const double s) const
std::vector< STPoint > upper_points() const
BoundaryType boundary_type() const
bool Init(const std::string &config_dir, const std::string &name, const std::shared_ptr< DependencyInjector > &injector) override
common::Status Execute(Frame *frame, ReferenceLineInfo *reference_line_info) override
std::shared_ptr< DependencyInjector > injector_
Definition task.h:59
ReferenceLineInfo * reference_line_info_
Definition task.h:58
virtual bool Init(const std::string &config_dir, const std::string &name, const std::shared_ptr< DependencyInjector > &injector)
Definition task.cc:40
virtual common::Status Execute(Frame *frame, ReferenceLineInfo *reference_line_info)
Definition task.cc:60
Planning module main class.
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
Some util functions.
double CrossProd(const Vec2d &start_point, const Vec2d &end_point_1, const Vec2d &end_point_2)
Cross product between two 2-D vectors from the common start point, and end at two other points.
Definition math_utils.cc:28
class register implement
Definition arena_queue.h:37
Defines proper safety distance the ADC should keep from target obstacle considering different informa...
optional VehicleParam vehicle_param
optional FollowDistanceSchedulerInfo follow_distance_scheduler