# Lateral Driver

Lateral path-tracking controller

• Library:
• Vehicle Dynamics Blockset / Vehicle Scenarios / Driver

## Description

The Lateral Driver block implements a control model to generate normalized steering commands that track a lateral reference displacement. The normalized steering commands can vary between -1 to 1. To model the dynamics, the block uses a linear single track (bicycle) model. Use the Lateral Driver block to:

• Close the loop between a predefined path and actual vehicle motion.

• Generate steering commands that track predefined paths. You can connect the Lateral Driver block output to steering block inputs.

### Configurations

External Actions

Use the External Actions parameters to create input ports for signals that can disable, hold, or override the closed-loop steering command. The block uses this priority order for the input commands: disable (highest), hold, override. The block uses this priority order for the input commands: disable (highest), hold, override.

This table summarizes the external action parameters.

Goal

External Action Parameter

Input Ports

Data Type

Override the steering command with an input steering command.

Steering override

`EnblSteerOvr`

`Boolean`

`SteerOvrCmd`

`double`

Hold the steering command at the current value.

Steering hold

`SteerHld``Boolean`

Disable the steering command.

Steering disable

`SteerZero``Boolean`

Use the Output handwheel angle parameter to specify the units for the steering ports.

Setting

Block Implementation

Port

`off` (default)

Commanded steer angle, normalized from -1 through 1. The block uses the tire wheel angle saturation limit Tire wheel angle limit, theta parameter to normalize the command.

`SteerCmd` — Output

Overrides the steering command with an input steering command normalized from -1 through 1.

`SteerOvrCmd` — Input

`on`

Commanded steer angle, in units specified by Angular units, angUnits.

`SteerCmd` — Output

Overrides the steering command with an input steering command, in units specified by Angular units, angUnits.

`SteerOvrCmd` — Input

Also, you can specify a tire wheel angle saturation limit using the Tire wheel angle limit, theta parameter.

Control Type and Units

Use the Lateral control type, controlTypeLat parameter to specify the type of lateral control. The table specifies the block implementation.

Setting

Block Implementation

`Predictive` (default)

Optimal single-point preview (look ahead) control model developed by C. C. MacAdam1, 2, 3. The model represents driver steering control behavior during path-following and obstacle avoidance maneuvers. Drivers preview (look ahead) to follow a predefined path.

`Stanley`

Controller that uses the Stanley4 method to minimize the position error and the angle error of the current pose with respect to the reference pose.

On the Reference Control pane, use the:

• Vector input for poses parameter to input the to specify the input.

SettingImplementation
`off` (default)

Block uses the longitudinal, lateral, and yaw reference (`LongRef`, `LatRef`, `LatRef`) input ports and the feedback (`LongFdbk`, `LatFdbk`, `LatFdbk`) input ports for the reference and feedback pose.

`on`

Block uses input ports, `RefPose` and `CurrPose`, for the reference and feedback pose, respectively.

• Include dynamics parameter to specify the type of model for the controller to use.

SettingImplementation
`off` (default)

Controller uses a kinematic bicycle model that is suitable for path following in low-speed environments such as parking lots, where inertial effects are minimal.

`on`

Controller uses a dynamic bicycle model that is suitable for path following in high-speed environments such as highways, where inertial effects are more pronounced.

Use the Angular units, angUnits parameter to specify the angular units for the input and output ports.

### Controller: Predictive Lateral Path-Tracking

If you set Lateral control type, controlTypeLat to `Predictive`, the Lateral Driver block implements an optimal single-point preview (look ahead) control model developed by C. C. MacAdam1, 2, 3. The model represents driver steering control behavior during path-following and obstacle avoidance maneuvers. Drivers preview (look ahead) to follow a predefined path. To implement the MacAdam model, the block:

• Represents the dynamics as a linear single track (bicycle) vehicle

• Minimizes the previewed error signal at a single point T* seconds ahead in time

• Accounts for the driver lag deriving from perceptual and neuromuscular mechanisms

This figure illustrates the block implementation of the single-point version of the driver model.

Vehicle Dynamics

For lateral and yaw motion, the block implements these linear dynamic equations.

