Online Active Set-Based Longitudinal and Lateral Model Predictive Tracking Control of Electric Autonomous Driving

Autonomous driving is a breakthrough technology in the automobile and transportation fields. The characteristics of planned trajectories and tracking accuracy affect the development of autonomous driving technology. To improve the measurement accuracy of the vehicle state and realise the online application of predictive control algorithm, an online active set-based longitudinal and lateral model predictive tracking control method of autonomous driving is proposed for electric vehicles. Integrated with the vehicle inertial measurement unit (IMU) and global positioning system (GPS) information, a vehicle state estimator is designed based on an extended Kalman filter. Based on the 3-degree-of-freedom vehicle dynamics model and the curvilinear road coordinate system, the longitudinal and lateral errors dimensionality reduction is carried out. A fast-rolling optimisation algorithm for longitudinal and lateral tracking control of autonomous vehicles is designed and implemented based on convex optimisation, online active set theory and QP solver. Finally, the performance of the proposed tracking control method is verified in the reconstructed curve road scene based on real GPS data. The hardware-in-the-loop simulation results show that the proposed MPC controller has apparent advantages compared with the PID-based controller.


Introduction
Due to the advantages in energy and environment, electric vehicles have become the most popular research area. The development of electric vehicles has an important influence on transforming social lifestyle [1] and energy structure [2]. The use of electric vehicles as the autonomous driving control platform has the advantages of easy control and a simple system. As one of the core functions of autonomous vehicles, trajectory tracking control involves the coordinated control of the vehicle steering system, braking system and driving system. As a controlled object including nonlinear factors such as tire, suspension and steering, the strong coupling characteristics between its components, the strong time-varying driving environment and the finite-dimensional control variables of the vehicle system undoubtedly make the trajectory tracking a control problem with high nonlinearity, strong control coupling, strong time-varying state and underdrive. The trajectory tracking aims to control the steering and braking/driving system of the vehicle. The vehicle can realise high-precision tracking of the desired trajectory curve under the conditions of meeting the constraints of vehicle stability, safety and energy consumption economy. Therefore, the trajectory tracking control problem of the autonomous vehicle is an optimisation control problem; that is, considering the vehicle kinematics/dynamics constraints and vehicle driving safety, energy consumption economy and stability, the trajectory tracking is optimised from the longitudinal and lateral control angles.

