Abstract
This paper presents a Nonlinear Model Predictive Controller (NMPC) for the path following of autonomous vehicles and an algorithm to adaptively adjust the preview distance. The prediction model includes vehicle dynamics, path following dynamics, and system input dynamics. The single-track vehicle model considers the vehicle’s coupled lateral and longitudinal dynamics, as well as nonlinear tire forces. The tracking error dynamics are derived based on the curvilinear coordinates. The cost function is designed to minimize path tracking errors and control effort while considering constraints such as actuator bounds and tire grip limits. An algorithm that utilizes the optimal preview distance vector to query the corresponding reference curvature and reference speed. The length of the preview path is adaptively adjusted based on the vehicle speed, heading error, and path curvature. We validate the controller performance in a simulation environment with the autonomous racing scenario. The simulation results show that the vehicle accurately follows the highly dynamic path with small tracking errors. The maximum preview distance can be prior estimated and guidance the selection of the prediction horizon for NMPC.
Model predict control can predict the future behavior of the system, consider the preview trajectory, and utilize these information to optimize the current control commands. In the model prediction path following controller, the information of the path ahead from vehicle is required. Path preview distance significantly affects the path following performance and several papers have investigated this topic. Zhang et al
This paper implements vehicle path-following control with a non-linear model prediction controller. By considering the nonlinearity of the vehicle dynamics and path following dy-namics, we can accurately predict the future vehicle traveling distance and use the corresponding path curvature and refer- ence speed as the reference. These approaches can improve the path following performance of a vehicle travelling on a path with arbitrary curvature at different speeds.
The layout of the single-track model is shown in
(1a) |
(1b) |
(1c) |

