# Automatic Vertical Parking Reference Trajectory Based on Improved Immune Shark Smell Optimization
## 2 Model of Reference Trajectory Optimization and Related Principles for Automatic Vertical Parking
### Reference Trajectory Optimization Model for AVP
\(\Delta L_{it}\) and \(\Delta\angle_{it}\) are the interval distance for parking and the difference of attitude angle under the \(it\)-th period, respectively, and their thresholds are \(\Delta L_{\max}\) and \(\Delta\angle_{\max}\), respectively;\(P_{is}\) is the central point of the \(is\)-th feature region, \(is\in\{2,\cdots,ns\}\), and \(\Omega_{C,is}\) is its adjustable area, obviously, \(\forall P_{is}\in\Omega_{C,is}\). In this work, the cubic spline fitting method is adopted, and \(tf\) is the fitted reference trajectory curve of the parking garage. \(T(P_{ns},P_{bm})\) is the line between the central point \(P_{ns}\) of the parking area and the bottom midpoint \(P_{bm}\) of the garage, \(\Delta\angle_{S}\) is the parking inclination angle, which is the angle between \(T(P_{ns},P_{bm})\) and the far side line \(L_{fe}\) of the garage, and \(\Delta\angle_{S\max}\) is the absolute value threshold. \(\Delta y_{ns}\) is the parking position error, \(\Delta y_{H\max}\) is the threshold of its absolute value, and \(y_{H}\) is the ordinate value of the expected parking point. \(T_{R}\) is the reference trajectory for the parking garage, and its length \(L(T_{R})\) reflects the performance quality of the parking optimization method to a considerable extent; hence, it is an important parking optimization objective. The cubic spline fitting method uses the cubic spline interpolation function to fit the curve, which has been widely applied in many industries. We assume that, given the interval \(\Delta=[a,b]\) and its \(n+1\) interpolation points \((x_{0},x_{1},\cdots,x_{n})\), the cubic spline interpolation function \(s(x)\) has the following two characteristics. First, \(s(x)\) is a cubic polynomial within any subinterval \([x_{i},x_{i+1}](i\in[0,1,\cdots\cdots,n-1])\), and the specific expression of the cubic polynomial can be given as  
\[s(x)=\left\{ \begin{array}{l}s_{0}(x)x\in[x_{0},x_{1}]\\ s_{1}(x)x\in[x_{1},x_{2}]\\ \cdots\cdots\\ s_{n-1}(x)x\in[x_{n-1},x_{n}]\end{array} \right., \tag{7}\]  
\[s_{i}(x)=a_{i+1}\cdot x^{3}+b_{i+1}\cdot x^{2}+c_{i+1}\cdot x+d_{i+1}, \tag{8}\]  
where \(s_{i}(x)\) represents the piecewise cubic polynomial function of cubic spline interpolation, \((x_{0},x_{1},\cdots,x_{n})\) denotes the interpolation point, while \((a_{0},a_{1},\cdots,a_{n})\), \((b_{0},b_{1},\cdots,b_{n})\), \((c_{0},c_{1},\cdots,c_{n})\), and \((d_{0},d_{1},\cdots,d_{n})\) denote the polynomial coefficients of the piecewise function \(s_{i}(x)\). In addition, \(s_{i}(x)\) should be second-order continuously differentiable within the interval \(\Delta=[a,b]\). If the coordinates of the central points of all feature regions under the standard parking plane system are obtained, the smooth parking reference trajectory can be quickly obtained using the cubic spline fitting method. This is a significant advantage that the geometric fitting method does not have. The line width of the garage sign line is usually between 0.1 and 0.15 m. Therefore, the maximum collision tolerance width \(\Delta W_{E}\) should be set as 0.1 m. Assuming that the sideline collision avoidance detection points are evenly distributed, the distance of the collision avoidance detection points between adjacent sidelines is set to \(\Delta D_{e}\). Based on the geometry, the following constraints should be met:  
\[\Delta D_{e}\leq 2\cdot\Delta W_{E}, \tag{9}\]  
\[ng\geq\left\lceil\frac{L(L_{ne})}{2\Delta W_{E}}\right\rceil+\left\lceil\frac{ L\left(L_{fe}\right)}{2\Delta W_{E}}\right\rceil, \tag{10}\]  
where \(L(L_{ne})\) and \(L\Big{(}L_{fe}\Big{)}\) are the length of the near and far side lines of the garage, respectively.