30 AINFO <<
"new version of stage parking park";
33 auto scenario_context = GetContextAs<ValetParkingContext>();
35 if (arrive_parking_spot_) {
36 AINFO <<
"Stage Parking finish";
41 scenario_config_ = scenario_context->scenario_config;
44 scenario_context->target_parking_spot_id;
47 AERROR <<
"StageParking planning error";
51 arrive_parking_spot_ =
true;
52 if (!CheckADCParkingCompleted(frame)) {
53 AINFO <<
"Stage Parking finish but do not reach parking spot,"
55 return FinishStage(frame);
58 AINFO <<
"Stage Parking finish";
69 mutable_optimizer_trajectory_data()->clear();
71 mutable_path_planning_trajectory_result()->clear();
73 mutable_interpolated_trajectory_result()->clear();
75 mutable_partitioned_trajectories()->clear();
77 mutable_chosen_partitioned_trajectory()->first.clear();
89bool StageParkingPark::CheckADCParkingCompleted(
Frame* frame) {
90 double ego_x =
injector_->vehicle_state()->x();
91 double ego_y =
injector_->vehicle_state()->y();
92 double ego_theta =
injector_->vehicle_state()->heading();
94 frame->open_space_info().origin_heading(),
95 frame->open_space_info().origin_point(),
96 &ego_x, &ego_y, &ego_theta);
97 const std::vector<double>& end_pose =
98 frame->open_space_info().open_space_end_pose();
99 double delta_theta = fabs(
103 double lat_error = park_unit_vec.
CrossProd(vec);
104 double lon_error = park_unit_vec.
InnerProd(vec);
105 AINFO <<
"lat error: " << lat_error <<
" "
106 <<
"lon error: " << lon_error <<
" "
107 <<
"delta_theta: " << delta_theta;
110 AINFO <<
"parallel parking no retry";
113 if (std::fabs(lat_error) < scenario_config_.
max_lat_error() &&
121bool StageParkingPark::CheckParkingMissionInfo(
const ValetParkingContext& planning_command) {
122 if (parking_mission_info_.
parking_spot_id != planning_command.target_parking_spot_id) {
123 parking_mission_info_.
parking_spot_id = planning_command.target_parking_spot_id;
129 }
else if (parking_mission_info_.
command_sequence_num != planning_command.command_sequence_num) {
140 AINFO <<
"Get same parking spot id from routing: " << parking_mission_info_.
parking_spot_id <<
"but status is DONE";
143 AINFO <<
"UNKNOW STATUS";
Implements a class of 2-dimensional vectors.
static Vec2d CreateUnitVec2d(const double angle)
Creates a unit-vector with a given angle to the positive x semi-axis
double InnerProd(const Vec2d &other) const
Returns the inner product between these two Vec2d.
double CrossProd(const Vec2d &other) const
Returns the "cross" product between these two Vec2d (non-standard).
Frame holds all data for one planning cycle.
const OpenSpaceInfo & open_space_info() const
OpenSpaceInfo * mutable_open_space_info()
std::string * mutable_target_parking_spot_id()
bool destination_reached() const
void set_is_on_open_space_trajectory(const bool flag)
void set_openspace_planning_finish(const bool flag)
static void PathPointNormalizing(double rotate_angle, const common::math::Vec2d &translate_origin, double *x, double *y, double *phi)
StageResult Process(const common::TrajectoryPoint &planning_init_point, Frame *frame) override
Each stage does its business logic inside Process function.
const StageResult & SetStageStatus(const StageStatusType &stage_status)
Set the stage status.
bool HasError() const
Check if StageResult contains error.
StageResult ExecuteTaskOnOpenSpace(Frame *frame)
std::shared_ptr< DependencyInjector > injector_
Planning module main class.
double NormalizeAngle(const double angle)
Normalize angle to [-PI, PI).
std::string parking_spot_id
ParkingMissionStatus status
optional double max_lon_error
optional double max_heading_error
optional double max_lat_error
optional bool enable_parallel_retry_parking