Development of a robust lateral control system (Lane Keeping Assist) for autonomous vehicles using Adaptative Linear Quadratic Regulator (LQR). Implemented on SCANeR Studio and MATLAB/Simulink.
![]() Figure 1: Autonomous Road Trajectory Tracking. |
![]() Figure 2: Lane Departure Warning System. |
Source: Mitsubishi Motors Website
This project was developed and validated using the SCANeR Studio co-simulation middleware.
Since the simulation environment is proprietary, the .slx files provided here (if still present) are for algorithmic review and architectural demonstration. They cannot be executed without the specific SCANeR Studio licenses and interfaces.
This project implements a Lane Keeping Assistance (LKA) system for an autonomous vehicle. The goal is to minimize the lateral deviation (
The system was developed and validated using MATLAB/Simulink, interfaced with a driving simulator setup featuring a physical steering wheel and pedals to test the system's performance and driver interactions.
To simulate the vehicle's behavior efficiently, we utilize a 2-Degree-of-Freedom (2-DOF) Bicycle Model. This model simplifies the 4-wheel dynamics by assuming that forces acting on wheels of the same axle are identical, effectively combining them into one equivalent wheel per axle.
The Bicycle Model Dynamic can be written as :
Where:
-
$\psi$ : Yaw angle -
$r = \dot{\psi}$ : Yaw rate -
$v_x, v_y$ : Longitudinal and lateral velocities -
$T_t$ : Traction/Braking torque -
$T_r$ : Rolling resistance torque -
$F_{yf}, F_{yr}$ : Front and rear lateral tire forces -
$f_w$ : Lateral wind force -
$C_x, C_y$ : Longitudinal and lateral aerodynamic drag coefficients -
$I_{eff}, I_z$ : Effective inertia and Yaw inertia
Assuming small slip angles, the lateral tire forces are modeled as linear functions of the slip angles:
With
To implement a linear control strategy (specifically LQR), the system dynamics must be expressed in a linear form. Therefore, the non-linear bicycle model was linearized around a constant operating point
The associated linear dynamic State-Space Model (SSM) can be written as:
Where :
To control the vehicle's position relative to the lane, we must model how the car moves with respect to the road geometry. This introduces the specific Lane Keeping Dynamics.
The system is defined by two key errors:
-
Heading Error (
$\psi_L$ ): The angle difference between where the car is pointing and the actual direction of the road lane. -
Lateral Deviation (
$y_L$ ): The distance separating the vehicle from the center of the lane.
The error dynamics, assuming a small heading error (
Where
At this stage, we establish the global lateral dynamics by combining the linearized bicycle model (1.2) and the lane positioning dynamics (1.3).
To design a controller that minimizes lateral deviation and heading error, we define the state vector
By neglecting the wind effect (
At this stage, the system is designed to control the front wheel steering angle in order to maintain the vehicle at the center of the road.
Before proceeding, we verified that the system is controllable, confirming that a feasible solution exists to stabilize the vehicle dynamics.
By defining the state variables as errors relative to the lane center, the control objective simplifies to a regulation to zero. Driving these errors to null naturally forces the vehicle to converge toward the desired trajectory. (actual_state + desired_state = 0 --> actual_state = desired_state).
To achieve this, I implemented a state-feedback control loop using a Linear Quadratic Regulator (LQR).
The "optimality" of this controller comes from minimizing a cost function
-
$x^T Q x$ : Penalizes state errors (deviation from the center). -
$u^T R u$ : Penalizes the control input (steering magnitude) to ensure smooth driving.
At this stage, the control law
Where
Standard LQR controllers are optimal only around their specific linearization point.
The Challenge:
During initial testing with a fixed controller tuned for
The Solution: To address this, I implemented a Gain Scheduling strategy to cover the operating range.
-
Offline Computation: I linearized the model at multiple velocity setpoints and computed the corresponding optimal gain matrix
$K$ for each point. -
Online Adaptation: During the simulation, the system reads the current vehicle speed (
$v_{x,sim}$ ) and dynamically selects the appropriate gain matrix to ensure optimal stability at any speed. (Through a MATLAN FUNCTION)
Note : The gain scheduling is designed to match realistic driving conditions. Since cornering above 100 km/h is outside the intended operating range, the controller is scheduled up to 100 km/h only.
| Vx,from sim (km/h) | Vx (km/h) | K |
|---|---|---|
| Vehicle speed intervals (from real-time Simulink) |
Linearization speed (operating point) |
LQR controller gain |
| [0, 20] | 10 | K1 = [0.2801 0.2067 1.0665 3.1623] |
| ]20, 40] | 30 | K2 = [1.1957 0.4187 1.7615 3.1623] |
| ]40, 60] | 50 | K3 = [2.0605 0.5083 2.5596 3.1623] |
| ]60, 80] | 70 | K4 = [2.9233 0.5549 3.4047 3.1623] |
| ]80, 100] | 90 | K5 = [3.8056 0.5825 4.2869 3.1623] |
| ]100, +∞[ | 110 | K6 = [4.7138 0.6003 5.2024 3.1623] |
Table 1: LQR gain scheduling based on vehicle longitudinal velocity
Figure: LQR gain scheduling illustration
The simulation loop is closed using SCANeR Studio for the environment and vehicle physics, and MATLAB/Simulink for the control logic.
The diagram below illustrates the control loop implementation. It receives real-time state data from the simulator (
Figure 3: Simulink implementation of the architecture.
To finalize the deployment, the optimal wheel angle
The complete system was fused into a Stateflow logic to handle three distinct driving modes:
- Manual Mode: The driver has full control via the hardware steering wheel and pedals.
- Semi-Autonomous: The driver controls the speed (pedals), while the LQR algorithm manages the trajectory (steering).
- Full Autonomous: The system manages both longitudinal speed and lateral positioning independently.
The project concludes with a complete Co-Simulation setup linking the MATLAB code, the SCANeR Studio physics engine, and a real cockpit (Logitech Steering Wheel & Pedals).
Check out the final demonstration video:

