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

NaviPlanner is a planner based on real-time relative maps. 更多...

#include <navi_planner.h>

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

Public 成员函数

virtual ~NaviPlanner ()=default
 
std::string Name () override
 
common::Status Init (const std::shared_ptr< DependencyInjector > &injector, const std::string &config_path="") override
 
common::Status Plan (const common::TrajectoryPoint &planning_init_point, Frame *frame, ADCTrajectory *ptr_computed_trajectory) override
 Override function Plan in parent class Planner.
 
void Stop () override
 
common::Status PlanOnReferenceLine (const common::TrajectoryPoint &planning_init_point, Frame *frame, ReferenceLineInfo *reference_line_info) override
 Override function Plan in parent class Planner.
 
- Public 成员函数 继承自 apollo::planning::PlannerWithReferenceLine
virtual ~PlannerWithReferenceLine ()=default
 Destructor
 
- Public 成员函数 继承自 apollo::planning::Planner
virtual ~Planner ()=default
 Destructor
 
virtual void Reset (Frame *frame)
 
template<typename T >
bool LoadConfig (const std::string &custom_config_path, T *config)
 

额外继承的成员函数

- Protected 属性 继承自 apollo::planning::Planner
std::shared_ptr< DependencyInjector > injector_ = nullptr
 

详细描述

NaviPlanner is a planner based on real-time relative maps.

It uses the vehicle's FLU (Front-Left-Up) coordinate system to accomplish tasks such as cruising, following, overtaking, nudging, changing lanes and stopping. Note that NaviPlanner is only used in navigation mode (turn on navigation mode by setting "FLAGS_use_navigation_mode" to "true") and do not use it in standard mode.

在文件 navi_planner.h 第 59 行定义.

构造及析构函数说明

◆ ~NaviPlanner()

virtual apollo::planning::NaviPlanner::~NaviPlanner ( )
virtualdefault

成员函数说明

◆ Init()

Status apollo::planning::NaviPlanner::Init ( const std::shared_ptr< DependencyInjector > &  injector,
const std::string &  config_path = "" 
)
overridevirtual

重载 apollo::planning::Planner .

在文件 navi_planner.cc 第 76 行定义.

77 {
78 Planner::Init(injector, config_path);
79 // NaviPlanner is only used in navigation mode based on the real-time relative
80 // map.
81 if (!FLAGS_use_navigation_mode) {
82 const std::string msg = "NaviPlanner is only used in navigation mode.";
83 AERROR << msg;
84 return Status(ErrorCode::PLANNING_ERROR, msg);
85 }
86
87 AINFO << "In NaviPlanner::Init()";
88 RegisterTasks();
89 PlannerNaviConfig planner_conf;
90 LoadConfig<PlannerNaviConfig>(config_path, &planner_conf);
91 for (const auto task : planner_conf.task()) {
92 tasks_.emplace_back(
93 task_factory_.CreateObject(static_cast<NaviTaskType>(task)));
94 AINFO << "Created task:" << tasks_.back()->Name();
95 }
96 for (auto& task : tasks_) {
97 if (!task->Init(planner_conf)) {
98 const std::string msg =
99 absl::StrCat("Init task[", task->Name(), "] failed.");
100 AERROR << msg;
101 return Status(ErrorCode::PLANNING_ERROR, msg);
102 }
103 }
104 return Status::OK();
105}
static Status OK()
generate a success status.
Definition status.h:60
virtual apollo::common::Status Init(const std::shared_ptr< DependencyInjector > &injector, const std::string &config_path="")
Definition planner.h:54
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42

◆ Name()

std::string apollo::planning::NaviPlanner::Name ( )
inlineoverridevirtual

实现了 apollo::planning::Planner.

在文件 navi_planner.h 第 63 行定义.

63{ return "NAVI"; }

◆ Plan()

Status apollo::planning::NaviPlanner::Plan ( const common::TrajectoryPoint &  planning_init_point,
Frame *  frame,
ADCTrajectory *  ptr_computed_trajectory 
)
overridevirtual

Override function Plan in parent class Planner.

参数
planning_init_pointThe trajectory point where planning starts.
frameCurrent planning frame.
返回
OK if planning succeeds; error otherwise.

实现了 apollo::planning::Planner.

在文件 navi_planner.cc 第 107 行定义.

108 {
109 // NaviPlanner is only used in navigation mode based on the real-time relative
110 // map.
111 if (!FLAGS_use_navigation_mode) {
112 const std::string msg = "NaviPlanner is only used in navigation mode.";
113 AERROR << msg;
114 return Status(ErrorCode::PLANNING_ERROR, msg);
115 }
116
117 size_t success_line_count = 0;
118 for (auto& reference_line_info : *frame->mutable_reference_line_info()) {
119 uint32_t priority = reference_line_info.GetPriority();
120 reference_line_info.SetCost(priority * kStraightForwardLineCost);
121 if (priority != KDestLanePriority) {
122 reference_line_info.SetDrivable(false);
123 continue;
124 }
125 auto status =
126 PlanOnReferenceLine(planning_init_point, frame, &reference_line_info);
127
128 if (status.ok() && reference_line_info.IsDrivable()) {
129 success_line_count += 1;
130 } else {
131 reference_line_info.SetDrivable(false);
132 AERROR << "Failed to plan on reference line "
133 << reference_line_info.Lanes().Id();
134 }
135 ADEBUG << "ref line info: " << reference_line_info.Lanes().Id()
136 << " priority : " << reference_line_info.GetPriority()
137 << " cost : " << reference_line_info.Cost()
138 << " driveable : " << reference_line_info.IsDrivable();
139 }
140
141 if (success_line_count > 0) {
142 return Status::OK();
143 }
144
145 return Status(ErrorCode::PLANNING_ERROR,
146 "Failed to plan on any reference line.");
147}
common::Status PlanOnReferenceLine(const common::TrajectoryPoint &planning_init_point, Frame *frame, ReferenceLineInfo *reference_line_info) override
Override function Plan in parent class Planner.
#define ADEBUG
Definition log.h:41

