24namespace external_command {
26bool ZoneCoverCommandProcessor::Convert(
27 const std::shared_ptr<ZoneCoverCommand>& command,
28 std::shared_ptr<apollo::routing::RoutingRequest>& routing_request)
const {
29 routing_request = std::make_shared<apollo::routing::RoutingRequest>();
30 if (!command->is_start_pose_set()) {
35 routing_request->set_is_start_pose_set(
true);
38 const auto zone_cover_area_id = command->zone_cover_area_id();
39 if (zone_cover_area_id.empty()) {
40 AERROR <<
"zone_cover_area_id is empty, error";
46 if (
nullptr == zone_cover_area) {
47 AERROR <<
"can not find zone_cover_area: " << zone_cover_area_id;
51 std::vector<apollo::routing::LaneWaypoint> lane_way_points;
52 lane_way_tool->GetPreciseParkingLaneWayPoint(zone_cover_area, &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 ZoneCoverCommandProcessor::ProcessSpecialCommand(
79 const std::shared_ptr<ZoneCoverCommand>& 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()
AreaInfoConstPtr GetAreaById(const Id &id) const
apollo::hdmap::Id MakeMapId(const std::string &id)
create a Map ID given a string.
std::shared_ptr< const AreaInfo > AreaInfoConstPtr