Literature Review
The design of trajectory tracking controllers based on the classical control theory is undoubtedly one of the efficient and feasible methods to quickly realise the single target tracking problem. In the autonomous vehicle off-road challenge organised by the U.S. Defense Advanced Research Projects Agency (DARPA) in 2005, Stanley of Stanford University successfully won the championship [3], and its lateral tracking controller was designed based on the classical PID control theory, which further verified the feasibility of using the classical PID control to achieve single target tracking. In addition, Nissan [4] designed a feedforward-feedback controller using the classical PID method to realise the tracking control of autonomous vehicle trajectory under continuous speed change and solved the real-time problem of longitudinal and lateral control of the autonomous vehicle. Aiming at the path tracking problem under significant curvature path conditions, a state feedback PID control strategy based on the optimal path was proposed to enhance the robustness of the lateral control system to the change of path curvature [5]. Zhang et al. [6] considered the enormous energy consumption of the suspension robot in the path tracking and optimised the control parameters of the traditional PID controller using the genetic algorithm. Through the online parameter adjustment, the energy consumption of the suspension robot could be significantly reduced when the designed PID controller tracks the same trajectory.
In addition, researchers have also expanded other control algorithms for single target trajectory tracking. Lee and Tomizuka [7] designed the coordinated control algorithm of longitudinal and lateral control based on the robust adaptive control theory and compared the traditional coordinated control algorithm with the longitudinal and lateral decoupling control algorithm. The results showed the superiority of longitudinal and lateral coordinated control of the autonomous vehicle. Brown et al. [8], based on the analysis of the maximum cornering force of the tire and the steady-state characteristics of the vehicle, proposed the planning control method of the slip envelope to continuously approach the driving speed limit of the autonomous vehicle on the premise of preventing the vehicle from slipping. Sisil et al. [9] constructed the RBF neural network adaptive longitudinal and lateral coordinated control strategy and analysed the stability of the control system through Lyapunov theory, which could ensure the uniform convergence and boundedness of tracking error. Zhao et al. [10] proposed a control method based on the expected azimuth deviation estimator and robust PID feedback controller for trajectory tracking control under variable speed conditions and verified that the vehicle had a good trajectory tracking performance under different speed conditions. Hu et al. [11] proposed an H ∞ robust static output feedback control method combining genetic algorithm and linear matrix inequality method to study the tracking problem of an autonomous vehicle. The proposed controller was robust to external disturbances and vehicle/environmental parameter/state uncertainties, including the tire cornering stiffness, the longitudinal vehicle speed, the yaw rate and the road curvature.
Constraint processing and multi-target tracking are inevitable in the trajectory tracking control of the autonomous vehicle in practice, and the extended classical PID control cannot deal with time-varying constraints and multi-target tracking. At present, for the problem of multi constraint processing and multi-target tracking in autonomous vehicle tracking control, model predictive control (MPC) based on optimal control theory is undoubtedly one of the most widely studied and applied control algorithms. In this regard, Song et al. [12] proposed longitudinal and lateral control strategies based on MPC and realised the expected speed and expected path following. Guo et al. [13] established the vehicle kinematics model with the constraints of drivable road area and vehicle geometry, designed the MPC controller, studied the trajectory tracking of autonomous vehicles by using the longitudinal and lateral coupling control method, and completed the effectiveness verification of the control algorithm. Du et al. [14] proposed a nonlinear MPC controller based on the genetic algorithm to control vehicle speed and steering, considering driving safety and comfort, and had a good track following effect. Li et al. [15] proposed the model discretisation method through the pseudospectral approach and presented the simplification method based on modularisation and constraint set compression to reduce the calculation amount of optimisation problems and improve the real-time performance of optimisation solutions.
Sun et al. [16] studied the trajectory tracking control method of the autonomous vehicle, based on the vehicle dynamics model with 6 degrees of freedom (DOF) and integrating the operational stability constraints of the vehicle. Wang et al. [17] designed a predictive control algorithm based on the vehicle dynamics model and simulated annealing model based on the longitudinal and lateral coupling 2DOF vehicle dynamics model. Equality constraints and inequality constraints are set according to the actual driving conditions, and the solution speed of MPC controller can be optimised. Zhang et al. [18], based on the vehicle 3DOF monorail dynamics model, proposed a linear time-varying model predictive path tracking coupling control method and simulated and analysed the real-time performance and robustness of the control algorithm through double line shifting conditions.
According to the differences of vehicle models, the above research on trajectory tracking control of autonomous vehicles based on model predictive control can be divided into simplified vehicle kinematics model-based and vehicle dynamics model-based. The former does not consider the rigid body dynamic constraints such as vehicle tires and the suspension but carries out kinematic analysis and modelling of the vehicle in the plane. It mainly realises the real-time description of vehicle motion law under low model accuracy. It is only suitable for researching non-fully constrained tracking control of autonomous vehicles under low-speed conditions and low requirements for vehicle stability. The latter needs to consider the time-varying characteristics of vehicle tires and describe the vehicle's state more accurately combined with yaw and slide. Under the same conditions, the improvement of model accuracy improves the state tracking accuracy to a great extent, but this is at the cost of dissipating the calculation amount, so the real-time performance of the algorithm is insufficient. When the model is too complex, the real-time requirements of the algorithm will be hard to meet. To improve the measurement accuracy of the vehicle state and realise the online application of predictive control algorithm, an online active setbased longitudinal and lateral model predictive tracking control of autonomous driving is proposed in this paper. Based on ensuring the accuracy of the vehicle model, the complexity of model calculation is reduced. On the other hand, the optimisation set is established to reduce the time required for optimisation.

