Apollo 11.0
自动驾驶开放平台
stage_large_curvature.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2024 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 <string>
24#include <vector>
25
27
28namespace apollo {
29namespace planning {
30
32 const StagePipeline& config,
33 const std::shared_ptr<DependencyInjector>& injector,
34 const std::string& config_dir,
35 void* context) {
36 CHECK_NOTNULL(context);
37 bool ret = Stage::Init(config, injector, config_dir, context);
38 if (!ret) {
39 AERROR << Name() << "init failed!";
40 return false;
41 }
42 scenario_config_.CopyFrom(GetContextAs<LargeCurvatureContext>()->scenario_config);
43 return ret;
44}
45
48 StageResult result = ExecuteTaskOnOpenSpace(frame);
49 if (result.HasError()) {
50 AERROR << "StageLargeCurvature planning error";
52 }
53
54 if (frame->open_space_info().destination_reached() || IsCurvatureSmall(frame)) {
55 AINFO << "StageLargeCurvature destination reached";
56 next_stage_.clear();
58 }
60}
61
62bool StageLargeCurvature::IsCurvatureSmall(Frame* frame) {
63 if (frame->reference_line_info().empty()) {
64 AINFO << "StageLargeCurvature: reference line info is empty";
65 return false;
66 }
67
68 common::VehicleState vehicle_state = injector_->vehicle_state()->vehicle_state();
69 common::SLPoint adc_sl;
70 if (!frame->reference_line_info().front().reference_line().XYToSL(
71 {vehicle_state.x(), vehicle_state.y()}, &adc_sl)) {
72 AINFO << "StageLargeCurvature: failed to get nearest lane";
73 return false;
74 }
75
76 double check_s = 0;
77 double kappa = 0;
78 for (double delta_s = 0; delta_s < scenario_config_.curvature_check_distance();
79 delta_s += scenario_config_.curvature_check_delta_s()) {
80 check_s = adc_sl.s() + delta_s;
81 if (frame->reference_line_info().front().reference_line().GetMapPath().accumulated_s().back() + 1e-2
82 < check_s) {
83 AINFO << "StageLargeCurvature: s is too large";
84 return false;
85 }
86
87 kappa = frame->reference_line_info().front().reference_line().GetNearestReferencePoint(check_s).kappa();
88 if (fabs(kappa) > scenario_config_.curvature_check_max()) {
89 AINFO << "StageLargeCurvature: curvature is too large";
90 return false;
91 }
92 AINFO << "delta_s: " << delta_s << " check_s: " << check_s << " kappa: " << kappa << " point: "
93 << frame->reference_line_info().front().reference_line().GetNearestReferencePoint(check_s).DebugString();
94 }
95 return true;
96}
97
98} // namespace planning
99} // namespace apollo
Frame holds all data for one planning cycle.
Definition frame.h:62
const OpenSpaceInfo & open_space_info() const
Definition frame.h:167
OpenSpaceInfo * mutable_open_space_info()
Definition frame.h:169
const std::list< ReferenceLineInfo > & reference_line_info() const
Definition frame.cc:123
void set_is_on_open_space_trajectory(const bool flag)
bool Init(const StagePipeline &config, const std::shared_ptr< DependencyInjector > &injector, const std::string &config_dir, void *context)
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
virtual bool Init(const StagePipeline &config, const std::shared_ptr< DependencyInjector > &injector, const std::string &config_dir, void *context)
Definition stage.cc:43
std::shared_ptr< DependencyInjector > injector_
Definition stage.h:91
const std::string & Name() const
Definition stage.cc:99
Planning module main class.
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37