◆ PlanOnReferenceLine()

Status apollo::planning::NaviPlanner::PlanOnReferenceLine ( const common::TrajectoryPoint &  planning_init_point,
Frame *  frame,
ReferenceLineInfo *  reference_line_info 
)
overridevirtual

Override function Plan in parent class Planner.

参数
planning_init_pointThe trajectory point where planning starts.
frameCurrent planning frame.
reference_line_infoThe computed reference line.
返回
OK if planning succeeds; error otherwise.

重载 apollo::planning::PlannerWithReferenceLine .

在文件 navi_planner.cc 第 149 行定义.

151 {
152 if (!reference_line_info->IsChangeLanePath() &&
153 reference_line_info->IsNeighborLanePath()) {
154 reference_line_info->AddCost(kStraightForwardLineCost);
155 }
156 ADEBUG << "planning start point:" << planning_init_point.DebugString();
157 auto* heuristic_speed_data = reference_line_info->mutable_speed_data();
158 auto speed_profile =
159 GenerateInitSpeedProfile(planning_init_point, reference_line_info);
160 if (speed_profile.empty()) {
161 speed_profile = GenerateSpeedHotStart(planning_init_point);
162 ADEBUG << "Using dummy hot start for speed vector";
163 }
164 *heuristic_speed_data = SpeedData(speed_profile);
165
166 auto ret = Status::OK();
167
168 for (auto& task : tasks_) {
169 const double start_timestamp = Clock::NowInSeconds();
170 ret = task->Execute(frame, reference_line_info);
171 if (!ret.ok()) {
172 AERROR << "Failed to run tasks[" << task->Name()
173 << "], Error message: " << ret.error_message();
174 break;
175 }
176 const double end_timestamp = Clock::NowInSeconds();
177 const double time_diff_ms = (end_timestamp - start_timestamp) * 1000;
178
179 ADEBUG << "after task " << task->Name() << ":"
180 << reference_line_info->PathSpeedDebugString();
181 ADEBUG << task->Name() << " time spend: " << time_diff_ms << " ms.";
182
183 RecordDebugInfo(reference_line_info, task->Name(), time_diff_ms);
184 }
185
186 RecordObstacleDebugInfo(reference_line_info);
187
188 if (reference_line_info->path_data().Empty()) {
189 ADEBUG << "Path fallback.";
190 GenerateFallbackPathProfile(reference_line_info,
191 reference_line_info->mutable_path_data());
192 reference_line_info->AddCost(kPathOptimizationFallbackClost);
193 }
194
195 if (!ret.ok() || reference_line_info->speed_data().empty()) {
196 ADEBUG << "Speed fallback.";
197 GenerateFallbackSpeedProfile(reference_line_info->mutable_speed_data());
198 reference_line_info->AddCost(kSpeedOptimizationFallbackClost);
199 }
200
201 DiscretizedTrajectory trajectory;
202 if (!reference_line_info->CombinePathAndSpeedProfile(
203 planning_init_point.relative_time(),
204 planning_init_point.path_point().s(), &trajectory)) {
205 const std::string msg = "Fail to aggregate planning trajectory.";
206 AERROR << msg;
207 return Status(ErrorCode::PLANNING_ERROR, msg);
208 }
209
210 for (const auto* obstacle :
211 reference_line_info->path_decision()->obstacles().Items()) {
212 if (obstacle->IsVirtual()) {
213 continue;
214 }
215 if (!obstacle->IsStatic()) {
216 continue;
217 }
218 if (obstacle->LongitudinalDecision().has_stop()) {
219 static constexpr double kRefrenceLineStaticObsCost = 1e3;
220 reference_line_info->AddCost(kRefrenceLineStaticObsCost);
221 }
222 }
223
224 if (FLAGS_enable_trajectory_check) {
225 if (ConstraintChecker::ValidTrajectory(trajectory) !=
227 const std::string msg = "Current planning trajectory is not valid.";
228 AERROR << msg;
229 return Status(ErrorCode::PLANNING_ERROR, msg);
230 }
231 }
232
233 reference_line_info->SetTrajectory(trajectory);
234 reference_line_info->SetDrivable(true);
235 return Status::OK();
236}
static double NowInSeconds()
gets the current time in second.
Definition clock.cc:56
static Result ValidTrajectory(const DiscretizedTrajectory &trajectory)

◆ Stop()

void apollo::planning::NaviPlanner::Stop ( )
inlineoverridevirtual

实现了 apollo::planning::Planner.

在文件 navi_planner.h 第 78 行定义.

78{}

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