Apollo 11.0
自动驾驶开放平台
large_curvature_scenario.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 <vector>
24
29
30namespace apollo {
31namespace planning {
34
35bool LargeCurvatureScenario::Init(std::shared_ptr<DependencyInjector> injector, const std::string& name) {
36 // hook: Apollo License Verification: v_apollo_park
37 if (init_) {
38 return true;
39 }
40
41 if (!Scenario::Init(injector, name)) {
42 AERROR << "failed to init scenario" << Name();
43 return false;
44 }
45
46 if (!Scenario::LoadConfig<ScenarioLargeCurvatureConfig>(&context_.scenario_config)) {
47 AERROR << "fail to get config of scenario" << Name();
48 return false;
49 }
50 AINFO << context_.scenario_config.DebugString();
52 CHECK_NOTNULL(hdmap_);
53 init_ = true;
54 return true;
55}
56
57bool LargeCurvatureScenario::IsTransferable(const Scenario* const other_scenario, const Frame& frame) {
58 if (!frame.local_view().planning_command->has_lane_follow_command()) {
59 AINFO << "No lane follow command from routing";
60 return false;
61 }
62 if (other_scenario == nullptr || frame.reference_line_info().empty()) {
63 AINFO << "Other scenario is null or no reference line";
64 return false;
65 }
66
67 // check if ego in big curvature
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({vehicle_state.x(), vehicle_state.y()}, &adc_sl)) {
71 AINFO << "scenario LargeCurvature: failed to get nearest lane";
72 return false;
73 }
74
75 double kappa
76 = frame.reference_line_info().front().reference_line().GetNearestReferencePoint(adc_sl.s() + 3.0).kappa();
77 AINFO << "kappa: " << kappa << " ego_x : " << vehicle_state.x() << " ego_y: " << vehicle_state.y()
78 << " ref length: " << frame.reference_line_info().front().reference_line().Length() << " s: " << adc_sl.s();
79 double vehicle_max_curvature = 1 / common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param().min_turn_radius();
80 AINFO << vehicle_max_curvature * context_.scenario_config.curvature_ratio();
81 if (fabs(kappa) > vehicle_max_curvature * context_.scenario_config.curvature_ratio()
82 && frame.reference_line_info().front().SDistanceToDestination() > 10.0) {
83 AINFO << "ego in large curvature";
84 return true;
85 }
86 return false;
87} // namespace planning
88
89} // namespace planning
90} // namespace apollo
The class of polygon in 2-D.
Definition polygon2d.h:42
Implements a class of 2-dimensional vectors.
Definition vec2d.h:42
static const HDMap * BaseMapPtr()
Frame holds all data for one planning cycle.
Definition frame.h:62
const LocalView & local_view() const
Definition frame.h:163
const std::list< ReferenceLineInfo > & reference_line_info() const
Definition frame.cc:123
bool IsTransferable(const Scenario *const other_scenario, const Frame &frame) override
Each scenario should define its own transfer condition, i.e., when it should allow to transfer from o...
bool Init(std::shared_ptr< DependencyInjector > injector, const std::string &name) override
virtual bool Init(std::shared_ptr< DependencyInjector > injector, const std::string &name)
Definition scenario.cc:43
std::shared_ptr< DependencyInjector > injector_
Definition scenario.h:113
const std::string & Name() const
Definition scenario.h:98
Planning module main class.
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37
std::shared_ptr< PlanningCommand > planning_command
Definition local_view.h:48