37 const std::string& name) {
47 if (!Scenario::LoadConfig<ScenarioValetParkingConfig>(
49 AERROR <<
"fail to get config of scenario" <<
Name();
53 CHECK_NOTNULL(hdmap_);
67 std::string target_parking_spot_id;
71 .has_parking_spot_id()) {
76 ADEBUG <<
"No parking space id from routing";
80 if (target_parking_spot_id.empty()) {
84 const auto& nearby_path =
89 if (!SearchTargetParkingSpotOnPath(nearby_path, target_parking_spot_id,
90 &parking_space_overlap)) {
91 ADEBUG <<
"No such parking spot found after searching all path forward "
93 << target_parking_spot_id;
96 double parking_spot_range_to_start =
98 if (!CheckDistanceToParkingSpot(frame, vehicle_state, nearby_path,
99 parking_spot_range_to_start,
100 parking_space_overlap)) {
101 ADEBUG <<
"target parking spot found, but too far, distance larger than "
102 "pre-defined distance"
103 << target_parking_spot_id;
110bool ValetParkingScenario::SearchTargetParkingSpotOnPath(
111 const Path& nearby_path,
const std::string& target_parking_id,
114 for (
const auto& parking_overlap : parking_space_overlaps) {
115 if (parking_overlap.object_id == target_parking_id) {
116 *parking_space_overlap = parking_overlap;
123bool ValetParkingScenario::CheckDistanceToParkingSpot(
124 const Frame& frame,
const VehicleState& vehicle_state,
125 const Path& nearby_path,
const double parking_start_range,
126 const PathOverlap& parking_space_overlap) {
130 double center_point_s, center_point_l;
131 id.set_id(parking_space_overlap.object_id);
133 hdmap->GetParkingSpaceById(
id);
134 Vec2d left_bottom_point = target_parking_spot_ptr->polygon().points().at(0);
135 Vec2d right_bottom_point = target_parking_spot_ptr->polygon().points().at(1);
136 Vec2d right_top_point = target_parking_spot_ptr->polygon().points().at(2);
137 Vec2d left_top_point = target_parking_spot_ptr->polygon().points().at(3);
138 Vec2d center_point = (left_bottom_point + right_bottom_point +
139 right_top_point + left_top_point) /
141 nearby_path.GetNearestPoint(center_point, ¢er_point_s, ¢er_point_l);
142 double vehicle_point_s = 0.0;
143 double vehicle_point_l = 0.0;
144 Vec2d vehicle_vec(vehicle_state.x(), vehicle_state.y());
145 nearby_path.GetNearestPoint(vehicle_vec, &vehicle_point_s, &vehicle_point_l);
146 if (std::abs(center_point_s - vehicle_point_s) < parking_start_range) {
Implements a class of 2-dimensional vectors.
static const HDMap * BaseMapPtr()
const std::vector< PathOverlap > & parking_space_overlaps() const
Frame holds all data for one planning cycle.
const LocalView & local_view() const
const common::VehicleState & vehicle_state() const
const std::list< ReferenceLineInfo > & reference_line_info() const
virtual bool Init(std::shared_ptr< DependencyInjector > injector, const std::string &name)
const std::string & Name() const
bool IsTransferable(const Scenario *const other_scenario, const Frame &frame) override
Each scenario should define its own transfer condition, i.e., when it should allow to transfer from o...
bool Init(std::shared_ptr< DependencyInjector > injector, const std::string &name) override
Planning module main class.
std::shared_ptr< const ParkingSpaceInfo > ParkingSpaceInfoConstPtr
std::shared_ptr< PlanningCommand > planning_command
optional double parking_spot_range_to_start
ScenarioValetParkingConfig scenario_config
std::string target_parking_spot_id