Apollo 11.0
自动驾驶开放平台
stage_cruise.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
18
19#include "cyber/common/log.h"
24
25namespace apollo {
26namespace planning {
27
29
31 const TrajectoryPoint& planning_init_point, Frame* frame) {
32 ADEBUG << "stage: Cruise";
33 CHECK_NOTNULL(frame);
34
35 StageResult result = ExecuteTaskOnReferenceLine(planning_init_point, frame);
36 if (result.HasError()) {
37 AERROR << "ParkAndGoStageCruise planning error";
38 }
39
40 const ReferenceLineInfo& reference_line_info =
41 frame->reference_line_info().front();
42 // check ADC status:
43 // 1. At routing beginning: stage finished
44 ParkAndGoStatus status =
45 CheckADCParkAndGoCruiseCompleted(reference_line_info);
46
47 if (status == CRUISE_COMPLETE) {
48 return FinishStage();
49 }
51}
52
53StageResult ParkAndGoStageCruise::FinishStage() { return FinishScenario(); }
54
56ParkAndGoStageCruise::CheckADCParkAndGoCruiseCompleted(
57 const ReferenceLineInfo& reference_line_info) {
58 const auto& reference_line = reference_line_info.reference_line();
59
60 // check l delta
61 const common::math::Vec2d adc_position = {injector_->vehicle_state()->x(),
62 injector_->vehicle_state()->y()};
63 common::SLPoint adc_position_sl;
64 reference_line.XYToSL(adc_position, &adc_position_sl);
65
66 const double kLBuffer = 0.5;
67 if (std::fabs(adc_position_sl.l()) < kLBuffer) {
68 ADEBUG << "cruise completed";
69 return CRUISE_COMPLETE;
70 }
71
72 /* loose heading check, so that ADC can enter LANE_FOLLOW scenario sooner
73 * which is more sophisticated
74 // heading delta
75 const double adc_heading =
76 common::VehicleStateProvider::Instance()->heading();
77 const auto reference_point =
78 reference_line.GetReferencePoint(adc_position_sl.s());
79 const auto path_point = reference_point.ToPathPoint(adc_position_sl.s());
80 ADEBUG << "adc_position_sl.l():[" << adc_position_sl.l() << "]";
81 ADEBUG << "adc_heading - path_point.theta():[" << adc_heading << "]"
82 << "[" << path_point.theta() << "]";
83 const double kHeadingBuffer = 0.1;
84 if (std::fabs(adc_heading - path_point.theta()) < kHeadingBuffer) {
85 ADEBUG << "cruise completed";
86 return CRUISE_COMPLETE;
87 }
88 */
89
90 return CRUISING;
91}
92
93} // namespace planning
94} // namespace apollo
Implements a class of 2-dimensional vectors.
Definition vec2d.h:42
double x() const
Getter for x component
Definition vec2d.h:54
Frame holds all data for one planning cycle.
Definition frame.h:62
const std::list< ReferenceLineInfo > & reference_line_info() const
Definition frame.cc:123
StageResult Process(const common::TrajectoryPoint &planning_init_point, Frame *frame) override
Each stage does its business logic inside Process function.
ReferenceLineInfo holds all data for one reference line.
const StageResult & SetStageStatus(const StageStatusType &stage_status)
Set the stage status.
bool HasError() const
Check if StageResult contains error.
virtual StageResult FinishScenario()
Definition stage.cc:258
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