A Trajectory Planning Method for Autonomous Valet Parking via Solving an Optimal Control Problem

In the last decade, research studies on parking planning mainly focused on path planning rather than trajectory planning. The results of trajectory planning are more instructive for a practical parking process. Therefore, this paper proposes a trajectory planning method in which the optimal autonomous valet parking (AVP) trajectory is obtained by solving an optimal control problem. Additionally, a vehicle kinematics model is established with the consideration of dynamic obstacle avoidance and terminal constraints. Then the parking trajectory planning problem is modeled as an optimal control problem, while the parking time and driving distance are set as the cost function. The homotopic method is used for the expansion of obstacle boundaries, and the Gauss pseudospectral method (GPM) is utilized to discretize this optimal control problem into a nonlinear programming (NLP) problem. In order to solve this NLP problem, sequential quadratic programming is applied. Considering that the GPM is insensitive to the initial guess, an online calculation method of vertical parking trajectory is proposed. In this approach, the offline vertical parking trajectory, which is calculated and stored in advance, is taken as the initial guess of the online calculation. The selection of an appropriate initial guess is based on the actual starting position of parking. A small parking lot is selected as the verification scenario of the AVP. In the validation of the algorithm, the parking trajectory planning is divided into two phases, which are simulated and analyzed. Simulation results show that the proposed algorithm is efficient in solving a parking trajectory planning problem. The online calculation time of the vertical parking trajectory is less than 2 s, which meets the real-time requirement.


Introduction
With the development of an intelligent transportation system (ITS), parking technology has gone through three stages: semi-autonomous parking, autonomous parking, and autonomous valet parking (AVP) [1]. The semi-autonomous parking system and autonomous parking system are used to help drivers park safely. Moreover, a shorter parking time can effectively reduce the negative impact of a parking process on road traffic. In addition, the last-mile transportation of autonomous driving can be achieved with an AVP system since users can send instructions through terminal devices to park or retrieve their cars [2]. In this context, parking technology is an indispensable part of the autonomous driving system.
Among the key technologies of AVP, researchers focus on the platforms, sensor setups, perception, environment model, maps, and motion planning [3]. As the basis for the realization of AVP, environmental perception is mainly realized by a fusion of ultrasonic radars and cameras [4]. On this basis, a parking guidance system (PGS) based on visual recognition is built, and environment A small parking lot is selected as the scenario of AVP, and the parking trajectory planning is separated into two phases. In this context, the trajectories of the two phases are simulated and analyzed. On this basis, the vertical parking trajectory is calculated online to verify the effectiveness of the proposed algorithm.
The remainder of the paper is organized as follows. The AVP scenario and the optimal control problem for parking, including kinematics models and various constraints, are described in Section 2. The optimal control problem is discretized as the nonlinear programming (NLP) problem through the GPM, and the solution strategy of the NLP problem through the homotopic method is described in Section 3. The simulation results and discussion of parking trajectory are in Section 4, and an online planning method of vertical parking is proposed. Finally, the conclusion and future works are discussed in Section 5.

AVP Scenario
In this paper, a small parking lot is selected as the scenario for verifying the algorithm. There is a U-shaped road in the parking lot, and the parking spaces on both sides of the road are vertical (see Figure 1a). Denoted by positions A, B, and C are the parking entrance, initial vertical parking position, and parking completion position, respectively. Based on the common parking process of a human driver, the parking process is divided into two phases: (i) The search for a vacant parking space, where the driver starts to seek a vacant parking space when entering the parking lot. Then the vehicle is moved to an initial parking area after finding a parking space. (ii) The vertical parking phase, where the vehicle moves backwards from the initial parking area until it is completely in the parking space. To facilitate parking trajectory planning, a 3D perspective of the parking space is set to top view (see Figure 1b). The initial vertical parking area and parking space are represented by the green dotted frame and the red solid frame, respectively, and the paths of the two phases are A-B and B-C.
problem for parking, including kinematics models and various constraints, are described in Section 2. The optimal control problem is discretized as the nonlinear programming (NLP) problem through the GPM, and the solution strategy of the NLP problem through the homotopic method is described in Section 3. The simulation results and discussion of parking trajectory are in Section 4, and an online planning method of vertical parking is proposed. Finally, the conclusion and future works are discussed in Section 5.