Contribution
(1) In order to meet the measurement accuracy requirements of vehicle state in tracking control, based on the extended Kalman filter theory, a vehicle state estimator is designed by fusing the information of onboard inertial measurement unit (IMU) and global positioning system (GPS), and the fusion estimation of vehicle state is realised. Based on the coordinate transformation theory, the local coordinate system of the road curve is defined. The road potential field function is also designed, and the potential field compatible with the curve road environment is constructed.
(2) According to the longitudinal and lateral multi-target tracking control requirements of the autonomous vehicle, the longitudinal and lateral error dimensionality reduction in path tracking is designed based on the 3DOF vehicle dynamics model and curved road coordinate system. On this basis, a model predictive tracking controller for longitudinal and lateral multi-objective control of autonomous vehicles is designed.
(3) According to the online application requirements of MPC algorithm, based on the convex optimisation and online active set theory, combined with an open-source solver, a fast-rolling optimisation algorithm for driverless vehicle longitudinal and lateral tracking control is designed and implemented. The effectiveness and tracking of the algorithm's performance are verified and evaluated in the reconstructed curve road scene based on the real GPS data.
Compared to the PID control result, under the proposed MPC, the maximum and average of the front wheel slip angle are reduced by 52.09% and 40.66%, respectively, and the average lateral acceleration of the proposed MPC drops from −0.0606 g to −0.0376 g; the maximum acceleration fell from 0.4549 g to 0.22 g.

Organisation
The remainder of this paper is organised as follows. Section 2 presents the vehicle state estimation, including vehicle dynamics model, state estimator design and EKF-based state estimation. MPC-based longitudinal and lateral tracking control are shown in Section 3, including reference path generation, dimension reduction-based errors calculation, MPC and online active set algorithm. Simulation results and discussions are shown in Section 4. Conclusions, limitations and future works are given in Section 5.

Vehicle State Estimation
The accurate and reliable state estimation is essential for the high-precision tracking control of autonomous driving. The traditional method is implemented by designing the estimator based on tire force estimation with the vehicle dynamics model. Considering that the related vital parameters are difficult to update, the tire model's precision is unreliable. With the advantages of onboard sensing and measurement equipment of autonomous vehicles, the vehicle state estimator is carried out by fusing the information of IMU and GPS with the vehicle dynamics model.

Vehicle Dynamics Model
The 3DOF vehicle dynamics model [19] is introduced and used in Figure 1 for state estimation and prediction, including longitudinal, lateral and yaw rate, respectively. Based on the 3DOF dynamics model with motion equations, the formulations are presented as: where V x and V y are longitudinal and lateral velocities according to the global Cartesian coordinate system in the centroid position of the vehicle; m and δ denote the mass and steering angle of the front tire, respectively; F c,x , F c,y and M c,z represent the longitudinal and lateral equivalent forces and torque of the centroid position according to the vehicle coordinate system. Moreover, the state equation is described as: where v x , v y and ω are the longitudinal and lateral velocities, and yaw rate in vehicle coordinate system, respectively; X, Y and ϕ denote the longitudinal and lateral positions, and the yaw angle in the global Cartesian coordinate system, F x represent the longitudinal force of the front-driving tire; F y, f and F y,r denote the lateral force of front and rear tires, respectively; L f , L r and I z denote the front and rear wheelbases and the vehicle inertia around the vertical axis, respectively.

The Design of the State Estimator
Combining the information of GPS and IMU, the estimation system is described as: where a x , a y and ω IMU are measured by IMU; M c,z is from the tire-force estimation module; X GPS , Y GPS and ϕ GPS are based on GPS.
The state formulations are regulated as: where w i (i = 1, 2, . . . , 6) represents the error of each state variable based on the estimation of (4).
The observation formulations are regulated as: where v i (i = 1, 2, 3, 4) represents the error of each observation variable based on the measurement of (5).

