28namespace external_command {
30bool ValetParkingCommandProcessor::Convert(
31 const std::shared_ptr<ValetParkingCommand>& command,
32 std::shared_ptr<apollo::routing::RoutingRequest>& routing_request)
const {
33 routing_request = std::make_shared<apollo::routing::RoutingRequest>();
34 if (!command->is_start_pose_set()) {
39 routing_request->set_is_start_pose_set(
true);
42 std::string parking_id = command->parking_spot_id();
44 for (
const auto& way_point : command->way_point()) {
45 if (!lane_way_tool->ConvertToLaneWayPoint(
46 way_point, routing_request->add_waypoint())) {
47 AERROR <<
"Cannot convert the end pose to lane way point: "
48 << way_point.DebugString();
52 std::vector<apollo::routing::LaneWaypoint> lane_way_points;
53 lane_way_tool->GetParkingLaneWayPoint(parking_id, &lane_way_points);
55 double min_distance = std::numeric_limits<double>::max();
56 for (
const auto& lane_way_point : lane_way_points) {
57 auto tmp_routing_request =
58 std::make_shared<apollo::routing::RoutingRequest>();
59 tmp_routing_request->CopyFrom(*routing_request);
60 tmp_routing_request->add_waypoint()->CopyFrom(lane_way_point);
61 auto routing_response =
62 std::make_shared<apollo::routing::RoutingResponse>();
63 if (!
routing_->Process(tmp_routing_request, routing_response.get())) {
66 AINFO << routing_response->DebugString();
67 if (routing_response->measurement().distance() < min_distance) {
68 min_distance = routing_response->measurement().distance();
69 best_lane_way_point.Clear();
70 best_lane_way_point.CopyFrom(lane_way_point);
73 if (min_distance >= std::numeric_limits<double>::max()) {
74 AERROR <<
"can not find any valid lane waypoint near parking space";
77 routing_request->add_waypoint()->CopyFrom(best_lane_way_point);
81bool ValetParkingCommandProcessor::ProcessSpecialCommand(
82 const std::shared_ptr<ValetParkingCommand>& command,
83 const std::shared_ptr<apollo::planning::PlanningCommand>& planning_command)
85 auto parking_command = planning_command->mutable_parking_command();
86 parking_command->set_parking_spot_id(command->parking_spot_id());
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_