Process the incoming lane follow command.
Search the routing to end point and send to planning module.
208 {
209 CHECK_NOTNULL(command);
210 CHECK_NOTNULL(status);
211 if (command->has_header()) {
213 AINFO << std::setprecision(12) <<
"timestamp: " <<
timestamp <<
" "
214 << "request for " << command->header().timestamp_sec();
215 if (timestamp - command->header().timestamp_sec() > 2.0) {
216 AINFO <<
"request for " << command->header().module_name()
217 << " has been timeouted";
218 return;
219 }
220 }
222 status->set_command_id(command->command_id());
223
224 std::shared_ptr<apollo::routing::RoutingRequest> routing_request = nullptr;
225 bool convert_result =
Convert(command, routing_request);
226 if (!convert_result) {
228 status->set_message("Cannot convert command to RoutingRequest: " +
229 command->DebugString());
230 return;
231 }
232
233 std::string module_name = "UNKNOWN";
234 if (command->has_header()) {
235 module_name = command->header().module_name();
236 }
237 std::lock_guard<std::mutex> guard(this->mutex_);
238 auto planning_command = std::make_shared<apollo::planning::PlanningCommand>();
239 common::util::FillHeader(module_name, planning_command.get());
240 if (nullptr != routing_request) {
241 AINFO <<
"Process routing: " << routing_request->DebugString();
242 auto routing_response =
243 std::make_shared<apollo::routing::RoutingResponse>();
244 if (!
routing_->Process(routing_request, routing_response.get())) {
246 status->set_message("Cannot get routing of command: " +
247 command->DebugString());
248 AERROR <<
"Routing process failed! ";
249 return;
250 }
251 planning_command->mutable_lane_follow_command()->CopyFrom(
252 *routing_response);
253
255 }
256
258 AERROR <<
"Process special command failed!";
259 return;
260 }
261 planning_command->set_command_id(command->command_id());
262
263 if (command->has_target_speed()) {
264 planning_command->set_target_speed(command->target_speed());
265 }
266 planning_command->set_is_motion_command(true);
267
269 AINFO <<
"publish: " << planning_command->DebugString();
271}
static double NowInSeconds()
gets the current time in second.
virtual bool Convert(const std::shared_ptr< T > &command, std::shared_ptr< apollo::routing::RoutingRequest > &routing_request) const =0
Convert moving command to RoutingRequest.
virtual bool ProcessSpecialCommand(const std::shared_ptr< T > &command, const std::shared_ptr< apollo::planning::PlanningCommand > &planning_command) const =0
Process special command except RoutingRequest.