EKF-Based State Estimation
Since (1) includes typical nonlinear formulations, the extended Kalman Filter (EKF) is used for state estimation. The standard formulations of EKF are shown as: where f d is the discrete form of the state function; x(k − 1|k − 1) and P(k − 1|k − 1) denote the last optimal estimation and error covariance matrix, respectively; K g is the coefficient of Kalman gain; I is the identity matrix; T s is the sampling period R = diag(0.04, 0.04, 0.0012, 0.0012) and Q =diag 10 −2 , 10 −2 , 10 −6 , 10 −4 , 10 −4 , 10 −4 represent the covariance matrices of the measure and model systems, respectively.
The Jacobi matrices of the transform and observe formulations are regulated as: where a 1,3 = T s (−x 5 (k)sin x 3 (k) − x 6 (k)cos x 3 (k)) and a 2,3 = T s (x 5 (k)cos x 3 (k)− x 6 (k)sin x 3 (k)). The details of the EKF algorithm are described as shown in Table 1.

Reference Path Generation
The potential field (PF) function of road boundary is defined as: where s and d represent the longitudinal and lateral coordinates in a road coordinate system, respectively; b is a shaping parameter, d Bl and d Br denote the lateral positions of the left and right road boundaries, respectively. The PF function of the target lane is designed as: where d TrgL denotes the lateral distance of ego vehicle and target lane, and a is the shaping parameter.
The PF functions are designed to construct the comprehensive road potential field based on the geometric information of the reference road, as shown in Figure 2. The constructed comprehensive road potential field is shown in Figure 3. In Figure 3, the greater the density of the lines, the higher the road potential field.

Dimension Reduction-Based Errors Calculation
As shown in Figure 4, three coordinates are introduced for path tracking of the autonomous vehicle, including the earth coordinate system, the vehicle and road moving coordinate systems. The earth coordinate system denotes the vehicle position, vehicle heading angle, the waypoints' position and the tangential angle of the trajectory. The vehicle coordinate system is usually used to denote the vehicle states, e.g., longitudinal and lateral velocities, side slip angle, yaw rate, etc. The road coordinate system is based on the Frenet coordinate system [20] to calculate the lateral and heading angle errors between the vehicle motion and reference trajectories. The lateral error can be calculated as: where → r (s, θ r ) denotes the coordinate of target point; → x (s, l) represent the current position of the ego vehicle; (x e , y e ) and (x r , y r ) are the coordinates in the global Cartesian coordinate system, respectively; θ r is the heading angle of the target point in the reference path.
According to the theory of coordinate transform based on (10), the multi-state errors, i.e., the deviations of tracking speed and trajectory at time of t, can be calculated and regulated as: are the reference position, target speed and heading angle at time of t; χ t Y , χ t v x and χ t θ represent the lateral position, speed and heading angle errors, respectively.

Model Predictive Control
The errors can be regulated from (11) as: where C k+1 represent the coordinate transform matrix, the reference and predicted states at the prediction step k + 1, respectively.
Therefore, the errors of the predictive horizon can be regulated as: whereÂ d andB d are the augmented matrices of the prediction formulation; U and Y ref are the vectors of control and reference variables during the prediction horizon. Based on the optimal control theory, a quadratic cost function is designed for the MPC tracking control. The optimisation problem can be described as follows: where Q and R are the weights of the cost terms, k represents the prediction of k th step ahead of t; A d and B d are the discrete matrices of the state-equation based on Euler method; C d denotes the output matrix, y des t+k,t represents the reference path; y t+k,t is the real-time position of the ego vehicle. The Optimal problem is solved by an open-source solver Qp OASES [21].

