## 4 Establishment of Co-Simulation Platform
### Optimization of Path Planning and Tracking Control Model  
In view of the problems existing in the path planning and tracking control model, the following optimization is carried out [35]:  
1. By adopting the method of coordinate conversion, the rear axle midpoint of the model vehicle is set as the reference point to track the planned parking path, thereby reducing tracking error.
2. ii. The state flow module is used to optimize the model and embed it into the built co-simulation platform. The sliding mode variable structure control algorithm is utilized to control the three input variables of CarSim: steering wheel angle, speed, and deceleration. The optimized path planning and tracking control model consists of three main functional modules, detailed below.  
The first module outputs the rear axle midpoint coordinates, as shown in Figure 13. Using three output variables of CarSim, including left rear wheel speed, right rear wheel speed, and vehicle yaw rate, the coordinates of rear axle midpoint are derived based on unit time of \(\Delta t\). The memory module  
Figure 13: Tracking results.  
is used to output the coordinates of the rear axle midpoint. In the module, the input signal includes steering wheel angle, throttle depth, and brake pressure. The output signal includes vehicle speed, driving direction angle, rear-wheel speed, steering wheel angle, front axle midpoint coordinates, and vehicle yaw angle signals.  
The second function module is used to transform the vehicle coordinate system into a global coordinate system, and design an ideal parking path based on the preview curvature correction algorithm, thus further optimizing the parking path. The coordinate error is obtained by subtracting the real-time coordinate of the model vehicle with the ideal path coordinate which are output continuously. The steering wheel angle is controlled based on the feedback of the coordinate error by the dual closed-loop sliding mode variable structure control algorithm, as shown in Figure 15. In this module, the input signal includes the coordinate [y] of the planned path and the coordinate [Y_lat] of the vehicle rear axle midpoint, besides, the output signal is the steering wheel angle, and [yd] is a constant.  
Figure 14: Rear Axle Midpoint Coordinate Output Module.  
Figure 15: Steering Wheel Angle Control Module.  
The third function module made use of the state flow module to output the target speed of vehicle. Based on the planned path, the target speed of different path segments is designed and output continuously. The speed error can be obtained by subtracting the real-time speed of the model vehicle with the target speed. Dual closed-loop sliding mode variable structure control algorithm is used to control the output speed of the vehicle based on the feedback of the speed error, as shown in Figure 16. In this module, the input signal includes the coordinates of the vehicle, the planned path and control parameters. While the output signal includes the coordinates of vehicle rear axle midpoint, vehicle speed, and steering wheel angle. The flag is used to determine in which stage the vehicle is in parking, and give the next path coordinate, the target steering wheel angle, and the target speed. The throttle and brake in the first module are controlled by feedback of the difference in terms of vehicle speed.