Apollo 10.0
自动驾驶开放平台
stage_slow_down.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 <memory>
24
25#include "cyber/common/log.h"
30
31namespace apollo {
32namespace planning {
33
35
37 const TrajectoryPoint& planning_init_point, Frame* frame) {
38 ADEBUG << "stage: SlowDown";
39 CHECK_NOTNULL(frame);
40
41 auto scenario_context = GetContextAs<EmergencyPullOverContext>();
42 scenario_config_.CopyFrom(scenario_context->scenario_config);
43
44 // set cruise_speed to slow down
45 const double adc_speed = injector_->vehicle_state()->linear_velocity();
46 double target_slow_down_speed = scenario_context->target_slow_down_speed;
47 if (target_slow_down_speed <= 0) {
48 target_slow_down_speed = scenario_context->target_slow_down_speed =
49 std::max(
50 scenario_config_.target_slow_down_speed(),
51 adc_speed - scenario_config_.max_stop_deceleration() *
52 scenario_config_.slow_down_deceleration_time());
53 }
54 auto& reference_line_info = frame->mutable_reference_line_info()->front();
55 reference_line_info.LimitCruiseSpeed(target_slow_down_speed);
56
57 StageResult result = ExecuteTaskOnReferenceLine(planning_init_point, frame);
58 if (result.HasError()) {
59 AERROR << "EmergencyPullOverStageSlowDown planning error";
60 }
61
62 // check slow enough
63 static constexpr double kSpeedTolarence = 1.0;
64 if (adc_speed - target_slow_down_speed <= kSpeedTolarence) {
65 return FinishStage();
66 }
67
69}
70
71StageResult EmergencyPullOverStageSlowDown::FinishStage() {
72 auto* pull_over_status = injector_->planning_context()
73 ->mutable_planning_status()
74 ->mutable_pull_over();
75 pull_over_status->set_plan_pull_over_path(true);
76
77 next_stage_ = "EMERGENCY_PULL_OVER_APPROACH";
79}
80
81} // namespace planning
82} // namespace apollo
StageResult Process(const common::TrajectoryPoint &planning_init_point, Frame *frame) override
Each stage does its business logic inside Process function.
Frame holds all data for one planning cycle.
Definition frame.h:62
std::list< ReferenceLineInfo > * mutable_reference_line_info()
Definition frame.cc:127
const StageResult & SetStageStatus(const StageStatusType &stage_status)
Set the stage status.
bool HasError() const
Check if StageResult contains error.
std::string next_stage_
Definition stage.h:89
std::shared_ptr< DependencyInjector > injector_
Definition stage.h:91
StageResult ExecuteTaskOnReferenceLine(const common::TrajectoryPoint &planning_start_point, Frame *frame)
Definition stage.cc:101
Planning module main class.
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
class register implement
Definition arena_queue.h:37