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

#include <extricate_stage.h>

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

Public 成员函数

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.
 
bool HasCollision (Frame *frame, const common::math::Box2d &adc_box)
 
bool GenerateStraightReversePath (PathData *path_data, const common::TrajectoryPoint &init_point)
 
- Public 成员函数 继承自 apollo::planning::Stage
 Stage ()
 
virtual ~Stage ()=default
 
const std::string & Name () const
 
template<typename T >
T * GetContextAs () const
 
const std::string & NextStage () const
 

额外继承的成员函数

- Protected 成员函数 继承自 apollo::planning::Stage
StageResult ExecuteTaskOnReferenceLine (const common::TrajectoryPoint &planning_start_point, Frame *frame)
 
StageResult ExecuteTaskOnReferenceLineForOnlineLearning (const common::TrajectoryPoint &planning_start_point, Frame *frame)
 
StageResult ExecuteTaskOnOpenSpace (Frame *frame)
 
virtual StageResult FinishScenario ()
 
void RecordDebugInfo (ReferenceLineInfo *reference_line_info, const std::string &name, const double time_diff_ms)
 
- Protected 属性 继承自 apollo::planning::Stage
std::vector< std::shared_ptr< Task > > task_list_
 
std::shared_ptr< Task > fallback_task_
 
std::string next_stage_
 
void * context_
 
std::shared_ptr< DependencyInjector > injector_
 
StagePipeline pipeline_config_
 

详细描述

在文件 extricate_stage.h 第 35 行定义.

成员函数说明

◆ GenerateStraightReversePath()

bool apollo::planning::ExtricateStage::GenerateStraightReversePath ( PathData *  path_data,
const common::TrajectoryPoint &  init_point 
)

在文件 extricate_stage.cc 第 148 行定义.

148 {
149 DiscretizedPath path;
150 std::vector<common::PathPoint> path_points;
151 static constexpr double kReversePathLength = 10.0;
152 static constexpr double kReversePathUnit = 0.5;
153 for (double s = 0; s <= kReversePathLength; s += kReversePathUnit) {
154 common::PathPoint point;
155 point.set_x(init_point.path_point().x() - s * std::cos(init_point.path_point().theta()));
156 point.set_y(init_point.path_point().y() - s * std::sin(init_point.path_point().theta()));
157 point.set_theta(init_point.path_point().theta());
158 point.set_s(s);
159 point.set_kappa(0.0);
160 point.set_dkappa(0.0);
161 point.set_ddkappa(0.0);
162 path.emplace_back(point);
163 }
164 path_data->SetDiscretizedPath(path);
165 path_data->set_path_label("reverse_straight_path");
166 path_data->set_is_reverse_path(true);
167 return true;
168}

◆ HasCollision()

bool apollo::planning::ExtricateStage::HasCollision ( Frame *  frame,
const common::math::Box2d &  adc_box 
)

在文件 extricate_stage.cc 第 137 行定义.

137 {
138 auto obstacles_by_frame = frame->GetObstacleList();
139 common::math::Polygon2d adc_polygon(adc_box);
140 for (const auto& obstacle : obstacles_by_frame->Items()) {
141 if (adc_polygon.HasOverlap(obstacle->PerceptionPolygon())) {
142 return true;
143 }
144 }
145 return false;
146}

◆ Init()

bool apollo::planning::ExtricateStage::Init ( const StagePipeline &  config,
const std::shared_ptr< DependencyInjector > &  injector,
const std::string &  config_dir,
void *  context 
)
virtual

重载 apollo::planning::Stage .

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

40 {
41 CHECK_NOTNULL(context);
42 bool ret = Stage::Init(config, injector, config_dir, context);
43 if (!ret) {
44 AERROR << Name() << "init failed!";
45 return false;
46 }
47 scenario_config_.CopyFrom(GetContextAs<SquareContext>()->scenario_config);
48 return ret;
49}
virtual bool Init(const StagePipeline &config, const std::shared_ptr< DependencyInjector > &injector, const std::string &config_dir, void *context)
Definition stage.cc:43
const std::string & Name() const
Definition stage.cc:99
#define AERROR
Definition log.h:44

◆ Process()

StageResult apollo::planning::ExtricateStage::Process ( const common::TrajectoryPoint &  planning_init_point,
Frame *  frame 
)
overridevirtual

Each stage does its business logic inside Process function.

If the stage want to transit to a different stage after finish, it should set the type of 'next_stage_'.

实现了 apollo::planning::Stage.

在文件 extricate_stage.cc 第 51 行定义.

