28namespace external_command {
30bool LaneFollowCommandProcessor::ProcessSpecialCommand(
31 const std::shared_ptr<LaneFollowCommand>& command,
32 const std::shared_ptr<apollo::planning::PlanningCommand>& planning_command)
37bool LaneFollowCommandProcessor::Convert(
38 const std::shared_ptr<LaneFollowCommand>& command,
39 std::shared_ptr<apollo::routing::RoutingRequest>& routing_request)
const {
40 routing_request = std::make_shared<apollo::routing::RoutingRequest>();
41 std::vector<apollo::routing::LaneWaypoint> lane_way_points;
43 if (!command->is_start_pose_set()) {
44 if (lane_way_tool->IsParkandgoScenario()) {
45 AINFO <<
"adc is outside road, in park and go scenario";
50 double min_distance = std::numeric_limits<double>::max();
51 AINFO <<
"lane_way_points.size()" << lane_way_points.size();
52 for (
const auto& lane_way_point : lane_way_points) {
53 auto tmp_routing_request =
54 std::make_shared<apollo::routing::RoutingRequest>();
55 tmp_routing_request->CopyFrom(*routing_request);
56 tmp_routing_request->add_waypoint()->CopyFrom(lane_way_point);
57 for (
const auto& way_point : command->way_point()) {
58 if (!lane_way_tool->ConvertToLaneWayPoint(
59 way_point, tmp_routing_request->add_waypoint())) {
60 AINFO <<
"Cannot convert the end pose to lane way point: "
61 << way_point.DebugString();
65 if (!lane_way_tool->ConvertToLaneWayPoint(
66 command->end_pose(), tmp_routing_request->add_waypoint())) {
67 AERROR <<
"Cannot convert the end pose to lane way point: "
68 << command->end_pose().DebugString();
71 auto routing_response =
72 std::make_shared<apollo::routing::RoutingResponse>();
73 if (!
routing_->Process(tmp_routing_request, routing_response.get())) {
74 AINFO <<
"routing_ error " << tmp_routing_request->DebugString();
77 AINFO << routing_response->DebugString();
78 if (routing_response->measurement().distance() < min_distance) {
79 min_distance = routing_response->measurement().distance();
80 best_lane_way_point.Clear();
81 best_lane_way_point.CopyFrom(lane_way_point);
84 if (min_distance >= std::numeric_limits<double>::max()) {
85 AINFO <<
"can not find any valid lane waypoint near parking space";
88 routing_request->add_waypoint()->CopyFrom(best_lane_way_point);
95 routing_request->set_is_start_pose_set(
true);
98 for (
const auto& way_point : command->way_point()) {
99 if (!lane_way_tool->ConvertToLaneWayPoint(
100 way_point, routing_request->add_waypoint())) {
101 AERROR <<
"Cannot convert the end pose to lane way point: "
102 << way_point.DebugString();
107 if (!lane_way_tool->ConvertToLaneWayPoint(command->end_pose(),
108 routing_request->add_waypoint())) {
109 AERROR <<
"Cannot convert the end pose to lane way point: "
110 << command->end_pose().DebugString();
bool SetStartPose(std::vector< apollo::routing::LaneWaypoint > *lane_way_points) const
Set the start pose of lane_way_points with current vehicle pose.
const std::shared_ptr< apollo::external_command::LaneWayTool > & GetLaneWayTool() const
std::shared_ptr< apollo::routing::Routing > routing_