Online Active Set Algorithm
There are several feasible algorithms for solving convex quadratic programming (QP) problems subject to the linear inequality and equality constraints, such as activeset method [22], interior-point method [23], gradient projection method [24], null space method [25], etc. However, the MPC based embedded optimisation application is strict to the computation time, and usually the period of vehicle control message is 10 ms. For the MPC embedded application of the autonomous vehicle, the online active-set strategy method is introduced to accelerate the solving process and realise the real-time embedded application.
Firstly, combine Equations (13) and (14), and it implies that the primal QP can be presented as a multi-parametric quadratic program (mp-QP), because the gradient ( g T ) of the objective function and the right-hand side of the constraints linearly depend on the parameters (x t,t , u t−1,t , Y re f t ) in the piecewise linearisation area. Consequently, a strictly convex QP problem can be determined and solved, as long as the parameters are determined in the parameter space.
Secondly, solving the continuous piecewise linearised QP problem is equivalent to solving the continuous QP sequence (QPs). If the corresponding parameters of every sub QP can be fast determined in the QPs, the QPs can be fast solved. With this ideal, the online active-set strategy method is used for fast solving the QPs.
The parameter vector of the sub QP is defined as: where w t represents the parameter vector in sampling instant of time t, and the convex set Γ denotes the feasible parameter space.
After elimination of the equality constraints, one rewrites the QP in the general form: Furthermore, the strategy of online active-set is to renew the gradient and constraint boundaries by linearly updating the parameters, as follows: where w 0 ,g, andb are the update of the parameter, gradient and the boundary of the constraints, and τ is the step length along the homotopy of parameter. Θ and P denote the affine matrices during the straight-line moving of the parameter. Based on the proved theorems in [19], the QPs remain feasible and can be solved when the parameter moves along a straight line in the defined parameter space. Above all, with a known initial parameter w 0 and the optimal solution (x * 0 , λ * Λ ), Λ is the corresponding working set, and the following new optimal solution x * new , λ * Λ(new) of QP w new 0 can be fast calculated according to the linear homotopy, which means moving w 0 towards/along a straight line.
The i homotopies is determined as: where M denotes the index of the inequality constraints, x * and λ * define the linear homotopies of the primal and dual optimal solution in n and m dimension space, respectively.Λ andĨ define the linear homotopies of the working set and non-working set in the feasible set. For the strict convex QP problem, the KKT conditions should be satisfied at every value of τ: Since x * (τ) and λ * (τ) are piecewise linear functions and can be defined as: The primal QP is transformed to the equivalent QP and reuse the KKT condition to get the optimal solution ∆x * and λ * Λ , then the optimal solution of QP w new 0 can be fast calculated.
As long as the τ max equals one, the solution of QP w new 0 is found; otherwise the infeasible constraints will be added or removed from the working set (Λ) just like the procedure of the conventional active-set algorithm.

HARDWARE-IN-LOOP
To ensure the effectiveness of the simulation, we built a hardware-in-the-loop simulation platform. The system framework of the hardware-in-the-loop simulation platform based on IPGXpack4, Chassis controller and Autonomous Driving Unit is shown in Figure 5. Among them, virtual test scenes, simulated vehicle models and sensor models are built and configured in TruckMaker and interact with peripherals (including radar, positioning and video signals) through IPGXpack4 (RoadBox). An autonomous Driving Unit is used to carry out the automatic driving tracking control. The acceleration/deceleration and steering control requirements are transmitted to the Chassis controller through the CAN protocol as the control output. Finally, the control demand outputs drive/brake and steering control commands through the Chassis controller and interacts with Xpack4 through CAN to realise the closed-loop control of the virtual actuator. The basic parameters of the vehicle model are in Table 2.

