Apollo 10.0
自动驾驶开放平台
apollo::planning::ReferenceLineProvider类 参考

The class of ReferenceLineProvider. 更多...

#include <reference_line_provider.h>

apollo::planning::ReferenceLineProvider 的协作图:

Public 成员函数

 ReferenceLineProvider ()=default
 
 ReferenceLineProvider (const common::VehicleStateProvider *vehicle_state_provider, const ReferenceLineConfig *reference_line_config, const std::shared_ptr< relative_map::MapMsg > &relative_map=nullptr)
 
 ~ReferenceLineProvider ()
 Default destructor.
 
bool UpdatePlanningCommand (const planning::PlanningCommand &command)
 Update when new PlanningCommand is received.
 
void UpdateVehicleState (const common::VehicleState &vehicle_state)
 
bool Start ()
 
void Stop ()
 
void Reset ()
 
bool GetReferenceLines (std::list< ReferenceLine > *reference_lines, std::list< hdmap::RouteSegments > *segments)
 
double LastTimeDelay ()
 
std::vector< routing::LaneWaypointFutureRouteWaypoints ()
 
bool UpdatedReferenceLine ()
 
void GetEndLaneWayPoint (std::shared_ptr< routing::LaneWaypoint > &end_point) const
 
hdmap::LaneInfoConstPtr GetLaneById (const hdmap::Id &id) const
 
bool GetAdcWaypoint (hdmap::LaneWaypoint *waypoint) const
 
bool GetAdcDis2Destination (double *dis) const
 

详细描述

The class of ReferenceLineProvider.

It provides smoothed reference line to planning.

在文件 reference_line_provider.h61 行定义.

构造及析构函数说明

◆ ReferenceLineProvider() [1/2]

apollo::planning::ReferenceLineProvider::ReferenceLineProvider ( )
default

◆ ReferenceLineProvider() [2/2]

apollo::planning::ReferenceLineProvider::ReferenceLineProvider ( const common::VehicleStateProvider vehicle_state_provider,
const ReferenceLineConfig reference_line_config,
const std::shared_ptr< relative_map::MapMsg > &  relative_map = nullptr 
)

在文件 reference_line_provider.cc60 行定义.

64 : vehicle_state_provider_(vehicle_state_provider) {
65 current_pnc_map_ = nullptr;
66 if (!FLAGS_use_navigation_mode) {
67 relative_map_ = nullptr;
68 } else {
69 relative_map_ = relative_map;
70 }
71
72 ACHECK(cyber::common::GetProtoFromFile(FLAGS_smoother_config_filename,
73 &smoother_config_))
74 << "Failed to load smoother config file "
75 << FLAGS_smoother_config_filename;
76 if (smoother_config_.has_qp_spline()) {
77 smoother_.reset(new QpSplineReferenceLineSmoother(smoother_config_));
78 } else if (smoother_config_.has_spiral()) {
79 smoother_.reset(new SpiralReferenceLineSmoother(smoother_config_));
80 } else if (smoother_config_.has_discrete_points()) {
81 smoother_.reset(new DiscretePointsReferenceLineSmoother(smoother_config_));
82 } else {
83 ACHECK(false) << "unknown smoother config "
84 << smoother_config_.DebugString();
85 }
86 // Load pnc map plugins.
87 pnc_map_list_.clear();
88 // Set "apollo::planning::LaneFollowMap" as default if pnc_map_class is empty.
89 if (nullptr == reference_line_config ||
90 reference_line_config->pnc_map_class().empty()) {
91 const auto &pnc_map =
93 ->CreateInstance<planning::PncMapBase>(
94 "apollo::planning::LaneFollowMap");
95 pnc_map_list_.emplace_back(pnc_map);
96 } else {
97 const auto &pnc_map_names = reference_line_config->pnc_map_class();
98 for (const auto &map_name : pnc_map_names) {
99 const auto &pnc_map =
101 ->CreateInstance<planning::PncMapBase>(map_name);
102 pnc_map_list_.emplace_back(pnc_map);
103 }
104 }
105
106 is_initialized_ = true;
107}
static PluginManager * Instance()
get singleton instance of PluginManager
std::shared_ptr< Base > CreateInstance(const std::string &derived_class)
create plugin instance of derived class based on Base
#define ACHECK(cond)
Definition log.h:80
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132

◆ ~ReferenceLineProvider()

