Apollo
11.0
自动驾驶开放平台
precise_parking_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
21
#include "
modules/planning/planning_base/common/frame.h
"
22
#include "
modules/planning/planning_base/common/util/print_debug_info.h
"
23
#include "
modules/planning/planning_open_space/utils/open_space_roi_util.h
"
24
#include "
modules/planning/scenarios/precise_parking/precise_parking_scenario.h
"
25
26
namespace
apollo
{
27
namespace
planning
{
28
using
apollo::common::math::Polygon2d
;
29
using
apollo::common::math::Vec2d
;
30
using
apollo::external_command::PreciseParkingCommand
;
31
32
bool
PreciseParkingScenario::Init
(std::shared_ptr<DependencyInjector> injector,
const
std::string& name) {
33
if
(!
Scenario::Init
(injector, name)) {
34
AERROR
<<
"failed to init scenario"
<<
Name
();
35
return
false
;
36
}
37
38
if
(!Scenario::LoadConfig<ScenarioPreciseParkingConfig>(&context_.
scenario_config
)) {
39
AERROR
<<
"fail to get config of scenario"
<<
Name
();
40
return
false
;
41
}
42
return
true
;
43
}
44
45
bool
PreciseParkingScenario::IsTransferable
(
const
Scenario
*
const
other_scenario,
const
Frame
& frame) {
46
const
auto
& planning_command = frame.
local_view
().
planning_command
;
47
if
(!planning_command->has_custom_command()) {
48
return
false
;
49
}
50
if
(!planning_command->custom_command().Is<
PreciseParkingCommand
>()) {
51
return
false
;
52
}
53
context_.
precise_parking_command
.Clear();
54
if
(!planning_command->custom_command().UnpackTo(&context_.
precise_parking_command
)) {
55
AERROR
<<
"Precise Parking Command unpack error"
<< planning_command->DebugString();
56
return
false
;
57
}
58
return
true
;
59
}
// namespace planning
60
61
}
// namespace planning
62
}
// namespace apollo
apollo::common::math::Polygon2d
The class of polygon in 2-D.
Definition
polygon2d.h:42
apollo::common::math::Vec2d
Implements a class of 2-dimensional vectors.
Definition
vec2d.h:42
apollo::planning::Frame
Frame holds all data for one planning cycle.
Definition
frame.h:62
apollo::planning::Frame::local_view
const LocalView & local_view() const
Definition
frame.h:163
apollo::planning::PreciseParkingScenario::IsTransferable
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...
Definition
precise_parking_scenario.cc:45
apollo::planning::PreciseParkingScenario::Init
bool Init(std::shared_ptr< DependencyInjector > injector, const std::string &name) override
Definition
precise_parking_scenario.cc:32
apollo::planning::Scenario
Definition
scenario.h:52
apollo::planning::Scenario::Init
virtual bool Init(std::shared_ptr< DependencyInjector > injector, const std::string &name)
Definition
scenario.cc:43
apollo::planning::Scenario::Name
const std::string & Name() const
Definition
scenario.h:98
planning
Planning module main class.
AERROR
#define AERROR
Definition
log.h:44
frame.h
apollo
class register implement
Definition
arena_queue.h:37
open_space_roi_util.h
precise_parking_scenario.h
print_debug_info.h
apollo::external_command::PreciseParkingCommand
Definition
precise_parking_command.proto:13
apollo::planning::LocalView::planning_command
std::shared_ptr< PlanningCommand > planning_command
Definition
local_view.h:48
apollo::planning::PreciseParkingContext::precise_parking_command
apollo::external_command::PreciseParkingCommand precise_parking_command
Definition
precise_parking_scenario.h:36
apollo::planning::PreciseParkingContext::scenario_config
ScenarioPreciseParkingConfig scenario_config
Definition
precise_parking_scenario.h:35
modules
planning
scenarios
precise_parking
precise_parking_scenario.cc