Simulation Results
The reference path is generated for validation and evaluation according to the real GPS data. The target tracking speed is set to 60 km/h, and the constraints of yaw rate and the comfortable acceleration are set to 10 deg/s and 0.2 g, respectively.
In the path tracking control with the target tracking speed set to 60 km/h, the reference trajectory results of the PID controller and the MPC controller are shown in Figure 6a,b, respectively. The lateral and heading errors are shown in Figure 7a,b, respectively. The simulation results show that, at a tracking speed of 60 km/h, both PID control and MPC control meet the requirements of lateral tracking accuracy. The two controllers' lateral and heading errors are within 15 cm and 6 deg, respectively. Thus, compared with the lateral tracking of PID Control, the MPC exhibits better performance. The simulation result of tracking the target speed is shown in Figure 6b. Since a single PID controller can only achieve tracking control of a single target, the PID controller only carries closed-loop control based on the lateral position error feedback without interfering with the vehicle's Longitudinal control. The longitudinal speed of the vehicle always maintains 60 km/h. The tracking control based on MPC controller involves multiple constraint processing and multiple target tracking. In constraint processing, the target speed as a soft constraint can deviate from a particular value at the expense of slack penalty terms to ensure better vehicle stability during path tracking. As shown in Figure 6b, at 28 s, when the vehicle is travelling close to a large curvature curve, if the vehicle is turned at a speed of 60 km/h, the stability and driving safety of the vehicle cannot be guaranteed. In the design of the MPC controller, the yaw rate and lateral acceleration are unbreakable hard constraints on vehicle dynamics. When optimising the objective function in the feasible region, the optimal objective function will be solved at the expense of speed tracking accuracy. When the curvature decreases (after the turn is completed), the longitudinal target speed of the vehicle will be tracked again under the premise of ensuring the accuracy of lateral tracking. Therefore, the tracking control based on MPC is a multi-target coordinated control of the vehicle.  The comparison of the longitudinal and lateral acceleration during the path tracking of the autonomous vehicle is shown in Figure 8. As shown in Figure 8a, the longitudinal acceleration of the vehicle is always 0 in PID control, because only a single lateral tracking target is controlled in the path tracking. The lateral acceleration of PID control is shown by the black line in Figure 8b. The red line shows the longitudinal acceleration control based on the MPC in Figure 8a. To ensure that the vehicle can track stably, comfortably and safely, the path tracking of an autonomous vehicle under the MPC needs to combine the curvature of the reference trajectory and the vehicle stability constraints to control the longitudinal speed of the vehicle accordingly. Compared with the PID-based control, the average lateral acceleration of MPC drops from −0.0606 to −0.0376, the maximum acceleration fell from 0.4549 to 0.22 and the standard deviation decrease from 0.1194 to 0.0682.   The single control step in the controller is distributed in 3-5 ms, which meets the demand of the control response.

Conclusions
To improve the measurement accuracy of the vehicle state in the tracking control, based on the extended Kalman filter theory, we integrated the vehicle GPS and IMU information and designed a vehicle state estimator with three inputs, six states and four outputs. To meet the requirements of multi-target tracking control in the longitudinal and lateral directions of autonomous vehicles, based on the 3DOF vehicle dynamics model and the curvilinear road coordinate system, we carried out dimensionality reduction on the longitudinal and lateral errors in the path tracking. To realise the online application of predictive control algorithm, based on the convex optimisation and the online active set theory with an open source QP solver, we designed and implemented a fast-rolling optimisation algorithm for longitudinal and lateral tracking control of autonomous vehicles and completed the verification of the algorithm and tracking performance in the reconstructed curve road scene based on real GPS data. The hardware-in-the-loop simulation results show that the proposed control can meet the tracking control need of autonomous driving. Compared with the PID-based controller, the proposed MPC controller has apparent advantages in lateral errors, lateral acceleration and front tire slip angle.
In the next step, we will further apply the proposed algorithm on other autonomous vehicles with specific driving environment. Moreover, the proposed strategy will be tested with a specific vehicle controller where the computing resources are limited. In this case, it is demanding to find a cost-efficient solver to trade off the optimization performance and the computing complexity. Acknowledgments: The authors would like to thank the reviewers for their comments and suggestions.  shaping parameter. C d Output matrix.

Conflicts of
τ Step length along the homotopy of parameter.  L f , L r , I z Front wheelbases, rear wheelbases and the vehicle inertia around the vertical axis. w 0 , g , b Update of the parameter, gradient and the boundary of the constraints.