AVP Scenario
In this paper, a small parking lot is selected as the scenario for verifying the algorithm. There is a U-shaped road in the parking lot, and the parking spaces on both sides of the road are vertical (see Figure 1a). Denoted by positions A, B, and C are the parking entrance, initial vertical parking position, and parking completion position, respectively. Based on the common parking process of a human driver, the parking process is divided into two phases: (i) The search for a vacant parking space, where the driver starts to seek a vacant parking space when entering the parking lot. Then the vehicle is moved to an initial parking area after finding a parking space. (ii) The vertical parking phase, where the vehicle moves backwards from the initial parking area until it is completely in the parking space. To facilitate parking trajectory planning, a 3D perspective of the parking space is set to top view (see Figure 1b). The initial vertical parking area and parking space are represented by the green dotted frame and the red solid frame, respectively, and the paths of the two phases are A-B and B-C.
Assuming that the parking lot is built with an infrastructure system, the vehicle can communicate with the system by Vehicle to Infrastructure (V2I) technology [36]. Moreover, vacant parking spaces can be detected by the system and allocated to vehicles entering the parking lot. In this context, the vehicle can be guided to the initial vertical parking area according to the system information. However, the guidance information provided by the system is not complete. Vehicle sensors, such as ultrasonic sensors, are needed to detect the environment for the accuracy of information around the vacant parking space. Besides, the parking trajectory in the vertical parking phase is obtained according to the initial parking position and the position relative to the vacant parking space. The trajectories of these two phases can be obtained in the following two means. One is that the trajectory is calculated by the server of the infrastructure system and sent to the vehicle, which is controlled to track the trajectory. Another is that the vehicle obtains part of the guidance information from the facility system, and then combines it with its own perception information for calculation. Also, the vehicle is controlled to track the obtained trajectory. Assuming that the parking lot is built with an infrastructure system, the vehicle can communicate with the system by Vehicle to Infrastructure (V2I) technology [36]. Moreover, vacant parking spaces can be detected by the system and allocated to vehicles entering the parking lot. In this context, the vehicle can be guided to the initial vertical parking area according to the system information. However, the guidance information provided by the system is not complete. Vehicle sensors, such as ultrasonic sensors, are needed to detect the environment for the accuracy of information around the vacant parking space. Besides, the parking trajectory in the vertical parking phase is obtained according to the initial parking position and the position relative to the vacant parking space. The trajectories of these two phases can be obtained in the following two means. One is that the trajectory is calculated by the server of the infrastructure system and sent to the vehicle, which is controlled to track the trajectory. Another is that the vehicle obtains part of the guidance information from the facility system, and then combines it with its own perception information for calculation. Also, the vehicle is controlled to track the obtained trajectory.

Kinematics Model
According to Ackerman steering, all wheels are in a state of rolling, and the vehicle is not affected by lateral force during the parking process. Thus, the slip of the wheel is neglected, and the steering axis of the front wheel intersects the axis of the rear wheel. On this basis, a kinematics model of a vehicle in autonomous parking is built as shown in Figure 2, where R(x, y) denotes the center of the rear axle; v refers to the speed of the center of the rear axle; O stands for the center of the instantaneous turning of the vehicle; f and r denote the front suspension and rear suspension of the vehicle, respectively; d stands for the width of the vehicle; L is the wheelbase of the vehicle; ϕ stands for the equivalent front wheel swing angle; and θ refers to heading angle. Furthermore, A, B, C, and D are the four vertices of the vehicle body.

Kinematics Model
According to Ackerman steering, all wheels are in a state of rolling, and the vehicle is not affected by lateral force during the parking process. Thus, the slip of the wheel is neglected, and the steering axis of the front wheel intersects the axis of the rear wheel. On this basis, a kinematics model of a vehicle in autonomous parking is built as shown in Figure 2, where R(x, y) denotes the center of the rear axle; v refers to the speed of the center of the rear axle; O stands for the center of the instantaneous turning of the vehicle; f and r denote the front suspension and rear suspension of the vehicle, respectively; d stands for the width of the vehicle; L is the wheelbase of the vehicle; φ stands for the equivalent front wheel swing angle; and θ refers to heading angle. Furthermore, A, B, C, and D are the four vertices of the vehicle body. According to the vehicle kinematics model, kinematics differential equations can be obtained as follows: where and refer to vehicle acceleration and jerk of the vehicle, denotes the angular velocity of the front wheel pendulum, and 0 and stand for initial time and final time, respectively.
According to the geometric relationship, the coordinate values of A, B, C, and D can be obtained by the center point of the rear axle R(x, y) and are as follows: (2) According to the vehicle kinematics model, kinematics differential equations can be obtained as follows: where a and j refer to vehicle acceleration and jerk of the vehicle, ω denotes the angular velocity of the front wheel pendulum, and t 0 and t f stand for initial time and final time, respectively. According to the geometric relationship, the coordinate values of A, B, C, and D can be obtained by the center point of the rear axle R(x, y) and are as follows: Sensors 2020, 20, 6435 5 of 19

