Frontiers in Computing and Intelligent Systems ISSN: 2832-6024 | Vol. 6, No. 1, 2023 46 Trajectory Tracking Control Algorithm of Two‐wheel Rutting Model Yuanhong Dan, Haiyang Zhong College of Computer Science and Engineering, Chongqing University of Technology, Chongqing, 400054, China Abstract: In the development of unmanned two-wheeled self-balancing vehicle, it is very important to consider the trajectory tracking of unmanned two-wheeled self-balancing vehicle. In order to study the track tracking problem of unmanned two- wheeled self-balancing vehicle, the kinematic model of unmanned two-wheeled vehicle and the relation between its roll Angle and the kinematic model were established. The simulation platform is built to realize the unmanned two-wheeled vehicle and realize the circular track tracking at 5m/s, and the tracking performance of the track tracking controller under the circular track is verified. Keywords: Unmanned Two-wheeled Vehicle; Trajectory Tracking Control; Model Predictive Control; Kinematic Model. 1. Introduction With the continuous improvement of the intelligent demand for vehicles and the continuous improvement of autonomous technology, researchers have also begun to pay attention to the autonomous driving problem of unmanned vehicles. Unmanned two-wheelers have only one rut and can show good maneuvering performance under narrow conditions. However, unmanned two-wheelers are a complex nonlinear, strongly coupled and multi-variable natural unstable system, so there are few studies on the trajectory tracking control of unmanned two-wheelers. In 2021, Singh,R [1], a foreign scholar, optimized the steady-state deviation and transient response by optimizing the proportional, integral and differential controllers (PID), thereby improving the stability of the system and adjusting the balance of the vehicle. Domestic scholars have also done a lot of research on unmanned two-wheeler trajectory tracking. Cui Leilei[2] established a nonlinear dynamics model for autonomous bicycles in 2022, and then divided it into two related subsystems: tracking and equalization. In the tracking system, the tractive force of the bicycle is calculated by the reverse method. In the equalization system, the optimal controller is used to determine the directional angular speed of the handle, so as to realize the adjustment of the vehicle. By using small gain technology, the problem of high coupling is solved by verifying the asymptotic stability of closed-loop bicycle control. The two-wheeled vehicle can track the expected trajectory with stable attitude. Firstly, the kinematics model of unmanned two-wheeled vehicle is established. The next step is to establish the relationship between the kinematics model of the unmanned two-wheeler and the rolling Angle of the vehicle. On this basis, a control algorithm for unmanned two-wheeled vehicle trajectory tracking considering model prediction is proposed. Finally, through simulation, it is proved that the unmanned two-wheeled vehicle can track the desired trajectory while maintaining its attitude stability. 2. Kinematic Error Model In order to realize the track tracking of unmanned two- wheelers, the kinematic model of two-wheelers must be established to analyze the motion law of two-wheelers from the Angle of geometry. The model mainly reflects the change of the speed and spatial position of the two-wheeled vehicle at different time points. It is assumed that the vehicle is driving on a good road surface, and the vehicle speed is controlled at [0m/s,6m/s], and on the premise that the vehicle's attitude is stable, the trajectory tracking controller is designed through the kinematic model [3-4]. Without considering the vehicle dynamics model. In the inertial plane rectangular coordinate system involved, the X axis is horizontally to the right, and the Y axis is vertically upward [5]. In the rectangular coordinate system of the two- wheel chassis plane, the x axis is forward along the two-wheel ground point line, and the y axis is perpendicular to the two- wheel ground point line and points to the left of the two-wheel. The Angle between the x axis of the car body coordinate system and the X axis of the inertial coordinate system is the yaw Angle, and the counterclockwise direction is defined as the positive direction. In the inertial plane rectangular coordinate system, the coordinates of the center of the front wheel and the center of the rear wheel of the unmanned two-wheel vehicle are , and , , is wheelbase, is the wheel speed of the rear wheel, ∆ is the motion steering Angle of the unmanned two-wheeler. When an unmanned two-wheeler is driving, the speed at the center of the rear wheel X , Y is: cos sinr r rv X Y    (1) The kinematic constraints of the front and rear wheels of unmanned two-wheelers are: sin( ) cos( ) 0 sin cos 0 f f r r X Y X Y                 (2) Combining formula 1 and Formula 2, the velocity vector of the rear wheel in the inertial coordinate system is obtained: cos sin r r r r X v Y v         (3) According to formula 2 and 3, and the geometric relationship between front and rear wheels, the yaw velocity can be obtained as: 47 tanrv L    (4) According to the yaw velocity and velocity of the rear wheel in the inertial coordinate system, the kinematics model of the unmanned two-wheeled vehicle is obtained by formulas 3 and 4: tan cos sin r r r r r r v L a v X v Y v                 (5) is the acceleration of the rear wheels of the vehicle. According to Formula 5, in the trajectory tracking control algorithm, when the system input is ∆ , converting the kinematic model into a linear vehicle error model can avoid the problem that is difficult to convert the system into a state space form due to the inclusion of input items. The following can be obtained: 1 2 3 cos sin tan r r r r r X v f Y v f v f L                                   (6) Select input ∆ , system state variable , then the general form of the system is: ( , )X f X u (7) The reference trajectory of the unmanned two-wheeler is determined, and assuming that every point on the reference trajectory satisfies the vehicle kinematics equation, it can be expressed as: ( , )ref ref refX f X u (8) ; ∆ ; represents the track reference. By expanding the Taylor series of formula 8 and ignoring the higher order terms, we get: ( , ) ( , ) | ( ) ( , ) | ( ) ref ref ref ref f X u X f X u X X X f X u u u u           (9) Subtract formula 9 from formula 8 to get a linearized kinematic error model: 0 0 sin 0 0 cos 0 0 0 ref ref ref ref ref ref ref ref ref ref X X v X X e Y Y v Y Y                                       2 cos 0 sin 0 tan cos ref r ref ref ref ref ref ref v v v L L                      (10) At this time, the controlled quantity is the error between the real-time path of the two-wheel vehicle and the reference trajectory, so the coefficient matrix is determined with the target trajectory [6-7]. 3. Model Predictive Controller Model predictive control (MPC) estimates the future control input through the historical state quantity to simulate the output at the next moment, and solves the constrained optimization problem on a rolling basis to achieve real-time control [8]. Model predictive control is composed of model prediction, rolling optimization and feedback correction. Formula 10 belongs to the continuous equation of state, and it needs to be discretized before model predictive control [9] : ( 1) ( )e k e k e Ae Bu T       (11) Collation available: 2 , , 1 0 sin ( 1) 0 1 cos ( ) 0 0 1 cos 0 sin 0 ( ) tan cos ( ) ( ) ref ref ref ref ref ref ref ref ref k t k t Tv e k Tv e k T T u k v T T L L A e t B u k                                     (12) is sampling time. The discretized state space is transformed again to constrain the controller output: ( , ) ( , ) ( 1, )k t e k t u k t          (13) Sort out state variables and control variable increments to further transform state space expressions: ( 1, ) , ( , ) , , ( , ) ( , ) ( , ) k t k t k t k t k t k t A B U k t k t C              (14) The coefficient matrix of state quantity and the control quantity is shown as follows: , , , 0 1 k t k t k t A B A          , , , 1 k t k t B B         ; , , 0k t k tC C      For ease of expression, let: , , , , , , , 1, , 1 , 1, , 1 , 1, , 1 k t t t k t t t k t t t A A k t N B B k t N C C k t N                      (15) Suppose that the prediction time domain is ; The control time domain is ; According to the principle of model predictive control algorithm, it can be obtained: ( ) ( , ) ( , )t tY t t t U k t  (16) 48 In model predictive control, the following objective function[10] is often used to solve the optimal solution: 2 1 1 2 2 1 ( ) || ( , ) ( , ) || || ( , ) || p c N ref Q i N R i J k k i t k i t U k i t                 (17) and are the system weight matrix; is relaxation factor; is the weight coefficient. Under different working conditions, the constraints of control increment and control quantity are considered, and the constraints are as follows: min maxt tU A U U U    (18) Where: : and are the maximum and minimum values of the system control quantity in the time domain. According to the established constraints, the controller is able to transform the objective function into a standard quadratic form through optimization: ( ( ), ( 1), ( )) [ ( ) , ] [ ( ) , ] [ ( ) , ] T T T t T t t J t u t U t U t H U t G U t P              (19) And: 0 0 T t t t Q R H           ; 2 ( ) 0T t tG E t Q    ; ( ) ( )T tP E t QE t is ths predict tracking errors in the time domain for the controller: ( ) ( ) ( )refE t Y t Y t  (20) Through the algorithm design, the formula is calculated for each cycle of the controller operation, and a series of control increment sequences are obtained: * * * * 1 1c T t t t t NU u u u           (21) When the controller is running, it will solve the optimal control increment according to the real-time state of the system and take the first one to enter the outer loop controller: ( ) ( 1) tu t u t u     (22) The final output desired motion steering Angle and desired rear wheel speed are expressed by ∆ and respectively. Convert the motion steering Angle to the rotation Angle of the shaft for balance control: arg arg cos t et t et    (23) The trajectory tracking controller algorithm consists of three parts, namely MPC controller, Angle loop controller and control object. First, the sensor sends the rear wheel speed, motion steering Angle and real-time status of the two-wheel vehicle to the MPC controller for error solving and the optimal solution is obtained, and then the rotation Angle of the shaft is obtained as the expected value of the Angle ring controller to complete the track tracking of the unmanned two-wheel vehicle. 4. Experimental Analysis After the control algorithm is designed, a simulation model is built in MATLAB/Simulink, in which the sampling time of the simulation model prediction controller is set to =0.05s, the simulation control time domain is set to =30, and the simulation prediction time domain is set to =80. Unmanned two-wheelers are sensitive to wheel speed, and vehicle control constraints are set to make the vehicle run stably: 0.1 / 0.1 / 0.1 / 0.1 / r d r m s v v m s m s v m s         (24) The steering angular speed of the simulated vehicle is within plus or minus 180deg/s, the steering Angle is within plus or minus 30°, and the control quantity and control increment of the front wheel Angle are set to stabilize the steering: 30 30 0.32 0.32              (25) 4.1. Circular Trajectory Tracking Test Considering the trajectory tracking stability of unmanned two-wheelers in the steering state [11], the simulation time is set as 50s, the simulation reference speed is 5m/s, the initial front wheel steering Angle of the simulation is 0°, the initial position of the simulation is zero, and the parametric equation of the circular trajectory is as follows: arg ( ) 5 25*sin ( ) 35 25*cos tan ( ) * t t d t et x t y t v t t L                (26) Where: is the yaw Angle changing with time. Simulation test results were obtained, as shown in Figure 1. According to the results shown in FIG. 5 (a) and (b), it can be seen that the unmanned two-wheeled vehicle can rapidly reduce the error with the reference track when it leaves the target track, so as to track the circular track of the upper target. Figures (c) and (d) reflect the change of roll Angle and steering Angle of unmanned two-wheelers, both of which converge gradually. The final steering Angle converges to 4.13°. (a)Change of Track 49 (b)Change of Tracking Error (c)Change of Roll Angle (d)Change of Steering Angle Fig 1. Result of Circular Track with A Tracking Radius of 25m 5. Conclusion (1) Combining the Angle loop control algorithm, a trajectory tracker considering model predictive control is designed to realize that when the vehicle speed is 3m/s and 5m/s, the vehicle can track the expected linear trajectory and circular trajectory well under the simulation platform. (2) Through the simulation test, it is obtained that at the speed of 5m/s, the limit curvature that the controller can track is 0.29, and the vehicle can track the circular trajectory under the limit curvature well, which verifies the performance of the trajectory tracking controller. References [1] Singh, R, Bhushan, B. Improved ant colony optimization for achieving self-balancing and position control for balancer systems[J]. Journal of Ambient Intelligence and Humanized Computing, 2021, 12: 8339–8356. [2] Leilei Cui, Shuai Wang, Zhengyou Zhang, et al. Asymptotic Trajectory Tracking of Autonomous Bicycles via Backstepping and Optimal Control[J]. IEEE Control Systems Letters, 2022, 6: 1292-1297. [3] Huang Mei. Trajectory Planning and Tracking Control of Intelligent Vehicle based on Model Predictive Control [D]. Chongqing University of Posts and Telecommunications, 2020. [4] Liu Nan. Research on Trajectory Tracking Control of Unmanned Vehicles based on MPC [D]. Xi 'an University of Technology, 2021. [5] Liang Zhongchao, Zhang Huan, Zhao Jing, et al. Autonomous vehicle trajectory tracking control based on adaptive MPC [J]. Journal of Northeastern University (Natural Science), 2020, 41 (6): 835. [6] Wang Si-xiao, Zhao Wen-jun, Zhang Hao, Gao Yong, Lipson. TD-PID control algorithm of coaxial anti-propeller UAV string based on differential tracker[J]. Journal of Zhejiang University (Engineering Edition), 2021, 55 (12): 2359-2364. [7] Wu Hong-xin, Shen Shao-ping. Application and theoretical basis of PID control[J]. Control Engineering, 2003 (01): 37-42. [8] Gong Jian-wei, Liu Kai, Qi Jian-yong. Model predictive control for driverless vehicles, 2nd edition[M]. Beijing: People's Post and Telecommunications Press, 2020. [9] Chu Can-can, Wang Dong, Zhang Wei-gong, etc. Speed control of electric vehicle driving robot based on inverse control strategy model[J]. Automotive Engineering, 2020, 42 (9): 1166-1173. [10] Xin Peng. Research on path tracking model predictive control method for autonomous vehicles[D]. Lanzhou University of Technology, 2021. [11] Wang Qi, Kong De-peng. Terminal trajectory tracking control of free-floating dual-arm space robot[J]. Mechanical Design and Manufacturing, 2022, No.382 (12): 68-72. 0 10 20 30 40 50 -2 0 2 4 6 8 10 12 14 5m/s 0 10 20 30 40 50 -10 -5 0 5 10 15 20 5m/s 0 10 20 30 40 50 -10 -5 0 5 10 15 5m/s