29namespace external_command {
31bool PreciseParkingCommandProcessor::Convert(
32 const std::shared_ptr<PreciseParkingCommand>& command,
33 std::shared_ptr<apollo::routing::RoutingRequest>& routing_request)
const {
34 routing_request = std::make_shared<apollo::routing::RoutingRequest>();
35 if (!command->is_start_pose_set()) {
40 routing_request->set_is_start_pose_set(
true);
43 std::vector<hdmap::AreaInfoConstPtr> areas;
44 common::PointENU point;
45 point.set_x(command->parking_spot_pose().x());
46 point.set_y(command->parking_spot_pose().y());
48 AERROR <<
"can not find any junction near parking spot";
51 std::vector<apollo::routing::LaneWaypoint> lane_way_points;
52 lane_way_tool->GetPreciseParkingLaneWayPoint(areas.front(), &lane_way_points);
54 double min_distance = std::numeric_limits<double>::max();
55 for (
const auto& lane_way_point : lane_way_points) {
56 auto tmp_routing_request = std::make_shared<apollo::routing::RoutingRequest>();
57 tmp_routing_request->CopyFrom(*routing_request);
58 tmp_routing_request->add_waypoint()->CopyFrom(lane_way_point);
59 auto routing_response = std::make_shared<apollo::routing::RoutingResponse>();
60 if (!
routing_->Process(tmp_routing_request, routing_response.get())) {
63 AINFO << routing_response->DebugString();
64 if (routing_response->measurement().distance() < min_distance) {
65 min_distance = routing_response->measurement().distance();
66 best_lane_way_point.Clear();
67 best_lane_way_point.CopyFrom(lane_way_point);
70 if (min_distance >= std::numeric_limits<double>::max()) {
71 AERROR <<
"can not find any valid lane waypoint near parking space";
74 routing_request->add_waypoint()->CopyFrom(best_lane_way_point);
78bool PreciseParkingCommandProcessor::ProcessSpecialCommand(
79 const std::shared_ptr<PreciseParkingCommand>& command,
80 const std::shared_ptr<apollo::planning::PlanningCommand>& planning_command)
const {
81 auto custom_command = planning_command->mutable_custom_command();
82 custom_command->PackFrom(*command);
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_
static const HDMap * BaseMapPtr()