Apollo 11.0
自动驾驶开放平台
stage_check.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"
23
24namespace apollo {
25namespace planning {
26
28
30 const TrajectoryPoint& planning_init_point, Frame* frame) {
31 ADEBUG << "stage: Check";
32 CHECK_NOTNULL(frame);
33 CHECK_NOTNULL(context_);
34
35 ADCInitStatus();
37 StageResult result = ExecuteTaskOnOpenSpace(frame);
38 if (result.HasError()) {
39 AERROR << "ParkAndGoStageAdjust planning error";
41 }
42
43 bool ready_to_cruise =
44 CheckADCReadyToCruise(injector_->vehicle_state(), frame,
45 GetContextAs<ParkAndGoContext>()->scenario_config);
46 return FinishStage(ready_to_cruise);
47}
48
49StageResult ParkAndGoStageCheck::FinishStage(const bool success) {
50 if (success) {
51 next_stage_ = "PARK_AND_GO_CRUISE";
52 } else {
53 next_stage_ = "PARK_AND_GO_ADJUST";
54 }
55 injector_->planning_context()
56 ->mutable_planning_status()
57 ->mutable_park_and_go()
58 ->set_in_check_stage(false);
59 return StageResult(StageStatusType::FINISHED);
60}
61
62void ParkAndGoStageCheck::ADCInitStatus() {
63 auto* park_and_go_status = injector_->planning_context()
64 ->mutable_planning_status()
65 ->mutable_park_and_go();
66 park_and_go_status->Clear();
67 park_and_go_status->mutable_adc_init_position()->set_x(
68 injector_->vehicle_state()->x());
69 park_and_go_status->mutable_adc_init_position()->set_y(
70 injector_->vehicle_state()->y());
71 park_and_go_status->mutable_adc_init_position()->set_z(0.0);
72 park_and_go_status->set_adc_init_heading(
73 injector_->vehicle_state()->heading());
74 park_and_go_status->set_in_check_stage(true);
75}
76
77} // namespace planning
78} // namespace apollo
Frame holds all data for one planning cycle.
Definition frame.h:62
OpenSpaceInfo * mutable_open_space_info()
Definition frame.h:169
void set_is_on_open_space_trajectory(const bool flag)
StageResult Process(const common::TrajectoryPoint &planning_init_point, Frame *frame) override
Each stage does its business logic inside Process function.
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
StageResult ExecuteTaskOnOpenSpace(Frame *frame)
Definition stage.cc:206
std::shared_ptr< DependencyInjector > injector_
Definition stage.h:91
Planning module main class.
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
bool CheckADCReadyToCruise(const common::VehicleStateProvider *vehicle_state_provider, Frame *frame, const apollo::planning::ScenarioParkAndGoConfig &scenario_config)
Definition util.cc:28
class register implement
Definition arena_queue.h:37