Fig.1 Schematic diagram of the single-track vehicle model. The state variables are in red and the tire forces are in blue, the arrow indicates the positive direction of the corresponding variable
where: δ is the front wheel steer angle; l is the wheelbase, and are the distance from CG to the front and rear axles; the lumped tire force with the subscript {x,y} denotes the longitudinal or lateral direction and {f, r} denotes the front or rear wheel;drag force is the compact aerodynamic coefficient times velocity squared; m is the vehicle mass; is the moment of inertia.
The Simplified Magic Formul
(2a) |
(2b) |
where B, C and D are fitting coefficients. The peak factor D is defined by the first-order function of . The lumped sideslip angles at the front and rear axles are described by:
(3) |
Then the combined tire lateral forces and in (4) are available to substitute into single-track model (1).
(4) |
The longitudinal forces and are composed of rear wheel traction force and all-wheel braking force as following equations:
(5) |
where: is the braking coefficient that determines the force distribution between the front axle and rear axle, we set = to distribute the braking force according to the ratio of axle load. The system inputs are δ, , and , but the large difference in magnitude between these variables may increase numerical instability for an NMPC solver, therefore, the normalized acceleration at and ab are introduced:
(6) |
During racing, we must ensure that the combined tire force is contained within the friction ellipse to avoid large tire slip and loss of grip. Thus the quadratic non-linear constraints are applied:
(7) |
There are upper bounds and lower bounds on the system inputs due to physical limits, these bounds are expressed by inequality constraints as:
(8) |
where: is the maximum total traction torque of rear axle; is the maximum braking torque of each axle; is the effective rolling radius of wheel.In order to achieve optimal actuation efficiency, an equality constraint is imposed,
(9) |
This equation ensures the traction and braking commands are orthogonal, i.e., they are not active at the same time.
The reference path is fitted by a cubic spline function to create a parametric representation. A curvilinear coordinate system is used to describe the relationship between the vehicle position and the reference waypoints (See

Fig.2 Single-track vehicle model in a curvilinear coordinates
The discrete path data set [X, Y] is composed by path coordinates and . Then a spline function X(s) with n equations is used to fit X:
(10) |
where: s is the cumulative arc length starting from s0=0:
(11) |
The higher-order derivative of the spline function with respect to the progressive variable s is easily obtained by:
(12) |
(13) |
Following the above procedure,y(s), y'(s) and y''(s) are also derived based on y. The reference heading angleand the reference curvatureare calculated by:
(14) |
(15) |
where the is the 2-argument arctangent function.
The vehicle CG position is , and the closest waypoint to is defined as “matching point”, , where m is the index of mathtcing point. Then the tracking error vector in global coordinate is defined as:
(16) |
In order to obtain the longitudinal error and the lateral error , the error vector is projected onto the curvilinear coordinate by rotation matrix:
(17) |
where: is the reference heading angle at , the arc length error es can be approximated as longitudinal error in general. Under the assumption that the reference curvature is the same at the matching point and projection point, then the reference heading angle is given by:
(18) |
Consider the vehicle sideslip angle β is regulated in a small value during racing, the course angle can be approximated to heading angle, then the heading error is defined as:
(19) |
In this section, the path following problem is transformed to nonlinear programming (NLP) problem.
The overall control structure of path following is shown in

Fig.3 Control architecture of NMPC path-following
Consider the vehicle dynamics (1), path following dynamics (20), and extended system input dynamics , the prediction model is formulated as (21).Given a prediction horizon Np, is the parameter trajectory composed by the reference curvature at each prediction stage. The first six equations in (21) can predict future vehicle states, path tracking errors, and driving distance. In the last three equations we assign the slew rate of system inputs as extended states,
(21)similar to Ref.[
The multi-step Euler method is used to discrete model in a simple but also precise way:
(22) |
where h =ts/n is the step size of Euler method, with the sampling time ts and the discrete step n. The model is integrated with smaller steps to increase the model prediction accuracy. In this study, h=0.02 s and ts=0.1 s.
The optimal state vector at the prediction step is denoted by
(23) |
The predicted vehicle traveling distances over prediction horizon at the current time step are given by
(24) |
where the first element s0 is the current vehicle traveling distance. To provide the preview vector for the next time step, we remove s0 and add a correction term that predicts one more step by multiplying sampling time with last predicted velocity, yielding preview distance vector,
(25) |
with this approach, the preview distance can be adaptively adjusted based on the predicted vehicle longitudinal velocity in each prediction step. The required preview distance can be prior estimated by
(26) |
The preview distance vector is used to query the corresponding reference curvature and velocity using linear interpolation,
(27) |
(28) |
To stabilize the lateral dynamics, track the reference velocity, and minimize path tracking error, the output vector of NMPC is , and the reference output states at each stage over the prediction horizon Np are given by
(29) |
where denotes the kth element in (25). The reference lateral velocity is derived from the steady-state kinematic sideslip angle, which can be found in Ref.[
Compose tracking and control costs over the prediction horizon, the cost function J to be minimized is defined as:
(30) |
where Sy and Su are square matrices with diagonal scaling factors. Set these factors to the maximum acceptable values of the variables for normalisation. Q is a positive weighting matrix to penalize the difference between reference states and actual system states, R penalizes the control effort to obtain the smooth input trajectory.
Finally we collect cost function, prediction model, and constraints to formulate path-following optimization problem:
(31a) |
(31b) |
(31c) |
(31d) |
where is the estimated or measured states at the current time. All the programs are deployed on a desktop computer with Intel i5-12500 @3.0 GHz processor, and we show that the problem of each step can be solved within milliseconds.
The optimal reference raceline is generated by the minimum curvature algorithm and the corresponding reference speed is generated by the quasi-steady-state lap time simulation tool all these programs are open source and available in Ref.[
The CarSim built-in B-class sports car was used as the test vehicle in this study, which is a neutral-steering vehicle. The main vehicle parameters are: m=1 209 kg; Iz=1 020 kg·

Fig.4 Path tracking result in Cartesian coordinates

Fig.5 Path tracking errors and vehicle states

Fig.6 Maximum preview distance
This paper presents a NMPC for the path following of autonomous vehicles and an algorithm to adaptively adjust the preview distance. The proposed controller scheme coordinates the vehicle’s lateral and longitudinal dynamics to follow the racing line at high speed. By combining path dynamics and vehicle dynamics to build a prediction model for NMPC, path following performance and driving stability are significantly improved. The simulation results show that the vehicle accurately follows the highly dynamic path with small tracking errors.
References
ZHANG C Y, CHU D F, LIU S D, et al. Trajectory planning and tracking for autonomous vehicle based on state lattice and model predictive control[J]. IEEE Intelligent Transportation Systems Magazine, 2019, 11(2): 29. [Baidu Scholar]
WANG H R, WANG Q D, CHEN W W, et al. Path tracking based on model predictive control with variable predictive horizon[J]. Transactions of the Institute of Measurement and Control, 2021, 43(12): 2676. https: //doi.org/10.1177/01423312211003809. [Baidu Scholar]
XU S B, PENG H. Design, analysis, and experiments of preview path tracking control for autonomous vehicles[J]. IEEE Transactions on Intelligent Transportation Systems, 2020, 21(1): 48. [Baidu Scholar]
METZLER M, TAVERNINI D, GRUBER P, et al. On prediction model fidelity in explicit nonlinear model predictive vehicle stability control[J]. IEEE Transactions on Control Systems Technology, 2020, 29(5): 1964. [Baidu Scholar]
LOT R, BIRAL F. A curvilinear abscissa approach for the lap time optimization of racing vehicles[J]. IFAC Proceedings Volumes (19th IFAC World Congress), 2014, 47(3): 7559. https://www.sciencedirect.com/science/article/pii/S1474667016428041. [Baidu Scholar]
Abe M. Vehicle handling dynamics: theory and application[M]. Oxford, UK: Butterworth-Heinemann, 2015. [Baidu Scholar]
Heilmeier A. Quasi-steady-state lap time simulation[DB/OL]. Github Repository, https://github.com/TUMFTM/laptimesimulation. [Baidu Scholar]