Apollo 11.0
自动驾驶开放平台
apollo::planning::FreeSpaceScenario类 参考

#include <free_space_scenario.h>

类 apollo::planning::FreeSpaceScenario 继承关系图:
apollo::planning::FreeSpaceScenario 的协作图:

Public 成员函数

bool Init (std::shared_ptr< DependencyInjector > injector, const std::string &name) override
 
FreeSpaceContext * GetContext () override
 Get the scenario context.
 
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 other scenario to itself.
 
- Public 成员函数 继承自 apollo::planning::Scenario
 Scenario ()
 
virtual ~Scenario ()=default
 
virtual ScenarioResult Process (const common::TrajectoryPoint &planning_init_point, Frame *frame)
 
virtual bool Exit (Frame *frame)
 
virtual bool Enter (Frame *frame)
 
std::shared_ptr< Stage > CreateStage (const StagePipeline &stage_pipeline)
 Each scenario should define its own stages object's creation scenario will call stage's Stage::Process function following a configured order, The return value of Stage::Process function determines the transition from one stage to another.
 
const ScenarioStatusType & GetStatus () const
 
const std::string GetStage () const
 
const std::string & GetMsg () const
 
const std::string & Name () const
 
void Reset ()
 Reset the scenario, used before entering the scenario.
 

额外继承的成员函数

- Protected 成员函数 继承自 apollo::planning::Scenario
template<typename T >
bool LoadConfig (T *config)
 
- Protected 属性 继承自 apollo::planning::Scenario
ScenarioResult scenario_result_
 
std::shared_ptr< Stage > current_stage_
 
std::unordered_map< std::string, const StagePipeline * > stage_pipeline_map_
 
std::string msg_
 
std::shared_ptr< DependencyInjector > injector_
 
std::string config_path_
 
std::string config_dir_
 
std::string name_
 
ScenarioPipeline scenario_pipeline_config_
 

详细描述

在文件 free_space_scenario.h 第 42 行定义.

成员函数说明

◆ GetContext()

FreeSpaceContext * apollo::planning::FreeSpaceScenario::GetContext ( )
inlineoverridevirtual

Get the scenario context.

实现了 apollo::planning::Scenario.

在文件 free_space_scenario.h 第 49 行定义.

49 {
50 return &context_;
51 }

◆ Init()

bool apollo::planning::FreeSpaceScenario::Init ( std::shared_ptr< DependencyInjector >  injector,
const std::string &  name 
)
overridevirtual

重载 apollo::planning::Scenario .

在文件 free_space_scenario.cc 第 36 行定义.

36 {
37 // hook: Apollo License Verification: v_apollo_park
38 if (init_) {
39 return true;
40 }
41
42 if (!Scenario::Init(injector, name)) {
43 AERROR << "failed to init scenario" << Name();
44 return false;
45 }
46
47 if (!Scenario::LoadConfig<ScenarioFreeSpaceConfig>(&context_.scenario_config)) {
48 AERROR << "fail to get config of scenario" << Name();
49 return false;
50 }
52 CHECK_NOTNULL(hdmap_);
53 init_ = true;
54 return true;
55}
static const HDMap * BaseMapPtr()
virtual bool Init(std::shared_ptr< DependencyInjector > injector, const std::string &name)
Definition scenario.cc:43
const std::string & Name() const
Definition scenario.h:98
#define AERROR
Definition log.h:44
ScenarioFreeSpaceConfig scenario_config

◆ IsTransferable()

bool apollo::planning::FreeSpaceScenario::IsTransferable ( const Scenario *const  other_scenario,
const Frame &  frame 
)
overridevirtual

Each scenario should define its own transfer condition, i.e., when it should allow to transfer from other scenario to itself.

重载 apollo::planning::Scenario .

在文件 free_space_scenario.cc 第 57 行定义.