Physical Constraints
Considering safety and crew comfort, some state variables and control variables of the system are constrained as follows: where v max stands for the maximum speed with a max for the maximum acceleration, jerk max denotes maximum acceleration change rate, ϕ max denotes the maximum front wheel swing angle, and ω max is the maximum front wheel swing angle speed. Another purpose of constraining these variables is to make the planned trajectory as smooth as possible so that it will be relatively easier for each vehicle execution system (such as steering system, power system, braking system) to implement trajectory tracking.

Avoid Collision Constraints
There is no collision allowed while the vehicle is parked. To this end, collision between vehicles and dynamic or static obstacles (e.g., other vehicles, pedestrians, road boundaries) must be considered. The vehicle contour is assumed to be rectangular. Considering the detection accuracy of on-board sensors and the detection blind area in practice, the four-circle model is selected to describe the vehicle contour in this paper, which is shown in Figure 3, where O 1 , O 2 , O 3 , and O 4 denote the center of four vehicles. The geometric relationship is described as follows:

Physical Constraints
Considering safety and crew comfort, some state variables and control variables of the system are constrained as follows: where stands for the maximum speed with for the maximum acceleration, denotes maximum acceleration change rate, denotes the maximum front wheel swing angle, and is the maximum front wheel swing angle speed. Another purpose of constraining these variables is to make the planned trajectory as smooth as possible so that it will be relatively easier for each vehicle execution system (such as steering system, power system, braking system) to implement trajectory tracking.

Avoid Collision Constraints
There is no collision allowed while the vehicle is parked. To this end, collision between vehicles and dynamic or static obstacles (e.g., other vehicles, pedestrians, road boundaries) must be considered. The vehicle contour is assumed to be rectangular. Considering the detection accuracy of on-board sensors and the detection blind area in practice, the four-circle model is selected to describe the vehicle contour in this paper, which is shown in Figure 3, where 1 ， 2 ， 3 , and 4 denote the center of four vehicles. The geometric relationship is described as follows： where 1 stands for the distance from circle center 1 to the rear of the vehicle, and 5 stands for the distance from circle center 4 to the front of the vehicle. Furthermore, 2 , 3 , and 4 refer to the distance between 1 2 , 2 3 , and 3 4 , respectively. denotes the radius of the outer circle.  From the above geometric relationships and the center point of the rear axle R(x, y), the positions of four centers are described as follows: Similarly, the contours of obstacles are described by multiple circumferential circles (see Figure 3). As shown in Figure 4, if the shapes of the obstacles are similar to a small square, such as pedestrians and trash cans, they can be described by a single circle for convenience. Therefore, the collision-free conditions between vehicles and obstacles can be described by the avoidance of the overlap between the circle of the vehicle contour and that of the obstacle contour. The strict mathematical description of security is shown in Equation (6): where O and R o denote the center and radius of the circumferential circle of the contour of the obstacle, respectively.    Otherwise, collision between a vehicle and road boundaries has to be considered. The movement of the vehicle is in an area bordered by a road boundary, where L s and W s denote the length and width of the road, respectively (see Figure 4). Hence, in the course of the movement, the four vertices of the vehicle, A, B, C, and D, all fall in the area expressed as follows:

Terminal Conditions
The satisfaction of the above constraints ensures a collision-free motion of the vehicle from the starting moment t 0 to the ending moment t f . Moreover, the terminal constraint of the vehicle at t 0 and t f is supposed to be taken into consideration. In this paper, the initial state and the end state of the vehicle are stationary, that is, v(t 0 ) = 0, v t f = 0. Other states like acceleration at t 0 are selected depending on different scenarios. The four vertices of the vehicle must be inside the parking space at t f . In addition, it is stipulated that the body of the vehicle should be parallel to the parking space as shown in Figure 5, where P(x, y) is the upper-left vertex of the vertical parking space. The terminal constraints at t f are as follows: where L p and W p denote the length and width of the parking space, respectively.