apollo::planning::ReferenceLineProvider::~ReferenceLineProvider ( )

Default destructor.

在文件 reference_line_provider.cc58 行定义.

58{}

成员函数说明

◆ FutureRouteWaypoints()

std::vector< routing::LaneWaypoint > apollo::planning::ReferenceLineProvider::FutureRouteWaypoints ( )

在文件 reference_line_provider.cc145 行定义.

145 {
146 if (!FLAGS_use_navigation_mode && nullptr != current_pnc_map_) {
147 std::lock_guard<std::mutex> lock(pnc_map_mutex_);
148 return current_pnc_map_->FutureRouteWaypoints();
149 }
150
151 // return an empty routing::LaneWaypoint vector in Navigation mode.
152 return std::vector<routing::LaneWaypoint>();
153}

◆ GetAdcDis2Destination()

bool apollo::planning::ReferenceLineProvider::GetAdcDis2Destination ( double *  dis) const

在文件 reference_line_provider.cc1042 行定义.

1042 {
1043 if (nullptr == current_pnc_map_) {
1044 AERROR << "Cannot find pnc map to get adc distance to destination!";
1045 return false;
1046 }
1047 *dis = current_pnc_map_->GetDistanceToDestination();
1048 return true;
1049}
#define AERROR
Definition log.h:44

◆ GetAdcWaypoint()

bool apollo::planning::ReferenceLineProvider::GetAdcWaypoint ( hdmap::LaneWaypoint waypoint) const

在文件 reference_line_provider.cc1032 行定义.

1033 {
1034 if (nullptr == current_pnc_map_) {
1035 AERROR << "Cannot find pnc map to get adc waypoint!";
1036 return false;
1037 }
1038 *waypoint = current_pnc_map_->GetAdcWaypoint();
1039 return true;
1040}

◆ GetEndLaneWayPoint()

void apollo::planning::ReferenceLineProvider::GetEndLaneWayPoint ( std::shared_ptr< routing::LaneWaypoint > &  end_point) const

在文件 reference_line_provider.cc155 行定义.

156 {
157 if (nullptr == current_pnc_map_) {
158 end_point = nullptr;
159 return;
160 }
161 current_pnc_map_->GetEndLaneWayPoint(end_point);
162}

◆ GetLaneById()

hdmap::LaneInfoConstPtr apollo::planning::ReferenceLineProvider::GetLaneById ( const hdmap::Id id) const

在文件 reference_line_provider.cc164 行定义.

165 {
166 if (nullptr == current_pnc_map_) {
167 return nullptr;
168 }
169 return current_pnc_map_->GetLaneById(id);
170}

◆ GetReferenceLines()

bool apollo::planning::ReferenceLineProvider::GetReferenceLines ( std::list< ReferenceLine > *  reference_lines,
std::list< hdmap::RouteSegments > *  segments 
)

在文件 reference_line_provider.cc300 行定义.

302 {
303 CHECK_NOTNULL(reference_lines);
304 CHECK_NOTNULL(segments);
305 if (!has_planning_command_) {
306 return true;
307 }
308 if (FLAGS_use_navigation_mode) {
309 double start_time = Clock::NowInSeconds();
310 bool result = GetReferenceLinesFromRelativeMap(reference_lines, segments);
311 if (!result) {
312 AERROR << "Failed to get reference line from relative map";
313 }
314 double end_time = Clock::NowInSeconds();
315 last_calculation_time_ = end_time - start_time;
316 return result;
317 }
318
319 if (FLAGS_enable_reference_line_provider_thread) {
320 std::lock_guard<std::mutex> lock(reference_lines_mutex_);
321 if (!reference_lines_.empty()) {
322 reference_lines->assign(reference_lines_.begin(), reference_lines_.end());
323 segments->assign(route_segments_.begin(), route_segments_.end());
324 return true;
325 }
326 } else {
327 double start_time = Clock::NowInSeconds();
328 if (CreateReferenceLine(reference_lines, segments)) {
329 UpdateReferenceLine(*reference_lines, *segments);
330 double end_time = Clock::NowInSeconds();
331 last_calculation_time_ = end_time - start_time;
332 return true;
333 }
334 }
335
336 AINFO << "Reference line is NOT ready.";
337 if (reference_line_history_.empty()) {
338 AINFO << "Failed to use reference line latest history";
339 return false;
340 }
341
342 reference_lines->assign(reference_line_history_.back().begin(),
343 reference_line_history_.back().end());
344 segments->assign(route_segments_history_.back().begin(),
345 route_segments_history_.back().end());
346 AWARN << "Use reference line from history!";
347 return true;
348}
static double NowInSeconds()
gets the current time in second.
Definition clock.cc:56
#define AINFO
Definition log.h:42
#define AWARN
Definition log.h:43