51 {
52 AINFO << "In ExtricateStage";
53 apollo::common::VehicleState vehicle_state = injector_->vehicle_state()->vehicle_state();
54 if (vehicle_state.gear() != canbus::Chassis::GEAR_REVERSE) {
55 frame->mutable_open_space_info()->set_is_on_open_space_trajectory(true);
56 auto* traj_pair = frame->mutable_open_space_info()->mutable_publishable_trajectory_data();
57 static constexpr double gear_shift_max_t = 5.0;
58 static constexpr double gear_shift_unit_t = 0.1;
59 for (double t = 0.0; t < gear_shift_max_t; t += gear_shift_unit_t) {
60 TrajectoryPoint point;
61 point.mutable_path_point()->set_x(frame->vehicle_state().x());
62 point.mutable_path_point()->set_y(frame->vehicle_state().y());
63 point.mutable_path_point()->set_theta(frame->vehicle_state().heading());
64 point.mutable_path_point()->set_s(0.0);
65 point.mutable_path_point()->set_kappa(0);
66 point.set_relative_time(t);
67 point.set_v(0.0);
68 point.set_a(0.0);
69 traj_pair->first.emplace_back(point);
70 }
71 traj_pair->second = apollo::canbus::Chassis::GEAR_REVERSE;
72 AINFO << "GENERATE REVERSE TRAJECTORY";
73 need_to_stop_ = false;
74 return StageResult(StageStatusType::RUNNING);
75 }
76 AINFO << "gear is reverse";
77 auto& reference_line_info = frame->mutable_reference_line_info()->back();
78 const auto& reference_line = reference_line_info.reference_line();
79 double adc_start_s = reference_line_info.AdcSlBoundary().start_s();
80 // GenerateStraightReversePath(reference_line_info.mutable_path_data(),
81 // planning_init_point);
82 if (stop_point_ == nullptr) {
84 auto ref_point = reference_line.GetReferencePoint(adc_start_s - 10.0);
85 stop_point_ = std::make_shared<common::PathPoint>(ref_point.ToPathPoint(0.0));
86 }
87 AINFO << "need to stop";
88 common::SLPoint sl_point;
89 reference_line.XYToSL(*stop_point_, &sl_point);
90 std::vector<std::string> wait_for_obstacles;
92 "reverse_stop",
93 sl_point.s(),
94 0.1,
95 StopReasonCode::STOP_REASON_STOP_SIGN,
96 wait_for_obstacles,
97 "reverse stop",
98 frame,
99 &(frame->mutable_reference_line_info()->front()));
100 StageResult result = ExecuteTaskOnReferenceLine(planning_init_point, frame);
101 const auto& candidate_paths = reference_line_info.GetCandidatePathData();
102 bool has_regular_path = false;
103 for (const auto& path_data : candidate_paths) {
104 if (path_data.path_label().find("regular") != std::string::npos && path_data.blocking_obstacle_id().empty()) {
105 AINFO << "find regular path: " << path_data.path_label();
106 has_regular_path = true;
107 break;
108 }
109 }
110 if (has_regular_path) {
111 success_path_times_++;
112 } else {
113 success_path_times_ = 0;
114 need_to_stop_ = false;
115 }
116 if (success_path_times_ > 10 && !need_to_stop_) {
117 AINFO << "find square path change stage";
118 need_to_stop_ = true;
119 *stop_point_ = reference_line_info.mutable_path_data()->discretized_path().Evaluate(5.0);
120 AINFO << "stop_point_:" << stop_point_->x() << "," << stop_point_->y();
121 }
122 if (success_path_times_ > 10 && std::fabs(vehicle_state.linear_velocity()) < 0.1) {
123 AINFO << "already stopped change stage" << vehicle_state.linear_velocity() << " " << vehicle_state.x() << ", "
124 << vehicle_state.y();
125 return FinishStage();
126 }
127 return result.SetStageStatus(StageStatusType::RUNNING);
128}
Implements a class of 2-dimensional vectors.
Definition vec2d.h:42
std::shared_ptr< DependencyInjector > injector_
Definition stage.h:91
StageResult ExecuteTaskOnReferenceLine(const common::TrajectoryPoint &planning_start_point, Frame *frame)
Definition stage.cc:101
#define AINFO
Definition log.h:42
int BuildStopDecision(const std::string &stop_wall_id, const double stop_line_s, const double stop_distance, const StopReasonCode &stop_reason_code, const std::vector< std::string > &wait_for_obstacles, const std::string &decision_tag, Frame *const frame, ReferenceLineInfo *const reference_line_info, double stop_wall_width)
Definition common.cc:28
optional apollo::canbus::Chassis::GearPosition gear

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