=
( where 1 and 2 are the weight of and the driving distance, respectively. When 1 = 1 and 2 = 0 , only the optimal is considered in the cost function. In contrast, when 1 = 0 and 2 = 1，only the shortest driving distance is considered in the cost function. Furthermore, 1 and 2 are set to be 0.5.

Trajectory Planning Optimal Control Problem
In this work, the minimum sum of t f and the driving distance are set as the cost function. Combined with the kinematics model, the collision avoidance constraints, the above-mentioned endpoint constraints, and the optimal control problem of autonomous parking trajectory planning are depicted as follows: Avoid collision constrains in Eqs. (4)(5)(6)(7) Terminal constrains in Eq.(8) where ω 1 and ω 2 are the weight of t f and the driving distance, respectively. When ω 1 = 1 and ω 2 = 0, only the optimal t f is considered in the cost function. In contrast, when ω 1 = 0 and ω 2 = 1, only the shortest driving distance is considered in the cost function. Furthermore, ω 1 and ω 2 are set to be 0.5.

Homotopic Method for Solving Optimal Control Problem
In Section 3, a unified trajectory optimization framework for the parking problem is presented. The GPM is utilized to discretize the above optimal control problem into a nonlinear programming problem for solving [37]. Here, the location of the collocation point is determined at first, and the state variables and control variables are discretized into unknown parameters at the collocation points. Then, Lagrange interpolation polynomials are constructed from these collocation points to determine the continuous state variables and control variables. By deriving the above Lagrange interpolation polynomials, the parking kinematics equation is transformed into algebraic equations at the collocation points, and the integral part of the cost function is discretized by the Gauss integral. Compared with the traditional collocation method and direct shooting method, the GPM, a kind of global collocation method, has better solving accuracy and convergence speed [38,39]. However, for nonsmooth problems, the convergence speed of the GPM is slower. To this end, a homotopic method is used to change the boundary of the obstacle avoidance constraint in the optimal control problem, and the solution of the last optimal control problem is used as the initial value of the next solution. The detailed framework is described as follows: Step 1. Time domain transformation The time domain of parking trajectory planning t ∈ t 0 , t f is transformed into a time domain of the GPM in [−1,1]: Step 2. Discretization of variables Lagrange interpolation and Gauss quadrature equations are used to discretize the optimal control problem at a series of Legendre-Gauss (LG) points. The discrete points of the GPM include N+1 points composed of NLG points and τ 0 = −1. State variables and control variables are approximated at each configuration point as follows: where x and µ stand for state variables and control variables, respectively. X and U refer to discrete variables, and L i (τ) denotes Lagrange interpolation basis functions.
Step 3. Transformation of state equation and constraint equation After the derivation of Equation (11), the obtained derivative of a state variable at collocation point τ = τ k can be approximated as follows: where D denotes a differential state matrix, which represents the differential value of the Lagrange interpolation basis function at each collocation point. Through Equation (13), a state equation can be transformed into equality constraints, as follows: The obstacle avoidance constraints and endpoint constraints in parking trajectories are also discretized at the collocation points. The obtained equality constraints are as follows: where C and E denote the obstacle avoidance constraint and endpoint constraint, respectively.
Step 4. Transformation of cost function The integral term in the cost function can be approximated by the Gauss integral method. In this way, the cost function is transformed as follows: where ω i stands for the integral weight.
Step 5. The homotopic transformation of constraint equation The optimal control problem of parking trajectory planning becomes unsmooth with the increase of environment complexity, which makes it difficult to solve the original problem by directly using the GPM. Thus, this paper proposes a homotopic method to improve the smoothness of the original problem. In the proposed method, the bounds of obstacle avoidance constraints in the original problem are taken as homotopic parameters to make the original problem of parking trajectory planning smoother. In this way, the unsmooth original problem is directly solved without changing the form of the original problem. In addition, the optimal solution is used as the initial value of the next calculation. To this end, Equation (15) is transformed as follows: where H c denotes the homotopic parameter vector. To improve the convergence of the generated new problem, H c is added, releasing the constraint boundaries. Therefore, when H c evolves into 0, the problem becomes the original problem. Equation (18) can also be transformed as follows: It is worth noting that Equation (19) has the same form as Equation (15). Therefore, the solution of the original problem can be obtained by constant iteration with a homotopic method. Moreover, the result of the last optimal control problem is taken as a better initial value, which reduces the difficulty of the next solution. As a result, the convergence speed of the solution is effectively improved.
After the five steps above, the optimal control problem of parking trajectory planning is transformed into a discrete NLP problem by the GPM, and SNOPT is adopted as the software package in this paper. The overall flowchart of the proposed GPM-based methodology is demonstrated in Figure 6.

Simulation Results and Discussion
The trajectory planning of AVP is separated into two phases. Two obtained optimal trajectories of corresponding phases are spliced into a complete trajectory of the whole AVP. The code is executed on a laptop running Windows 7 with an Intel(R) Core(TM) i5-3210M 2.50 GHz processor and 8 GB RAM, written in MATLAB. The vehicle parameters and physical constraints used in the simulation

Simulation Results and Discussion
The trajectory planning of AVP is separated into two phases. Two obtained optimal trajectories of corresponding phases are spliced into a complete trajectory of the whole AVP. The code is executed on a laptop running Windows 7 with an Intel(R) Core(TM) i5-3210M 2.50 GHz processor and 8 GB RAM, written in MATLAB. The vehicle parameters and physical constraints used in the simulation are shown in Table 1.

Trajectory of Parking Space Searching Phase
In the first phase of the parking process, the vehicle moves from the entrance of the parking lot to the initial area of vertical parking. In this phase, it is assumed that there are no other dynamic obstacles, such as vehicles and pedestrians, but only some constraints of road boundary and parking space. The position of the vehicle at the entrance and the initial area of vertical parking are defined as follows: According to the above-mentioned algorithm, the trajectory planning problem of the first phase is solved without constraints, and the trajectory of the vehicle (see Figure 7a) is a circular arc. The termination condition is that all the vertices of the vehicle fall in the initial parking area. In this context, the vehicle reaches the top, rather than the middle, of the initial parking area to optimize the cost function, which is shown in Figure 7a. It is also found out that the trajectory intersects with the parking spaces in the middle of the parking lot, instead of those at the bottom or top of the parking lot. Therefore, by using the above-mentioned homotopic algorithm, the constraints of the middle parking spaces are gradually approximated to the constraints of the original optimal control problem. Then vehicle trajectories from the entrance to the initial area of parking are obtained by iterative solution, which are shown in Figure 7b

Trajectory in Vertical Parking Phase
In the second phase of the parking process, the convenience of passengers in getting on and off has to be considered. To this end, the minimum width of the space on both sides of the vehicle when the parking ends is set to 0.3. Therefore, the minimum parking length min L p is set to 2.3, and the parking width W p is set to 5.0. Additionally, based on the range of the initial parking area, the road width W s is set to 4.5 (see Figure 5). For the convenience of calculation, the upper-left vertex of the vertical parking space is set as the origin of the coordinate system, that is, [Px, Py] = (0, 0). Furthermore, the coordinate of the central point of the rear axle at the starting position is [Rx(t 0 ), Ry(t 0 )] = (5, 1.5). In addition, the termination condition of parking completion is required to meet the constraints in Equation (8), and the equation of Ry t f = Lp/2 to ensure that the vehicle is in the middle of the parking space at the ending moment.
According to the above-mentioned homotopic algorithm, the parking space L p gradually decreases from 3.5 to the minimum value. In other words, the homotopic parameter H c = [3.5 : λ : 2.3], where the step length λ = 0.02. Hence, the problem is solved with 61 times of iteration, and there is only a difference of Lp between each iteration process. Then, four vertical parking processes with different Lp values are selected for analysis and discussion. The values of Lp in Cases 1-4 are set as 3.50, 3.12, 2.72, and 2.30, respectively. The optimized trajectory, control variables, and state variables are illustrated in Figures 8-15.
First of all, all vehicles can complete vertical parking and meet the above-mentioned termination constraints in Cases 1-4, which means that the vehicle is in the middle of the parking space when the parking ends. The control variables all present the feature of the bang-bang control (see Figure 9, Figure 11, Figure 13, and Figure 15) because time is required to be optimal in cost function. That is to say that the state variables are continuous and smooth despite that the control variables are oscillated.
As shown in Figures 8 and 10, the trajectories in Cases 1 and 2 are similar. The adjustment of the vehicle occurs outside the parking space rather than inside, even if the parking space is relatively larger in Cases 1 and 2. This phenomenon is similar to our daily manual vertical parking process because the narrow parking space is not conducive to the adjustment of the vehicle posture.
parking width is set to 5.0. Additionally, based on the range of the initial parking area, the road width is set to 4.5 (see Figure 5). For the convenience of calculation, the upper-left vertex of the vertical parking space is set as the origin of the coordinate system, that is, [ , ] = (0,0) . Furthermore, the coordinate of the central point of the rear axle at the starting position is [ ( 0 ), ( 0 )] = (5,1.5). In addition, the termination condition of parking completion is required to meet the constraints in Equation (8), and the equation of ( ) = /2 to ensure that the vehicle is in the middle of the parking space at the ending moment.
According to the above-mentioned homotopic algorithm, the parking space gradually decreases from 3.5 to the minimum value. In other words, the homotopic parameter = [3.5: : 2.3], where the step length = 0.02. Hence, the problem is solved with 61 times of iteration, and there is only a difference of Lp between each iteration process. Then, four vertical parking processes with different Lp values are selected for analysis and discussion. The values of Lp in Cases 1-4 are set as 3.50, 3.12, 2.72, and 2.30, respectively. The optimized trajectory, control variables, and state variables are illustrated in Figures 8-15.
First of all, all vehicles can complete vertical parking and meet the above-mentioned termination constraints in Cases 1-4, which means that the vehicle is in the middle of the parking space when the parking ends. The control variables all present the feature of the bang-bang control (see Figures 9,11,13,and 15) because time is required to be optimal in cost function. That is to say that the state variables are continuous and smooth despite that the control variables are oscillated.
As shown in Figures 8 and 10, the trajectories in Cases 1 and 2 are similar. The adjustment of the vehicle occurs outside the parking space rather than inside, even if the parking space is relatively larger in Cases 1 and 2. This phenomenon is similar to our daily manual vertical parking process because the narrow parking space is not conducive to the adjustment of the vehicle posture.  As shown in Figures 10-15, parking time shows a growing trend with the gradual decrease of Lp. Furthermore, the of Case 4 is the longest, and the reason is obvious. It is because of the narrow parking space resulting in six times of direction changes in Case 4, compared with only four times in Cases 1-3.  As shown in Figures 10-15, parking time t f shows a growing trend with the gradual decrease of Lp. Furthermore, the t f of Case 4 is the longest, and the reason is obvious. It is because of the narrow  As shown in Figures 10-15, parking time shows a growing trend with the gradual decrease of Lp. Furthermore, the of Case 4 is the longest, and the reason is obvious. It is because of the narrow parking space resulting in six times of direction changes in Case 4, compared with only four times in Cases 1-3.    As shown in Figures 10-15, parking time shows a growing trend with the gradual decrease of Lp. Furthermore, the of Case 4 is the longest, and the reason is obvious. It is because of the narrow parking space resulting in six times of direction changes in Case 4, compared with only four times in Cases 1-3.          The traditional GPM takes a long time to directly solve the optimal parking problem, and even ends with nonconvergence when the parking space is narrow. Thus, this paper adopts a homotopic method to select a rational initial guess, which can solve this problem effectively. As depicted in Figure 16, the iteration time is less than 1 s in more than 90% of the cases. And the longest calculation time does not exceed 2 s. Longer iteration times occur at the beginning and end of the calculation for two reasons: (i) In the first iteration, the constraint is set to the calculation for the first time, and the increase of the constraint condition leads to the extension of the calculation time. (ii) At the end of the iteration, the rear space is narrow, so the process of trajectory optimization becomes difficult. The traditional GPM takes a long time to directly solve the optimal parking problem, and even ends with nonconvergence when the parking space is narrow. Thus, this paper adopts a homotopic method to select a rational initial guess, which can solve this problem effectively. As depicted in Figure 16, the iteration time is less than 1 s in more than 90% of the cases. And the longest calculation time does not exceed 2 s. Longer iteration times occur at the beginning and end of the calculation for two reasons: (i) In the first iteration, the constraint is set to the calculation for the first time, and the increase of the constraint condition leads to the extension of the calculation time. (ii) At the end of the iteration, the rear space is narrow, so the process of trajectory optimization becomes difficult. The traditional GPM takes a long time to directly solve the optimal parking problem, and even ends with nonconvergence when the parking space is narrow. Thus, this paper adopts a homotopic method to select a rational initial guess, which can solve this problem effectively. As depicted in Figure 16, the iteration time is less than 1 s in more than 90% of the cases. And the longest calculation time does not exceed 2 s. Longer iteration times occur at the beginning and end of the calculation for two reasons: (i) In the first iteration, the constraint is set to the calculation for the first time, and the increase of the constraint condition leads to the extension of the calculation time. (ii) At the end of the iteration, the rear space is narrow, so the process of trajectory optimization becomes difficult.

Online Computing Method for Vertical Parking Trajectory Planning
The offline calculation method of vertical parking trajectory planning is illustrated above. In the process of approaching the original optimal control problem by homotopic parameters, the overall calculation time is long even if the time cost of each iteration is short. At this time, real-time requirements will not be met. Thus, an online planning method of parking trajectory is proposed. Let us assume that the trajectories calculated by each iteration in the second phase are stored as a table. If the starting position and parking space size in practice are the same as in any case stored, the trajectory can be obtained directly from the stored trajectories by looking up the tables without any calculation. However, these ideal situations barely happen in practical applications. Considering this problem, the stored trajectory is used as an initial guess rather than an actual trajectory. The complete process is as follows: First, a parking space is found, and the vehicle is parked in its initial area. In this context, an optimal control problem for parking trajectory planning is formed. Then, the most similar set of trajectories is found from the stored data based on actual parking space size and the

Online Computing Method for Vertical Parking Trajectory Planning
The offline calculation method of vertical parking trajectory planning is illustrated above. In the process of approaching the original optimal control problem by homotopic parameters, the overall calculation time is long even if the time cost of each iteration is short. At this time, real-time requirements will not be met. Thus, an online planning method of parking trajectory is proposed. Let us assume that the trajectories calculated by each iteration in the second phase are stored as a table. If the starting position and parking space size in practice are the same as in any case stored, the trajectory can be obtained directly from the stored trajectories by looking up the tables without any calculation. However, these ideal situations barely happen in practical applications. Considering this problem, the stored trajectory is used as an initial guess rather than an actual trajectory. The complete process is as follows: First, a parking space is found, and the vehicle is parked in its initial area. In this context, an optimal control problem for parking trajectory planning is formed. Then, the most similar set of trajectories is found from the stored data based on actual parking space size and the starting position, and used as the initial guess of the actual optimal control problem, which is solved by the GPM. The advantage is that the solving speed can be effectively improved by the proposed method. This is because the corresponding original problem of the found trajectory is similar to the current problem, which makes this trajectory similar to the current solution, being a good initial guess.
To verify the above method, a working condition with L p = 2.5, [Rx(t 0 ), Ry(t 0 )] = (5, 1.5) is assumed, and its parking trajectory, used as the initial guess of the subsequent optimal control problem, is stored in the data table. Cases 5 and 6 are set up according to the distance from the actual parking starting position to point R. In each case, there are four vehicles whose start locations R'(x, y) are in the circles that take R(x, y) of the initial guess as the center and 0.2 and 0.5 as radii (as shown in Table 2). The GPM is also taken to solve the new optimal control problem for vertical parking trajectory planning. As shown in Figure 17a,b, the new optimal control problems in Cases 5-6 can be solved quickly, and the solving speed of Vehicle 4 is the quickest, followed by that of Vehicle 2. For Vehicles 2 and 4, the vertical positions are the same as those in the initial guess, that is, R y(t 0 ) = Ry(t 0 ), despite differences in the horizontal position. Therefore, their trajectories at the beginning phase of the parking are closer to the optimal ones. In contrast, the vertical positions of Vehicles 1 and 3 are different from those in the initial guess despite the same horizontal positions, which leads to a large deviation of the trajectories at the beginning phase. Therefore, the calculation time increases. As shown in Figure 17a,b, the new optimal control problems in Cases 5-6 can be solved quickly, and the solving speed of Vehicle 4 is the quickest, followed by that of Vehicle 2. For Vehicles 2 and 4, the vertical positions are the same as those in the initial guess, that is, , despite differences in the horizontal position. Therefore, their trajectories at the beginning phase of the parking are closer to the optimal ones. In contrast, the vertical positions of Vehicles 1 and 3 are different from those in the initial guess despite the same horizontal positions, which leads to a large deviation of the trajectories at the beginning phase. Therefore, the calculation time increases.

ID
(a) In Case 5, the maximal calculation time of all the vehicles is 1.87 s, which is acceptable in realtime parking applications. However, in Case 6, the calculation time of Vehicles 1 and 3 is more than 3 s. Comparing Case 5 and Case 6, it can be noted that the large deviation, especially horizontal deviation, of vehicle trajectory from the initial guess leads to a greater impact on calculation time. Therefore, the calculation time of the optimal control problem increases. In contrast, the deviation of the horizontal position has less effect on the calculation speed.
To verify the effectiveness and real-time performance of the proposed homotopic strategy, the calculation results of the two initialization methods are selected for comparison. The CPU time and tf of Cases 1-4 are recorded, and fail means nonconvergence in the calculation process. As presented in Table 3, the simulation costs of the proposed homotopic strategy are much lower than those of the other two strategies. Especially in conditions with small space (Cases 3 and 4), the calculation costs of the incremental strategy and the spatiotemporal decomposition strategy increase significantly, and the calculation may fail. We cite the following reasons to explain the excellent real-time performance In Case 5, the maximal calculation time of all the vehicles is 1.87 s, which is acceptable in real-time parking applications. However, in Case 6, the calculation time of Vehicles 1 and 3 is more than 3 s. Comparing Case 5 and Case 6, it can be noted that the large deviation, especially horizontal deviation, of vehicle trajectory from the initial guess leads to a greater impact on calculation time. Therefore, the calculation time of the optimal control problem increases. In contrast, the deviation of the horizontal position has less effect on the calculation speed.
To verify the effectiveness and real-time performance of the proposed homotopic strategy, the calculation results of the two initialization methods are selected for comparison. The CPU time and t f of Cases 1-4 are recorded, and fail means nonconvergence in the calculation process. As presented in Table 3, the simulation costs of the proposed homotopic strategy are much lower than those of the other two strategies. Especially in conditions with small space (Cases 3 and 4), the calculation costs of the incremental strategy and the spatiotemporal decomposition strategy increase significantly, and the calculation may fail. We cite the following reasons to explain the excellent real-time performance of the proposed strategy: In the iterative solution process, only the width of the parking space changes according to the calculation step. Thus, optimal control problems of two adjacent calculations are very similar. In the homotopic strategy, the optimal solution of the previous calculation is used as the initial guess for each solution. And the calculation is guided by a high-quality initial guess. It is worth noting that since there is no initial guess stored when solving the problem of Case 1, the calculation time is slightly longer than that of other cases. This result is consistent with the conclusion in Figure 16. As a summary, the processes of the online calculation of vertical parking trajectory are as follows: (i) A matrix, whose size is R m×n , is formed with starting points selected in the initial area of vertical parking. The optimal parking trajectories of these starting points are obtained by an offline method and stored. (ii) The starting point with the minimum deviation from the actual location is obtained by looking up the table of stored data. Note that the vertical deviation minimum takes higher priority than the horizontal one. Finally, the trajectory with the minimum deviation is taken as the initial guess of the optimal control problem. This optimal control problem is solved by the GPM, and an optimal trajectory of the actual parking is obtained.

Conclusions
In this paper, a method that combines the GPM and homotopic method to solve the optimal control problem is proposed for the trajectory planning of AVP. An optimal control problem is determined to describe the optimization problem of parking trajectory. Then the GPM is used to transform this optimal control problem into a nonlinear programming problem, which can be solved by sequence quadratic programming. The difficulty of solving is handled by a homotopic method, which adjusts the constraint boundary. The original problem is approached by iteration where the last solution result is taken as the initial value of the next solution. AVP trajectory planning is divided into two phases, and an online calculation method for the vertical parking phase is proposed. Furthermore, simulation results indicate that the proposed method can effectively improve the calculation speed and convergence of the solution. In the vertical parking phase, the online calculation time of trajectory planning is less than 2 s, which meets the real-time requirement.
In our future works, various sizes of parking scenarios will be taken into account. Furthermore, we will study the effective solving of the multivehicle coordinated trajectory of connected and automated vehicles in a parking lot.
Author Contributions: Conceptualization, C.C. and B.W.; methodology, B.W.; software, L.X.; data curation, J.C.; writing-original draft preparation, B.W.; writing-review and editing, C.C. and T.W.; funding acquisition, L.Q. The first two authors, C.C. and B.W., contributed equally to this work. All authors have read and agreed to the published version of the manuscript.