# 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
### Solution Principle of the Parking Trajectory Length  
The vehicle parking trajectory is obtained using cubic spline interpolation, in which case the function expression of the trajectory is difficult to obtain directly. To calculate the trajectory length of such a complex curve, we can solve it as follows.  
Let the cubic spline curve be \(s(t)\), where \(t\) is a parameter. We sample \(n\) points uniformly or non-uniformly on the curve to obtain a set of sampling points \(\{T_{i}\}_{i=1}^{n}\). For every sampling point \(T_{i}\), we find the two endpoints \(s(T_{i})\) and \(s(T_{i+1})\) of its corresponding curve segment and calculate the distance \(d(T_{i},T_{i+1})\) between these two points. The total length of the parking trajectory is the sum of the lengths of all the curve segments:  
\[L=\sum_{i=1}^{n-1}d(T_{i},T_{i+1}). \tag{11}\]  
Specifically, it includes sampling, quantization, coding, and so on [17].  
Through the reasonable sampling method, the accuracy and reliability of the parking trajectory length calculation can be ensured. The specific sampling method is as follows:  
First, based on the obtained parking trajectory, an effective and feasible sampling principle is given to implement sampling.  
Then, every sampling point is assigned a label to facilitate subsequent processing.  
Next, we check whether the sampling points cover all the key areas of the curve and whether the requirements of the sampling interval are met.  
Finally, the details of every sampling point, such as the coordinates, time stamps, feature value, etc., are recorded for subsequent processing.  
The quantization process is the basis for calculating the length of the parking trajectory, and its accuracy directly affects the reliability of the final result. The specific quantification methods are as follows:  
* Curve segment division: We divide the sampling points' set into several curve segments. Every curve segment represents consecutive sampling points. The division of the curve segments should ensure that the length of every curve segment is roughly equal, to achieve equal-length quantization.
* Curve segment endpoints extraction: For every curve segment, we extract its two endpoints as the endpoints of the curve segment, and the coordinates of the two endpoints are calculated to determine the length of the curve segment.
* Curve segment length calculation: We calculate the distance between the two endpoints of every curve segment. In the two-dimensional plane coordinate system, the distance between the two endpoints is \(d=\sqrt{\left(x_{2}-x_{1}\right)^{2}+\left(y_{2}-y_{1}\right)^{2}}\).
* Result verification: We verify the length of every curve segment to determine whether the length of the curve segment meets the expected error range.
* Quantization result recording: We record the length of every curve segment for the subsequent trajectory length calculation.  
Through encoding, the original data can be converted into a form suitable for computer processing for subsequent calculation and analysis. The coding steps are as follows:  
* Selection of the encoding method: We select the appropriate encoding method according to the data type to be encoded. For the decimal index value of the parking position reference point set, binary code can be used instead.
* Data conversion: We convert the original data to the encoding format. The index values of the parking position reference points' set need to be converted into binary numbers.
* Encoding processing: The converted data are encoded according to a fixed length. We fill every binary number to the specified length to ensure that every coding length is the same.
* Verification of the encoding results: We verify whether every encoding length is the same and whether every coding can correctly represent the original data.  
Result recording: We record the encoding results and prepare them for subsequent intelligent algorithm optimization.