`$\begin{array}{l}\stackrel{˙}{y}=v+U\psi \\ \\ \stackrel{˙}{v}=\left[-\frac{2\left({C}_{\alpha F}+{C}_{\alpha R}\right)}{mU}\right]v+\left[\frac{2\left(b{C}_{\alpha R}-a{C}_{\alpha F}\right)}{mU}-U\right]r+\left(\frac{2{C}_{\alpha F}}{m}\right){\delta }_{F}\\ \\ \stackrel{˙}{r}=\left[\frac{2\left(b{C}_{\alpha R}-a{C}_{\alpha F}\right)}{IU}\right]v+\left[-\frac{2\left({a}^{2}{C}_{\alpha F}+{b}^{2}{C}_{\alpha R}\right)}{IU}\right]r+\left(\frac{2a{C}_{\alpha F}}{I}\right){\delta }_{F}\\ \\ \stackrel{˙}{\psi }=r\end{array}$`

In matrix notation:

`$\begin{array}{l}\stackrel{˙}{x}=Fx+g{\delta }_{F}\\ \\ \text{where:}\\ \\ x=\left[\begin{array}{l}y\\ v\\ r\\ \psi \end{array}\right]\\ F=\left[\begin{array}{cccc}0& 1& 0& U\\ 0& \text{-2}\frac{{C}_{\alpha F}+{C}_{\alpha R}}{mU}& \text{2}\frac{b{C}_{\alpha R}-a{C}_{\alpha F}}{mU}-U& 0\\ 0& \text{2}\frac{b{C}_{\alpha R}-a{C}_{\alpha F}}{IU}& \text{-2}\frac{{a}^{2}{C}_{\alpha F}+{b}^{2}{C}_{\alpha R}}{IU}& 0\\ 0& 0& 1& 0\end{array}\right]\\ x=\left[\begin{array}{l}0\\ \frac{2{C}_{\alpha F}}{m}\\ \frac{2a{C}_{\alpha F}}{I}\\ 0\end{array}\right]\end{array}$`

The single-point model assumes a minimum previewed error signal at a single point T* seconds ahead in time. a* is the driver ability to predict the future vehicle response based on the current steering control input. b* is the driver ability to predict the future vehicle response based on the current vehicle state. The block uses these equations.

The equations use these variables.

 a, b Forward and rearward tire location, respectively m Vehicle mass I Vehicle rotational inertia CɑF Front tire cornering coefficient CɑR Rear tire cornering coefficient a*, b* Driver prediction scalar and vector gain, respectively x Predicted vehicle state vector v Lateral velocity r Yaw rate Ψ Front wheel heading angle y Lateral displacement F System matrix δ, δF Steer angle and front axle steer angle, respectively g Control coefficient vector U Forward (longitudinal) vehicle velocity T* Preview time window ƒ(t+T*) Previewed path input T* seconds ahead U Forward vehicle velocity mT Constant observer vector; provides vehicle lateral position

Optimization

The single-point model implemented by the block finds the steering command that minimizes a local performance index, J, over the current preview interval, (t, t+T).

`$J=\frac{1}{T}{\int }_{t}^{t+T}{\left[f\left(\eta \right)-y\left(\eta \right)\right]}^{2}d\eta$`

To minimize J with respect to the steering command, this condition must be met.

`$\frac{dJ}{du}=0$`

You can express the optimal control solution in terms of a current non-optimal and corresponding nonzero preview output error T* seconds ahead1, 2, 3.

`${u}^{o}\left(t\right)=u\left(t\right)+\frac{e\left(t+{T}^{*}\right)}{{a}^{*}}$`

The block uses the preview distance and vehicle longitudinal velocity to determine the preview time window.

`${T}^{*}=\frac{L}{U}$`

The equations use these variables.

 T* Preview time window ƒ(t+T*) Previewed path input T* sec ahead y(t+T*) Previewed plant output T* sec ahead e(t+T*) Previewed error signal T* sec ahead u(t), uo(t) Steer angle and optimal steer angle, respectively L Preview distance J Performance index U Forward (longitudinal) vehicle velocity

Driver Lag

The single-point model implemented by the block introduces a driver lag. The driver lag accounts for the delay when the driver is tracking tasks. Specifically, it is the transport delay deriving from perceptual and neuromuscular mechanisms. To calculate the driver transport delay, the block implements this equation.

`$H\left(s\right)={e}^{-s\tau }$`

The equations use these variables.

 τ Driver transport delay y(t+T*) Previewed plant output T* sec ahead e(t+T*) Previewed error signal T* sec ahead u(t), uo(t) Steer angle and optimal steer angle, respectively J Performance index

### Controller: Stanley Lateral Path-Tracking

