Apollo 10.0
自动驾驶开放平台
apollo::routing::Navigator类 参考

#include <navigator.h>

apollo::routing::Navigator 的协作图:

Public 成员函数

 Navigator (const std::string &topo_file_path)
 
 ~Navigator ()
 
bool IsReady () const
 
bool SearchRoute (const routing::RoutingRequest &request, routing::RoutingResponse *const response)
 

详细描述

在文件 navigator.h29 行定义.

构造及析构函数说明

◆ Navigator()

apollo::routing::Navigator::Navigator ( const std::string &  topo_file_path)
explicit

在文件 navigator.cc97 行定义.

97 {
98 Graph graph;
99 if (!cyber::common::GetProtoFromFile(topo_file_path, &graph)) {
100 AERROR << "Failed to read topology graph from " << topo_file_path;
101 return;
102 }
103
104 graph_.reset(new TopoGraph());
105 if (!graph_->LoadGraph(graph)) {
106 AINFO << "Failed to init navigator graph failed! File path: "
107 << topo_file_path;
108 return;
109 }
110 black_list_generator_.reset(new BlackListRangeGenerator);
111 result_generator_.reset(new ResultGenerator);
112 is_ready_ = true;
113 AINFO << "The navigator is ready.";
114}
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
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

◆ ~Navigator()

apollo::routing::Navigator::~Navigator ( )

在文件 navigator.cc116 行定义.

116{}

成员函数说明

◆ IsReady()

bool apollo::routing::Navigator::IsReady ( ) const

在文件 navigator.cc118 行定义.

118{ return is_ready_; }

◆ SearchRoute()

bool apollo::routing::Navigator::SearchRoute ( const routing::RoutingRequest request,
routing::RoutingResponse *const  response 
)

在文件 navigator.cc206 行定义.

207 {
208 if (!ShowRequestInfo(request, graph_.get())) {
209 SetErrorCode(ErrorCode::ROUTING_ERROR_REQUEST,
210 "Error encountered when reading request point!",
211 response->mutable_status());
212 return false;
213 }
214
215 if (!IsReady()) {
216 SetErrorCode(ErrorCode::ROUTING_ERROR_NOT_READY, "Navigator is not ready!",
217 response->mutable_status());
218 return false;
219 }
220 std::vector<const TopoNode*> way_nodes;
221 std::vector<double> way_s;
222 if (!Init(request, graph_.get(), &way_nodes, &way_s)) {
223 SetErrorCode(ErrorCode::ROUTING_ERROR_NOT_READY,
224 "Failed to initialize navigator!", response->mutable_status());
225 return false;
226 }
227
228 std::vector<NodeWithRange> result_nodes;
229 if (!SearchRouteByStrategy(graph_.get(), way_nodes, way_s, &result_nodes)) {
230 SetErrorCode(ErrorCode::ROUTING_ERROR_RESPONSE,
231 "Failed to find route with request!",
232 response->mutable_status());
233 return false;
234 }
235 if (result_nodes.empty()) {
236 SetErrorCode(ErrorCode::ROUTING_ERROR_RESPONSE, "Failed to result nodes!",
237 response->mutable_status());
238 return false;
239 }
240 result_nodes.front().SetStartS(request.waypoint().begin()->s());
241 result_nodes.back().SetEndS(request.waypoint().rbegin()->s());
242
243 if (!result_generator_->GeneratePassageRegion(
244 graph_->MapVersion(), request, result_nodes, topo_range_manager_,
245 response)) {
246 SetErrorCode(ErrorCode::ROUTING_ERROR_RESPONSE,
247 "Failed to generate passage regions based on result lanes",
248 response->mutable_status());
249 return false;
250 }
251 SetErrorCode(ErrorCode::OK, "Success!", response->mutable_status());
252
253 PrintDebugData(result_nodes);
254 return true;
255}

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