◆ LastTimeDelay()

double apollo::planning::ReferenceLineProvider::LastTimeDelay ( )

在文件 reference_line_provider.cc290 行定义.

290 {
291 if (FLAGS_enable_reference_line_provider_thread &&
292 !FLAGS_use_navigation_mode) {
293 std::lock_guard<std::mutex> lock(reference_lines_mutex_);
294 return last_calculation_time_;
295 } else {
296 return last_calculation_time_;
297 }
298}

◆ Reset()

void apollo::planning::ReferenceLineProvider::Reset ( )

在文件 reference_line_provider.cc200 行定义.

200 {
201 std::lock_guard<std::mutex> lock(routing_mutex_);
202 has_planning_command_ = false;
203 is_new_command_ = false;
204 reference_lines_.clear();
205 route_segments_.clear();
206 is_reference_line_updated_ = false;
207 planning_command_.Clear();
208 while (!reference_line_history_.empty()) {
209 reference_line_history_.pop();
210 }
211}

◆ Start()

bool apollo::planning::ReferenceLineProvider::Start ( )

在文件 reference_line_provider.cc178 行定义.

178 {
179 if (FLAGS_use_navigation_mode) {
180 return true;
181 }
182 if (!is_initialized_) {
183 AERROR << "ReferenceLineProvider has NOT been initiated.";
184 return false;
185 }
186
187 if (FLAGS_enable_reference_line_provider_thread) {
188 task_future_ = cyber::Async(&ReferenceLineProvider::GenerateThread, this);
189 }
190 return true;
191}

◆ Stop()

void apollo::planning::ReferenceLineProvider::Stop ( )

在文件 reference_line_provider.cc193 行定义.

193 {
194 is_stop_ = true;
195 if (FLAGS_enable_reference_line_provider_thread) {
196 task_future_.get();
197 }
198}

◆ UpdatedReferenceLine()

bool apollo::planning::ReferenceLineProvider::UpdatedReferenceLine ( )
inline

在文件 reference_line_provider.h97 行定义.

97{ return is_reference_line_updated_.load(); }

◆ UpdatePlanningCommand()

bool apollo::planning::ReferenceLineProvider::UpdatePlanningCommand ( const planning::PlanningCommand command)

Update when new PlanningCommand is received.

参数
commandNew PlanningCommand.
返回
True if no error occurs.

在文件 reference_line_provider.cc109 行定义.

110 {
111 std::lock_guard<std::mutex> routing_lock(routing_mutex_);
112 bool find_matched_pnc_map = false;
113 for (const auto &pnc_map : pnc_map_list_) {
114 if (pnc_map->CanProcess(command)) {
115 current_pnc_map_ = pnc_map;
116 find_matched_pnc_map = true;
117 break;
118 }
119 }
120 if (nullptr == current_pnc_map_) {
121 AERROR << "Cannot find pnc map to process input command!"
122 << command.DebugString();
123 return false;
124 }
125 if (!find_matched_pnc_map) {
126 AWARN << "Find no pnc map for the input command and the old one will be "
127 "used!";
128 }
129 // Update routing in pnc_map
130 std::lock_guard<std::mutex> lock(pnc_map_mutex_);
131 if (current_pnc_map_->IsNewPlanningCommand(command)) {
132 is_new_command_ = true;
133 if (!current_pnc_map_->UpdatePlanningCommand(command)) {
134 AERROR << "Failed to update routing in pnc map: "
135 << command.DebugString();
136 return false;
137 }
138 }
139 planning_command_ = command;
140 has_planning_command_ = true;
141 return true;
142}

◆ UpdateVehicleState()

void apollo::planning::ReferenceLineProvider::UpdateVehicleState ( const common::VehicleState vehicle_state)

在文件 reference_line_provider.cc172 行定义.

173 {
174 std::lock_guard<std::mutex> lock(vehicle_state_mutex_);
175 vehicle_state_ = vehicle_state;
176}

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