If you set Lateral control type, controlTypeLat to `Stanley`, the block implements the Stanley method4. To compute the steering angle command, the Stanley controller minimizes the position error and the angle error of the current pose with respect to the reference pose. The driving direction of the vehicle determines these error values.

To compute the steering angle command, the controller minimizes the position error and the angle error of the current pose with respect to the reference pose.

• The position error is the lateral distance from the vehicle center-of-gravity (CG) to the reference point on the path.

• The angle error is the angle of the vehicle with respect to reference path.

## Ports

### Input

expand all

Longitudinal center of mass (CM) displacement reference, in the inertial reference frame, in m.

#### Dependencies

To enable this port:

• Set Lateral control type, controlTypeLat to `Stanley`

• Clear Vector input for poses

Lateral center of mass (CM) displacement reference, in the inertial reference frame, in m.

#### Dependencies

To enable this port, do either of these:

• Set Lateral control type, controlTypeLat to `Stanley` and clear Vector input for poses.

• Set Lateral control type, controlTypeLat to `Predictive`.

Enable steering command override.

#### Dependencies

To enable this port, select Steering override.

Data Types: `Boolean`

Steering override command.

Use the Output handwheel angle parameter to specify the units for the steering ports.

Setting

Block Implementation

Port

`off` (default)

Commanded steer angle, normalized from -1 through 1. The block uses the tire wheel angle saturation limit Tire wheel angle limit, theta parameter to normalize the command.

`SteerCmd` — Output

Overrides the steering command with an input steering command normalized from -1 through 1.

`SteerOvrCmd` — Input

`on`

Commanded steer angle, in units specified by Angular units, angUnits.

`SteerCmd` — Output

Overrides the steering command with an input steering command, in units specified by Angular units, angUnits.

`SteerOvrCmd` — Input

#### Dependencies

To enable this port, select Steering override.

Data Types: `double`

Boolean signal that holds the steering command at the current value.

#### Dependencies

To enable this port, select Steering hold.

Data Types: `Boolean`

Disable steering command.

#### Dependencies

To enable this port, select Steering disable.

Data Types: `Boolean`

Vehicle yaw angle, Ψo, in the inertial reference frame, in units specified by Angular units, angUnits.

#### Dependencies

To enable this port:

• Set Lateral control type, controlTypeLat to `Stanley`

• Clear Vector input for poses

Reference pose, specified as an [x, y, Θ] vector. x and y are in meters, and Θ are in units specified by Angular units, angUnits.

x and y specify the reference point to steer the vehicle toward. Θ specifies the orientation angle of the path at this reference point and is positive in the counterclockwise direction.

The reference point is the point on the path that is closest to the vehicle CG. You can use the either the Z-up or Z-down vehicle coordinate system, as long you use the same coordinate system (Z-up or Z-down) for block inputs and parameters.

#### Dependencies

To enable this port, set Lateral control type, controlTypeLat to `Stanley` and select Vector input for poses.

Data Types: `single` | `double`

Longitudinal vehicle velocity, U, in the vehicle-fixed frame, in m/s.

Current pose of the vehicle, specified as an [x, y, Θ] vector. x and y are in meters, and Θ is in units specified by Angular units, angUnits.

x and y specify the location of the vehicle, which is defined as the vehicle CG. You can use the either the Z-up or Z-down vehicle coordinate system, as long you use the same coordinate system (Z-up or Z-down) for block inputs and parameters.

#### Dependencies

To enable this port, set Lateral control type, controlTypeLat to `Stanley` and select Vector input for poses.

Data Types: `single` | `double`

Lateral CM displacement, yo, in the inertial reference frame, in m.

#### Dependencies

To enable this port, do either of these:

• Set Lateral control type, controlTypeLat to `Stanley` and clear Vector input for poses.

• Set Lateral control type, controlTypeLat to `Predictive`.

Lateral vehicle velocity, vo , in the vehicle-fixed frame, in m/s.

#### Dependencies

To enable this port, Set Lateral control type, controlTypeLat to `Predictive`.

Vehicle yaw angle, Ψo, in the inertial reference frame, in units specified by Angular units, angUnits.

#### Dependencies

To enable this port, do either of these:

• Set Lateral control type, controlTypeLat to `Stanley` and clear Vector input for poses.

• Set Lateral control type, controlTypeLat to `Predictive`.

Yaw rate, ro, in the vehicle-fixed frame, in units specified by Angular units, angUnits per sec.

#### Dependencies

To enable this port, Set Lateral control type, controlTypeLat to `Predictive`.

### Output

expand all

Bus signal containing these block calculations.

SignalVariableDescription
`Predicted``y`y

Predicted lateral displacement, in the vehicle-fixed frame.

`ydot`v

Predicted lateral velocity, in the vehicle-fixed frame.

`psi`Ψ

Predicted front wheel heading angle.

`r`r

Predicted yaw rate, in the vehicle-fixed frame.

`SteerCmd`δF

Commanded steer angle.

`Err`eref

Difference in reference vehicle position and vehicle position.

`ErrSqrSum`$\underset{0}{\overset{t}{\int }}{e}_{ref}{}^{2}dt$

Integrated square of error.

`ErrMax`$\mathrm{max}\left({e}_{ref}\left(t\right)\right)$

Maximum error during simulation.

`ErrMin`$\mathrm{min}\left({e}_{ref}\left(t\right)\right)$

Minimum error during simulation.

`ExtActions``EnblSteerOvr`

Override the steering command with an input deceleration command.

`SteerOvrCmd`

Input steering override command

`SteerHld`

Hold the steering command at the current value

`SteerZero`

Disable the steering command

Commanded steer angle, δF.

Use the Output handwheel angle parameter to specify the units for the steering ports.

Setting

Block Implementation

Port

`off` (default)

Commanded steer angle, normalized from -1 through 1. The block uses the tire wheel angle saturation limit Tire wheel angle limit, theta parameter to normalize the command.

`SteerCmd` — Output

Overrides the steering command with an input steering command normalized from -1 through 1.

`SteerOvrCmd` — Input

`on`

Commanded steer angle, in units specified by Angular units, angUnits.

`SteerCmd` — Output

Overrides the steering command with an input steering command, in units specified by Angular units, angUnits.

`SteerOvrCmd` — Input

## Parameters

expand all

### Configuration

Select to override the steering command with an input steering command.

#### Dependencies

Selecting this parameter creates the `EnblSteerOvr` and `SteerOvrCmd` input ports.

Select to hold the steering command.

#### Dependencies

Selecting this parameter creates the `SteerHld` input port.

Select to disable the steering command.

#### Dependencies

Selecting this parameter creates the `SteerZero` input port.

Use the Output handwheel angle parameter to specify the units for the steering ports.

Setting

Block Implementation

Port

`off` (default)

Commanded steer angle, normalized from -1 through 1. The block uses the tire wheel angle saturation limit Tire wheel angle limit, theta parameter to normalize the command.

`SteerCmd` — Output

Overrides the steering command with an input steering command normalized from -1 through 1.

`SteerOvrCmd` — Input

`on`

Commanded steer angle, in units specified by Angular units, angUnits.

`SteerCmd` — Output

Overrides the steering command with an input steering command, in units specified by Angular units, angUnits.

`SteerOvrCmd` — Input

#### Dependencies

To create the `SteerOvrCmd` input port, select Steering override.

Use the Lateral control type, controlTypeLat parameter to specify the type of lateral control. The table specifies the block implementation.

Setting

Block Implementation

`Predictive` (default)

Optimal single-point preview (look ahead) control model developed by C. C. MacAdam1, 2, 3. The model represents driver steering control behavior during path-following and obstacle avoidance maneuvers. Drivers preview (look ahead) to follow a predefined path.

`Stanley`

Controller that uses the Stanley4 method to minimize the position error and the angle error of the current pose with respect to the reference pose.

On the Reference Control pane, use the:

• Vector input for poses parameter to input the to specify the input.

SettingImplementation
`off` (default)

Block uses the longitudinal, lateral, and yaw reference (`LongRef`, `LatRef`, `LatRef`) input ports and the feedback (`LongFdbk`, `LatFdbk`, `LatFdbk`) input ports for the reference and feedback pose.

`on`

Block uses input ports, `RefPose` and `CurrPose`, for the reference and feedback pose, respectively.

• Include dynamics parameter to specify the type of model for the controller to use.

SettingImplementation
`off` (default)

Controller uses a kinematic bicycle model that is suitable for path following in low-speed environments such as parking lots, where inertial effects are minimal.

`on`

Controller uses a dynamic bicycle model that is suitable for path following in high-speed environments such as highways, where inertial effects are more pronounced.

Input and output port angular units.

### Reference Control

Predictive

Driver response time, τ, in s.

#### Dependencies

To enable this parameter, Set Lateral control type, controlTypeLat to `Predictive`.

Driver preview distance, L, in m. Used to determine the preview time window, T*.

#### Dependencies

To enable this parameter, Set Lateral control type, controlTypeLat to `Predictive`.

Stanley

Select this parameter to create the `RefPose` and `CurrPose` input ports.

#### Dependencies

To enable this parameter, Set Lateral control type, controlTypeLat to `Stanley`.

The controller computes this command using the Stanley method, whose control law is based on both a kinematic and dynamic bicycle model. To change between models, use this parameter.

SettingImplementation
`off`

Controller uses a kinematic bicycle model that is suitable for path following in low-speed environments such as parking lots, where inertial effects are minimal.

`on`

Controller uses a dynamic bicycle model that is suitable for path following in high-speed environments such as highways, where inertial effects are more pronounced.

#### Dependencies

To enable this parameter, Set Lateral control type, controlTypeLat to `Stanley`.

Position gain of the vehicle when it is in forward motion, specified as a positive scalar. This value determines how much the position error affects the steering angle. Typical values are in the range [1, 5]. Increase this value to increase the magnitude of the steering angle.

#### Dependencies

To enable this parameter, Set Lateral control type, controlTypeLat to `Stanley`.

Position gain of the vehicle when it is in reverse motion, specified as a positive scalar. This value determines how much the position error affects the steering angle. Typical values are in the range [1, 5]. Increase this value to increase the magnitude of the steering angle.

#### Dependencies

To enable this parameter, Set Lateral control type, controlTypeLat to `Stanley`.

Yaw rate feedback gain, specified as a nonnegative real scalar. This value determines how much weight is given to the current yaw rate of the vehicle when the block computes the steering angle command.

#### Dependencies

To enable this parameter, Set Lateral control type, controlTypeLat to `Stanley` and select Include dynamics.

Steering angle feedback gain, specified as a nonnegative real scalar. This value determines how much the difference between the current steering angle command, SteerCmd, and the current steering angle, CurrSteer, affects the next steering angle command.

#### Dependencies

To enable this parameter, Set Lateral control type, controlTypeLat to `Stanley` and select Include dynamics.

Vehicle Parameters

Forward location of tire, a, in m. Distance from vehicle cg to forward tire location, along vehicle longitudinal axis.

Rearward location of tire, b, in m. Absolute value of distance from vehicle cg to rearward tire location, along vehicle longitudinal axis.

Vehicle mass, m, in kg.

#### Dependencies

To enable this port, do either of these:

• Set Lateral control type, controlTypeLat to `Stanley` and select Include dynamics.

• Set Lateral control type, controlTypeLat to `Predictive`.

Cornering stiffness coefficient, CαF , in N/rad.

#### Dependencies

To enable this port, do either of these:

• Set Lateral control type, controlTypeLat to `Stanley` and select Include dynamics.

• Set Lateral control type, controlTypeLat to `Predictive`.

Cornering stiffness coefficient, CαR , in N/rad.

#### Dependencies

To enable this port, set Lateral control type, controlTypeLat to `Predictive`.

Vehicle rotational inertia, I, about the vehicle yaw axis, in N·m·s^2.

#### Dependencies

To enable this parameter, Set Lateral control type, controlTypeLat to `Predictive`.

Steering ratio, Ksteer. The value has no dimension.

#### Dependencies

To enable this parameter, select Output handwheel angle.

Tire wheel angle limit, θ, in rad.

## References

[1] MacAdam, C. C. "An Optimal Preview Control for Linear Systems". Journal of Dynamic Systems, Measurement, and Control. Vol. 102, Number 3, Sept. 1980.

[2] MacAdam, C. C. "Application of an Optimal Preview Control for Simulation of Closed-Loop Automobile Driving ". IEEE Transactions on Systems, Man, and Cybernetics. Vol. 11, Issue 6, June 1981.

[3] MacAdam, C. C. Development of Driver/Vehicle Steering Interaction Models for Dynamic Analysis. Final Technical Report UMTRI-88-53. Ann Arbor, Michigan: The University of Michigan Transportation Research Institute, Dec. 1988.

[4] Hoffmann, Gabriel M., Claire J. Tomlin, Michael Montemerlo, and Sebastian Thrun. "Autonomous Automobile Trajectory Tracking for Off-Road Driving: Controller Design, Experimental Validation and Racing." American Control Conference. 2007, pp. 2296–2301. doi:10.1109/ACC.2007.4282788

## Version History

Introduced in R2018a