57 {
58 const auto& planning_command = frame.local_view().planning_command;
59 if (!planning_command->has_custom_command()) {
60 return false;
61 }
62 if (!planning_command->custom_command().Is<FreeSpaceCommand>()) {
63 return false;
64 }
65 context_.free_space_command.Clear();
66 if (!planning_command->custom_command().UnpackTo(&context_.free_space_command)) {
67 AERROR << "Free Space Command unpack error" << planning_command->DebugString();
68 return false;
69 }
70 const auto& vehicle_state = frame.vehicle_state();
71 const auto& vehicle_param = common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param();
72 double adc_speed = vehicle_state.linear_velocity();
73 const double max_adc_stop_speed = vehicle_param.max_abs_speed_when_stopped();
74 if (std::fabs(adc_speed) > max_adc_stop_speed) {
75 AINFO << "adc not stopped" << adc_speed;
76 return false;
77 }
78 apollo::common::math::Polygon2d ego_box(injector_->ego_info()->ego_box());
79 Vec2d vec_to_center(
80 (vehicle_param.front_edge_to_center() - vehicle_param.back_edge_to_center()) / 2.0,
81 (vehicle_param.left_edge_to_center() - vehicle_param.right_edge_to_center()) / 2.0);
82 const auto& end_pose = context_.free_space_command.parking_spot_pose();
83 Vec2d position(end_pose.x(), end_pose.y());
84 Vec2d center(position + vec_to_center.rotate(end_pose.heading()));
85 Polygon2d end_box(Box2d(center, end_pose.heading(), vehicle_param.length(), vehicle_param.width()));
86 PrintCurves print_curves;
87 print_curves.AddPoint("ego_box", ego_box.points());
88 print_curves.AddPoint("end_box", end_box.points());
89 if (!context_.free_space_command.has_drivable_roi()) {
90 AERROR << "drivable_roi is needed!";
91 return false;
92 }
93 const auto& roi_polygon = context_.free_space_command.drivable_roi();
94 std::vector<Vec2d> polygon_points;
95 for (const auto& point : roi_polygon.point()) {
96 polygon_points.emplace_back(point.x(), point.y());
97 }
98 print_curves.AddPoint("free_space_roi", polygon_points);
99 Polygon2d polygon_roi(polygon_points);
100 if (OpenSpaceRoiUtil::IsPolygonClockwise(polygon_points)) {
101 AERROR << "drivable_roi should be counter-clockwise!";
102 print_curves.PrintToLog();
103 return false;
104 }
105 if (!polygon_roi.Contains(ego_box) || !polygon_roi.Contains(end_box)) {
106 AERROR << "ego box or end box is out of roi";
107 print_curves.PrintToLog();
108 return false;
109 }
110 for (const auto& roi_polygon : context_.free_space_command.non_drivable_roi()) {
111 std::vector<Vec2d> polygon_points;
112 for (const auto& point : roi_polygon.point()) {
113 polygon_points.emplace_back(point.x(), point.y());
114 }
115 print_curves.AddPoint("free_space_roi", polygon_points);
116 Polygon2d polygon_roi(polygon_points);
117 if (!OpenSpaceRoiUtil::IsPolygonClockwise(polygon_points)) {
118 AERROR << "non_drivable_roi should be clockwise!";
119 print_curves.PrintToLog();
120 return false;
121 }
122 if (polygon_roi.HasOverlap(ego_box) || polygon_roi.HasOverlap(end_box)) {
123 AERROR << "ego box or end box has collision with obs";
124 print_curves.PrintToLog();
125 return false;
126 }
127 }
128 print_curves.PrintToLog();
129 return true;
130} // namespace planning
The class of polygon in 2-D.
Definition polygon2d.h:42
static bool IsPolygonClockwise(const std::vector< Vec2d > &polygon)
std::shared_ptr< DependencyInjector > injector_
Definition scenario.h:113
#define AINFO
Definition log.h:42
apollo::external_command::FreeSpaceCommand free_space_command

该类的文档由以下文件生成: