User's Guide: Vehicle Dynamics Blockset™
User's Guide: Vehicle Dynamics Blockset™
User's Guide
R2021a
How to Contact MathWorks
Phone: 508-647-7000
Getting Started
1
Vehicle Dynamics Blockset Product Description . . . . . . . . . . . . . . . . . . . . 1-2
Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Coordinate Systems
2
Coordinate Systems in Vehicle Dynamics Blockset . . . . . . . . . . . . . . . . . . 2-2
Earth-Fixed (Inertial) Coordinate System . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Vehicle Coordinate System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
Tire and Wheel Coordinate Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
World Coordinate System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Reference Applications
3
Passenger Vehicle Dynamics Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
iii
Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Passenger Vehicle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
iv Contents
Project Templates
4
Vehicle Dynamics Blockset Project Templates . . . . . . . . . . . . . . . . . . . . . . 4-2
Maneuver Standards
5
ISO 15037-1:2006 Standard Measurement Signals . . . . . . . . . . . . . . . . . . 5-2
Supporting Data
6
Support Package For Maneuver and Drive Cycle Data . . . . . . . . . . . . . . . . 6-2
v
Vehicle Dynamics Blockset Examples
7
Scene Interrogation with Camera and Ray Tracing Reference Application
.......................................................... 7-2
3D Simulation
8
3D Simulation for Vehicle Dynamics Blockset . . . . . . . . . . . . . . . . . . . . . . 8-2
3D Simulation Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Algorithm Testing and Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
vi Contents
Run Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-41
vii
1
Getting Started
1 Getting Started
Vehicle Dynamics Blockset™ provides fully assembled reference application models that simulate
driving maneuvers in a 3D environment. You can use the prebuilt scenes to visualize roads, traffic
signs, trees, buildings, and other objects around the vehicle. You can customize the reference models
by using your own data or by replacing a subsystem with your own model. The blockset includes a
library of components for modeling propulsion, steering, suspension, vehicle bodies, brakes, and
tires.
Vehicle Dynamics Blockset provides a standard model architecture that can be used throughout the
development process. It supports ride and handling analyses, chassis controls development, software
integration testing, and hardware-in-the-loop testing. By integrating vehicle dynamics models with a
3D environment, you can test ADAS and automated driving perception, planning, and control
software. These models let you test your vehicle with standard driving maneuvers such as a double
lane change or with your own custom scenarios.
Key Features
• Preassembled vehicle dynamics models for passenger cars and trucks
• Preassembled maneuvers for common ride and handling tests, including a double-lane change
• 3D environment for visualizing simulations and communicating scene information to Simulink®
• Libraries of propulsion, steering, suspension, vehicle body, brake, and tire components
• Combined longitudinal and lateral slip dynamic tire models
• Predictive driver model for generating steering commands that track a predefined path
• Prebuilt 3D scenes, including straight roads, curved roads, and parking lots
1-2
Acknowledgements
Acknowledgements
• Vehicle Dynamics Blockset uses the Unreal® Engine. Unreal® is a trademark or registered
trademark of Epic Games®, Inc. in the United States of America and elsewhere.
Unreal® Engine, Copyright 1998–2021, Epic Games, Inc. All rights reserved.
• Vehicle Dynamics Blockset uses fitted tire data sets provided by the Global Center for Automotive
Performance Simulation (GCAPS). GCAPS uses advanced physical data collection to develop tire
models that cover a broad range of vehicle and environmental conditions.
1-3
1 Getting Started
Required Products
Vehicle Dynamics Blockset product requires current versions of these products:
• MATLAB
• Simulink
Recommended Products
You can extend the capabilities of the Vehicle Dynamics Blockset using the following recommended
products.
See Also
More About
• “3D Visualization Engine Requirements and Limitations” on page 8-6
1-4
Engine Calibration Maps
To develop the calibration maps for engine plant models in the reference applications, MathWorks®
developed and used processes to measure performance data from 1.5–L spark-ignition (SI) and
compression-ignition (CI) engine models provided by Gamma Technologies LLC.
To represent the behavior of engine plants specific to your application, you can develop your own
engine calibration maps. The data required for calibration typically comes from engine dynamometer
tests or engine hardware design models.
To develop the calibration maps in the engine plant models, MathWorks used GT-POWER models from
the GT-SUITE modeling library in a Simulink-based virtual dynamometer. MathWorks used the Model-
Based Calibration Toolbox to create design-of-experiment (DoE) test plans. The Simulink-based virtual
dynamometer executed the DoE test plan on GT-POWER 1.5–L SI and CI reference engines.
MathWorks used the Model-Based Calibration Toolbox to develop the engine plant model calibration
maps from the GT-POWER.
1-5
1 Getting Started
Engine air Engine air mass Mapped CI The air mass flow lookup table is a function of
mass flow flow as a Engine commanded fuel mass and engine speed, ṁintk =
function of ƒ(Fmax, N), where:
commanded
fuel mass and • ṁintk is engine air mass flow, in kg/s.
engine speed
• Fmax is commanded fuel mass, in mg per injection.
• N is engine speed, in rpm.
1-6
Engine Calibration Maps
Engine Engine exhaust Mapped CI The engine exhaust temperature table is a function of
exhaust temperature as Engine commanded fuel mass and engine speed, Texh= ƒ(F, N),
temperature a function of where:
commanded
fuel mass and • Texhis exhaust temperature, in K.
engine speed • F is commanded fuel mass, in mg per injection.
• N is engine speed, in rpm.
1-7
1 Getting Started
1-8
Engine Calibration Maps
Engine-out EO nitric oxide Mapped CI The engine-out nitric oxide and nitrogen dioxide
(EO) nitric and nitrogen Engine emissions are a function of commanded fuel mass and
oxide and dioxide engine speed, EO NOx= ƒ(F, N), where:
nitrogen emissions as a
dioxide function of • EO NOx is engine-out nitric oxide and nitrogen
commanded dioxide emissions, in kg/s.
fuel mass and • F is commanded fuel mass, in mg per injection.
engine speed • N is engine speed, in rpm.
1-9
1 Getting Started
1-10
Engine Calibration Maps
Engine fuel Engine fuel flow Mapped SI The engine fuel mass flow lookup table is a function of
flow as a function of Engine commanded engine torque and engine speed,
commanded MassFlow = ƒ(Tcmd, N), where:
torque mass
and engine • MassFlow is engine fuel mass flow, in kg/s.
speed • Tcmd is commanded engine torque, in N·m.
• N is engine speed, in rpm.
1-11
1 Getting Started
1-12
Engine Calibration Maps
1-13
1 Getting Started
See Also
Mapped CI Engine | Mapped SI Engine
1-14
Engine Calibration Maps
External Websites
• Virtual Engine Calibration: Making Engine Calibration Part of the Engine Hardware Design
Process
1-15
1 Getting Started
ISO 3888-2 defines the double-lane change maneuver to test the obstacle avoidance performance of a
vehicle. In the test, the driver:
Typically, cones mark the lane boundaries. If the vehicle and driver can negotiate the maneuver
without hitting a cone, the vehicle passes the test.
For more information about the reference application, see “Double-Lane Change Maneuver” on page
3-14.
helpersetupdlc;
1. Open the Lane Change Reference Generator block. By default, the maneuver is set with these
parameters:
1-16
Yaw Stability on Varying Road Surfaces
2. In the Visualization subsystem, open the 3D Engine block. By default, the 3D Engine parameter is
set to Disabled. For the 3D visualization engine platform requirements and hardware
recommendations, see the “3D Visualization Engine Requirements and Limitations” on page 8-6.
3. Run the maneuver. As the simulation runs, view the vehicle information.
mdl = 'DLCReferenceApplication';
sim(mdl);
Build Summary
1-17
1 Getting Started
• In the Vehicle Position window, view the vehicle longitudinal distance as a function or the lateral
distance.
• In the Visualization subsystem, open the Lane Change scope block to display the lateral
displacement as a function of time. The red and orange lines mark the cone boundaries. The blue
line marks the reference trajectory and the green line marks the actual trajectory. The green line
does come close to the red line that marks the cones.
1-18
Yaw Stability on Varying Road Surfaces
• In the Visualization subsystem, if you enable the 3D Engine block visualization environment, you
can view the vehicle response in the AutoVrtlEnv window.
Run the reference application on three road surfaces with different friction scaling coefficients. Use
the results to analyze the yaw stability and help determine the success of the maneuver.
2. Enable signal logging for the velocity, lane, and ISO signals. You can use the Simulink® editor or,
alternatively, these MATLAB® commands. Save the model.
• Enable signal logging for the Lane Change Reference Generator outport Lane signal.
1-19
1 Getting Started
mdl = 'DLCReferenceApplication';
ph=get_param('DLCReferenceApplication/Lane Change Reference Generator','PortHandles');
set_param(ph.Outport(1),'DataLogging','on');
• Enable signal logging for the Passenger Vehicle block outport signal.
ph=get_param('DLCReferenceApplication/Passenger Vehicle','PortHandles');
set_param(ph.Outport(1),'DataLogging','on');
• In the Visualization subsystem, enable signal logging for the ISO block.
3. Set up a vector with the friction scaling coefficients, lambdamu, that you want to investigate. For
example, to examine friction scaling coefficients equal to 0.9, 0.95, and 1.0, at the command line
enter:
1-20
Yaw Stability on Varying Road Surfaces
4. Create an array of simulation inputs that sets lambdamu equal to the Friction constant block
parameter.
5. Set the simulation stop time at 25 s. Save the model and run the simulations. If available, use
parallel computing.
set_param(mdl,'StopTime','25')
save_system(mdl)
tic;
simout = parsim(in,'ShowSimulationManager','on');
toc;
1-21
1 Getting Started
6. After the simulations complete, close the Simulation Data Inspector windows.
Use the Simulation Data Inspector to examine the results. You can use the UI or, alternatively,
command-line functions.
1. Open the Simulation Data Inspector. On the Simulink Toolstrip, on the Simulation tab, under
Review Results, click Data Inspector.
• In the Import dialog box, clear logsout. Select simout(1), simout(2), and simout(3).
Select Import.
1-22
Yaw Stability on Varying Road Surfaces
2. Alternatively, use these MATLAB commands to create 6 plots. The first three plots mark the upper
lane boundary, UB, lower lane boundary, LB, and lateral vehicle distance, Y, for each run.
The next three plots provide the lateral acceleration, ay, lateral vehicle distance, Y, and yaw rate, r,
for each run.
1-23
1 Getting Started
plotOnSubPlot(lbsignal(idx),(idx),1,true);
plotOnSubPlot(ysignal(idx),(idx),1,true);
end
for idx = 1:numExperiments
% Plot the lateral acceleration, position, and yaw rate
plotOnSubPlot(asignal(idx),1,2,true);
plotOnSubPlot(ysignal(idx),2,2,true);
plotOnSubPlot(rsignal(idx),3,2,true);
end
The results are similar to these plots, which indicate that the vehicle has a yaw rate of about .66
rad/s when the friction scaling coefficient is equal to 1.
Further Analysis
To explore the results further, use these commands to extract the lateral acceleration, steering angle,
and vehicle trajectory from the simout object.
1. Extract the lateral acceleration and steering angle. Plot the data. The results are similar to this
plot. They indicate that the greatest lateral acceleration occurs when the friction scaling coefficient is
1.
figure
for idx = 1:numExperiments
% Extract Data
log = get(simout(idx),'logsout');
sa=log.get('Steering-wheel angle').Values;
ay=log.get('Lateral acceleration').Values;
legend_labels{idx} = ['lambdamu = ', num2str(lambdamu(idx))];
% Plot steering angle vs. lateral acceleration
1-24
Yaw Stability on Varying Road Surfaces
plot(sa.Data,ay.Data)
hold on
end
% Add labels to the plots
legend(legend_labels, 'Location', 'best');
title('Lateral Acceleration')
xlabel('Steering Angle [deg]')
ylabel('Acceleration [m/s^2]')
grid on
2. Extract the vehicle path. Plot the data. The results are similar to this plot. They indicate that the
greatest lateral vehicle position occurs when the friction scaling coefficient is 0.9.
figure
for idx = 1:numExperiments
% Extract Data
log = get(simout(idx),'logsout');
x = log{3}.Values.Body.InertFrm.Cg.Disp.X.Data;
y = log{3}.Values.Body.InertFrm.Cg.Disp.Y.Data;
legend_labels{idx} = ['lambdamu = ', num2str(lambdamu(idx))];
% Plot vehicle location
plot(y,x)
hold on
end
% Add labels to the plots
legend(legend_labels, 'Location', 'best');
title('Vehicle Path')
xlabel('Y Position [m]')
1-25
1 Getting Started
See Also
Simulink.SimulationInput | Simulink.SimulationOutput
References
[1] ISO 3888-2: 2011. Passenger cars — Test track for a severe lane-change manoeuvre.
See Also
Related Examples
• “Send and Receive Double-Lane Change Scene Data” on page 3-81
More About
• “Double-Lane Change Maneuver” on page 3-14
• “How 3D Simulation for Vehicle Dynamics Blockset Works” on page 8-8
• Simulation Data Inspector
1-26
Vehicle Steering Gain at Different Speeds
For more information about the reference application, see “Slowly Increasing Steering Maneuver” on
page 3-43.
helpersetupsis;
1. Open the Swept Sine Reference Generator block. By default, the maneuver is set with these
parameters:
1-27
1 Getting Started
2. In the Visualization subsystem, open the 3D Engine block. By default, the 3D Engine parameter is
set to Disabled. For the 3D visualization engine platform requirements and hardware
recommendations, see the “3D Visualization Engine Requirements and Limitations” on page 8-6.
3. Run the maneuver with the default settings. As the simulation runs, view the vehicle information.
mdl = 'ISReferenceApplication';
sim(mdl);
Build Summary
1-28
Vehicle Steering Gain at Different Speeds
• In the Vehicle Position window, view the vehicle longitudinal distance as a function or the lateral
distance. The yellow line displays the yaw rate. The blue line shows the steering angle.
• In the Visualization subsystem, open the Yaw Rate and Steer Scope block to display the yaw rate
and steering angle versus time.
1-29
1 Getting Started
Run the slowly increasing steering angle reference application with three different speed set points.
1. In the slowly increasing steering reference application model ISReferenceApplication, open the
Slowly Increasing Steer block. The Longitudinal speed set point, xdot_r block parameter sets the
vehicle speed. By default, the speed is 50 mph.
2. Enable signal logging for the velocity, lane, and ISO signals. You can use the Simulink® editor or,
alternatively, these MATLAB® commands. Save the model.
• Enable signal logging for the Slowly Increasing Steer Ref signal outport.
1-30
Vehicle Steering Gain at Different Speeds
mdl = 'ISReferenceApplication';
ph=get_param('ISReferenceApplication/Slowly Increasing Steer','PortHandles');
set_param(ph.Outport(1),'DataLogging','on');
• Enable signal logging for the Passenger Vehicle block outport signal.
ph=get_param('ISReferenceApplication/Passenger Vehicle','PortHandles');
set_param(ph.Outport(1),'DataLogging','on');
• In the Visualization subsystem, enable signal logging for the ISO block.
3. Set up a speed set point vector, xdot_r, that you want to investigate. For example, at the
command line, type:
vmax = [45, 50, 55];
numExperiments = length(vmax);
4. Create an array of simulation inputs that set the Swept Sine Reference Generator block parameter
Steering amplitude, theta_hw equal to amp.
for idx = numExperiments:-1:1
in(idx) = Simulink.SimulationInput(mdl);
in(idx) = in(idx).setBlockParameter([mdl '/Slowly Increasing Steer'], ...
'xdot_r', num2str(vmax(idx)));
end
5. Save the model and run the simulations. If available, use parallel computing.
save_system(mdl)
tic;
1-31
1 Getting Started
simout = parsim(in,'ShowSimulationManager','on');
toc;
6. After the simulations complete, close the Simulation Data Inspector windows.
Use the Simulation Data Inspector to examine the results. You can use the UI or, alternatively,
command-line functions.
1. Open the Simulation Data Inspector. On the Simulink Toolstrip, on the Simulation tab, under
Review Results, click Data Inspector.
• In the Import dialog box, clear logsout. Select simout(1), simout(2), and simout(3).
Select Import.
1-32
Vehicle Steering Gain at Different Speeds
2. Alternatively, use these MATLAB commands to plot the longitudinal velocity, steering wheel angle,
lateral acceleration, longitudinal position, and lateral position.
The results are similar to these plots, which indicate that the greatest lateral acceleration occurs
when the vehicle velocity is 45 mph.
1-33
1 Getting Started
Further Analysis
To explore the results further, use these commands to extract the lateral acceleration, steering angle,
and vehicle trajectory from the simout object.
1. Extract the lateral acceleration and steering angle. Plot the data. The results are similar to this
plot.
figure
for idx = 1:numExperiments
1-34
Vehicle Steering Gain at Different Speeds
% Extract Data
log = get(simout(idx),'logsout');
sa=log.get('Steering-wheel angle').Values;
ay=log.get('Lateral acceleration').Values;
firstorderfit = polyfit(sa.Data,ay.Data,1);
gain(idx)=firstorderfit(1);
legend_labels{idx} = [num2str(vmax(idx)), ' mph: Gain = ', ...
num2str(gain(idx)), ' m/(deg s^2)'];
% Plot steering angle vs. lateral acceleration
plot(sa.Data,ay.Data)
hold on
end
% Add labels to the plots
legend(legend_labels, 'Location', 'best');
title('Lateral Acceleration')
xlabel('Steering Angle [deg]')
ylabel('Acceleration [m/s^2]')
grid on
2. Extract the vehicle path. Plot the data. The results are similar to this plot.
figure
for idx = 1:numExperiments
% Extract Data
log = get(simout(idx),'logsout');
x = log{1}.Values.Body.InertFrm.Cg.Disp.X.Data;
y = log{1}.Values.Body.InertFrm.Cg.Disp.Y.Data;
legend_labels{idx} = [num2str(vmax(idx)), ' mph'];
1-35
1 Getting Started
References
[1] SAE J266. Steady-State Directional Control Test Procedures For Passenger Cars and Light Trucks.
Warrendale, PA: SAE International, 1996.
See Also
Simulink.SimulationInput | Simulink.SimulationOutput | polyfit
More About
• “Slowly Increasing Steering Maneuver” on page 3-43
• “How 3D Simulation for Vehicle Dynamics Blockset Works” on page 8-8
1-36
Vehicle Steering Gain at Different Speeds
1-37
1 Getting Started
During the maneuver, the vehicle uses a predictive driver model to maintain a pre-specified turn
radius at a set velocity.
For more information about the reference application, see “Constant Radius Maneuver” on page 3-
54.
helpersetupcr;
1. Open the Reference Generator block. By default, the maneuver is set with these parameters:
2. Select the Reference Generator block 3D Engine tab. By default, the 3D Engine parameter is
Disabled. For the 3D visualization engine platform requirements and hardware recommendations,
see the “3D Visualization Engine Requirements and Limitations” on page 8-6.
3. Run the maneuver with the default settings. As the simulation runs, view the vehicle information.
1-38
Vehicle Lateral Acceleration at Different Speeds
mdl = 'CRReferenceApplication';
sim(mdl);
Build Summary
1-39
1 Getting Started
• In the Vehicle Position window, view the vehicle longitudinal distance as a function or the lateral
distance. The yellow line displays the yaw rate. The blue line shows the steering angle.
• In the Visualization subsystem, open the Steer, Velocity, Lat Accel Scope block to display the
steering angle, velocity, and lateral acceleration versus time.
Sweep Speed
Run the constant radius reference application with three different speeds. Stop the simulation if the
vehicle exceeds a lateral acceleration threshold of .5 g.
1. In the slowly increasing steering reference application model CRReferenceApplication, open the
Reference Generator block. The Longitudinal speed set point, xdot_r block parameter sets the
vehicle speed. By default, the speed is 50 mph.
2. Enable signal logging for the velocity, lane, and ISO signals. You can use the Simulink® editor or,
alternatively, these MATLAB® commands. Save the model.
• Select the Reference Generator block Stop simulation at lateral acceleration threshold
parameter.
1-40
Vehicle Lateral Acceleration at Different Speeds
• Enable signal logging for the Reference Generator Vis signal outport.
ph=get_param('CRReferenceApplication/Reference Generator','PortHandles');
set_param(ph.Outport(1),'DataLogging','on');
• Enable signal logging for the Passenger Vehicle block outport signal.
ph=get_param('CRReferenceApplication/Passenger Vehicle','PortHandles');
set_param(ph.Outport(1),'DataLogging','on');
• In the Visualization subsystem, enable signal logging for the ISO block.
1-41
1 Getting Started
3. Set up a speed set point vector, xdot_r, that you want to investigate. For example, at the command
line, type:
4. Create an array of simulation inputs that set the Reference Generator block parameter
Longitudinal velocity reference, xdot_r equal to xdot_r.
5. Save the model and run the simulations. If available, use parallel computing.
save_system(mdl)
tic;
simout = parsim(in,'ShowSimulationManager','on');
toc;
Use the Simulation Data Inspector to examine the results. You can use the UI or, alternatively,
command-line functions.
1. Open the Simulation Data Inspector. On the Simulink Toolstrip, on the Simulation tab, under
Review Results, click Data Inspector.
• In the Import dialog box, clear logsout. Select simout(1), simout(2), and simout(3). Select
Import.
1-42
Vehicle Lateral Acceleration at Different Speeds
2. Alternatively, use these MATLAB commands to plot the longitudinal velocity, lateral acceleration,
and the steering wheel angle.
The results are similar to these plots, which indicate that the greatest lateral acceleration occurs
when the vehcile velocity is 45 mph.
1-43
1 Getting Started
Further Analysis
To explore the results further, use these commands to extract the lateral acceleration, steering angle,
and vehicle trajectory from the simout object.
1. Extract the lateral acceleration and steering angle. Plot the data. The results are similar to this
plot.
figure
for idx = 1:numExperiments
% Extract Data
log = get(simout(idx),'logsout');
sa=log.get('Steering-wheel angle').Values;
ay=log.get('Lateral acceleration').Values;
firstorderfit = polyfit(sa.Data,ay.Data,1);
gain(idx)=firstorderfit(1);
legend_labels{idx} = [num2str(vmax(idx)), ' mph: Gain = ', ...
num2str(gain(idx)), ' m/(deg s^2)'];
% Plot steering angle vs. lateral acceleration
plot(sa.Data,ay.Data)
hold on
1-44
Vehicle Lateral Acceleration at Different Speeds
end
% Add labels to the plots
legend(legend_labels, 'Location', 'best');
title('Lateral Acceleration')
xlabel('Steering Angle [deg]')
ylabel('Acceleration [m/s^2]')
grid on
2. Extract the vehicle path. Plot the data. The results are similar to this plot.
figure
for idx = 1:numExperiments
% Extract Data
log = get(simout(idx),'logsout');
x = log{1}.Values.Body.InertFrm.Cg.Disp.X.Data;
y = log{1}.Values.Body.InertFrm.Cg.Disp.Y.Data;
legend_labels{idx} = [num2str(vmax(idx)), ' mph'];
% Plot vehicle location
axis('equal')
plot(y,x)
hold on
end
% Add labels to the plots
legend(legend_labels, 'Location', 'best');
title('Vehicle Path')
xlabel('Y Position [m]')
ylabel('X Position [m]')
grid on
1-45
1 Getting Started
References
[1] J266_199601. Steady-State Directional Control Test Procedures for Passenger Cars and Light
Trucks. Warrendale, PA: SAE International, 1996.
[2] ISO 4138:2012. Passenger cars -- Steady-state circular driving behaviour -- Open-loop test
methods. ISO (International Organization for Standardization), 2012.
See Also
Simulink.SimulationInput | Simulink.SimulationOutput | polyfit
More About
• “Constant Radius Maneuver” on page 3-54
• “How 3D Simulation for Vehicle Dynamics Blockset Works” on page 8-8
• Simulation Data Inspector
1-46
Frequency Response to Steering Angle Input
The swept-sine steering maneuver tests the vehicle frequency response to steering inputs. In the test,
the driver:
For more information about the reference application, see “Swept-Sine Steering Maneuver” on page
3-32.
helpersetupsss;
1. Open the Swept Sine Reference Generator block. By default, the maneuver is set with these
parameters:
2. In the Visualization subsystem, open the 3D Engine block. By default, the 3D Engine parameter is
set to Disabled. For the 3D visualization engine platform requirements and hardware
recommendations, see the “3D Visualization Engine Requirements and Limitations” on page 8-6.
1-47
1 Getting Started
3. Run the maneuver with the default settings. As the simulation runs, view the vehicle information.
mdl = 'SSSReferenceApplication';
sim(mdl);
Build Summary
1-48
Frequency Response to Steering Angle Input
• In the Vehicle Position window, view the vehicle longitudinal distance as a function or the lateral
distance. The yellow line is the yaw rate. The blue line is the steering angle.
• In the Visualization subsystem, open the Yaw Rate and Steer Scope block to display the yaw rate
and steering angle versus time.
1-49
1 Getting Started
Sweep Steering
Run the reference application with three different sinusoidal wave steering amplitudes.
1. In the swept-sine steering reference application model SSSReferenceApplication, open the Swept
Sine Reference Generator block. The Steering amplitude, theta_hw block parameter sets the
amplitude. By default, the amplitude is 90 deg.
2. Enable signal logging for the velocity, lane, and ISO signals. You can use the Simulink® editor or,
alternatively, these MATLAB® commands. Save the model.
• Enable signal logging for the Lane Change Reference Generator outport Lane signal.
1-50
Frequency Response to Steering Angle Input
mdl = 'SSSReferenceApplication';
open_system(mdl);
ph=get_param('SSSReferenceApplication/Swept Sine Reference Generator','PortHandles');
set_param(ph.Outport(1),'DataLogging','on');
• Enable signal logging for the Passenger Vehicle block outport signal.
ph=get_param('SSSReferenceApplication/Passenger Vehicle','PortHandles');
set_param(ph.Outport(1),'DataLogging','on');
• In the Visualization subsystem, enable signal logging for the ISO block.
3. Set up a steering amplitude vector, amp, that you want to investigate. For example, at the
command line, type:
4. Create an array of simulation inputs that set the Swept Sine Reference Generator block parameter
Steering amplitude, theta_hw equal to amp.
5. Save the model and run the simulations. If available, use parallel computing.
1-51
1 Getting Started
save_system(mdl)
tic;
simout = parsim(in,'ShowSimulationManager','on');
toc;
6. After the simulations complete, close the Simulation Data Inspector windows.
Use the Simulation Data Inspector to examine the results. You can use the UI or, alternatively,
command-line functions.
1. Open the Simulation Data Inspector. On the Simulink Toolstrip, on the Simulation tab, under
Review Results, click Data Inspector.
• In the Import dialog box, clear logsout. Select simout(1), simout(2), and simout(3).
Select Import.
1-52
Frequency Response to Steering Angle Input
2. Alternatively, use these MATLAB commands to plot data for each run. For example, use these
commands to plot the lateral position, steering wheel angle, and lateral acceleration. The results are
similar to these plots, which show the results for each run.
The results are similar to these plots, which indicate that the greatest lateral acceleration occurs
when the steering amplitude is 120 deg.
1-53
1 Getting Started
Further Analysis
To explore the results further, use these commands to extract the lateral acceleration, steering angle,
and vehicle trajectory from the simout object.
1. Extract the lateral acceleration and steering angle. Plot the data. The results are similar to this
plot.
figure
for idx = 1:numExperiments
% Extract Data
log = get(simout(idx),'logsout');
sa=log.get('Steering-wheel angle').Values;
ay=log.get('Lateral acceleration').Values;
legend_labels{idx} = ['amplitude = ', num2str(amp(idx)), '^{\circ}'];
% Plot steering angle vs. lateral acceleration
plot(sa.Data,ay.Data)
1-54
Frequency Response to Steering Angle Input
hold on
end
% Add labels to the plots
legend(legend_labels, 'Location', 'best');
title('Lateral Acceleration')
xlabel('Steering Angle [deg]')
ylabel('Acceleration [m/s^2]')
grid on
2. Extract the vehicle path. Plot the data. The results are similar to this plot.
figure
for idx = 1:numExperiments
% Extract Data
log = get(simout(idx),'logsout');
x = log{1}.Values.Body.InertFrm.Cg.Disp.X.Data;
y = log{1}.Values.Body.InertFrm.Cg.Disp.Y.Data;
legend_labels{idx} = ['amplitude = ', num2str(amp(idx)), '^{\circ}'];
% Plot vehicle location
axis('equal')
plot(y,x)
hold on
end
% Add labels to the plots
legend(legend_labels, 'Location', 'best');
title('Vehicle Path')
xlabel('Y Position [m]')
1-55
1 Getting Started
See Also
Simulink.SimulationInput | Simulink.SimulationOutput | fft
More About
• “Fourier Analysis and Filtering”
• Simulation Data Inspector
• “Swept-Sine Steering Maneuver” on page 3-32
• “How 3D Simulation for Vehicle Dynamics Blockset Works” on page 8-8
1-56
2
Coordinate Systems
2 Coordinate Systems
2-2
Coordinate Systems in Vehicle Dynamics Blockset
Axis Description
XE The XE axis is in the forward direction of the vehicle.
YE
The XE and YE axes are parallel to the ground plane. The ground plane is a
horizontal plane normal to the gravitational vector.
ZE In the Z-up orientation, the positive ZE axis points upward.
Z-Down Orientation
Axis Description
XV The XV axis points forward and is parallel to the vehicle plane of symmetry.
YV The YV axis is perpendicular to the vehicle plane of symmetry.
ZV
In the Z-down orientation:
The wheel coordinate system axes (XW, YW, ZW) are fixed in a reference frame attached to the wheel.
The origin is at the wheel center.
Z-Up Orientation1
2-3
2 Coordinate Systems
Z-Down Orientation
Axis Description
XT XT and YT are parallel to the road plane. The intersection of the wheel plane and
YT the road plane define the orientation of the XT axis.
ZT ZT points:
1. Reprinted with permission Copyright © 2008 SAE International. Further distribution of this material is not permitted
without prior permission from SAE.
2-4
Coordinate Systems in Vehicle Dynamics Blockset
Axis Description
YW • XW is parallel to the local road plane.
• YW is parallel to the wheel-spin axis.
ZW ZW points:
Axis Description
X Forward direction of the vehicle
References
[1] Gillespie, Thomas. Fundamentals of Vehicle Dynamics. Warrendale, PA: Society of Automotive
Engineers, 1992.
[2] Vehicle Dynamics Standards Committee. Vehicle Dynamics Terminology. SAE J670. Warrendale,
PA: Society of Automotive Engineers, 2008.
[3] Technical Committee. Road vehicles — Vehicle dynamics and road-holding ability — Vocabulary.
ISO 8855:2011. Geneva, Switzerland: International Organization for Standardization, 2011.
2-5
2 Coordinate Systems
See Also
More About
• “Coordinate Systems in Automated Driving Toolbox” (Automated Driving Toolbox)
External Websites
• SAE International Standards
• ISO Standards
2-6
3
Reference Applications
3 Reference Applications
From the Simulink start page, you can open project files that contain the vehicle models.
3-2
Passenger Vehicle Dynamics Models
See Also
Vehicle Body 3DOF | Vehicle Body 6DOF
More About
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• “Vehicle Reference Applications”
3-3
3 Reference Applications
Braking Test
This reference application represents a full vehicle dynamics model undergoing a braking test,
including a split-mu test. You can create your own versions, establishing a framework to test that
your vehicle meets the design requirements under normal and extreme driving conditions. Use this
reference application in ride and handling studies and chassis controls development to characterize
the vehicle dynamics during a braking test. For information about this and similar maneuvers, see
standards SAE J299_2009014 and ISO 21994:20075.
To test advanced driver assistance systems (ADAS) and automated driving (AD) perception, planning,
and control software, you can run the maneuver in a 3D environment. For the 3D visualization engine
platform requirements and hardware recommendations, see “3D Visualization Engine Requirements
and Limitations” on page 8-6.
To create and open a working copy of the constant radius reference application, enter
vdynblksBrakingStart
This table summarizes the blocks and subsystems in the reference application. Some subsystems
contain variants.
3-4
Braking Test
To override the default variant, on the Modeling tab, in the Design section, click the drop-down. In
the General section, select Variant Manager. In the Variant Manager, navigate to the variant that
you want to use. Right-click and select Override using this Choice.
Use the Maneuver Parameters to specify the maneuver start time, velocity setpoint, acceleration,
and deceleration.
Optionally, on the Tracking Parameters tab, select Enable fault tracking before braking. Use the
parameters to specify fault conditions before braking during a split-mu test. If the vehicle speed,
steering angle, or yaw rate is not within the allowable range before braking, the block sets a fault
condition. The default values represent compliance with ISO 145126.
Driver Commands
The Driver Commands block implements the driver model that the reference application uses to
generate acceleration, braking, gear, and steering commands. By default, if you select the Reference
Generator block parameter Use maneuver-specific driver, initial position, and scene, the
reference application selects the driver for the maneuver that you specified.
3-5
3 Reference Applications
Environment
The Environment subsystem implements wind and road forces, including a constant or split friction
coefficient scaling factor.
Use the Road Track Friction block Type of surface parameter to specify the friction coefficient
scaling factor:
• Constant friction coefficient scaling factor — Constant surface friction during the
maneuver
• Split friction coefficient scaling factor — Two friction coefficients
Select this option to specify the friction scaling coefficients for a split-mu braking test. Use the
enabled parameters to set the ground friction and rectangular surface friction coefficient scaling
factors.
Controllers
The Controllers subsystem generates engine torque, transmission gear, brake pressure, and
differential pressure commands.
3-6
Braking Test
ECU
The ECU controller generates the engine torque command. The controller prevents over-revving the
engine by limiting the engine torque command to the value specified by model workspace variable
EngRevLim. By default, the value is 7000 rpm. If the differential torque command exceeds the limited
engine torque command, the ECU sets the engine torque command to the commanded differential
torque.
Transmission Control
The Transmission Controller subsystem generates the transmission gear command. The controller
includes these variants.
Variant Description
Transmission Implements a transmission control module (TCM) that uses Stateflow
Controller logic to generate the gear command based on the vehicle
acceleration, wheel speed, and engine speed.
Driver - No Clutch Open loop transmission control. The controller sets the gear
command to the gear request.
PRNDL Controller Implements a transmission control module (TCM) that uses Stateflow
(default) logic to generate the gear command based on the vehicle
acceleration, brake command, wheel speed, engine speed, and gear
request.
Paddles Implements a paddle controller that uses the vehicle acceleration and
engine speed to generate the gear command.
The Brake Controller subsystem implements a Brake Pressure Control subsystem to generate the
brake pressure command. The Brake Pressure Control subsystem has these variants.
Variant Description
Bang Bang ABS Implements an ABS feedback controller that switches between two
states to regulate wheel slip. The bang-bang control minimizes the
error between the actual slip and desired slip. For the desired slip,
the controller uses the slip value at which the mu-slip curve reaches a
peak value. This desired slip value is optimal for minimum braking
distance.
Open Loop (default) Open loop brake control. The controller sets the brake pressure
command to a reference brake pressure based on the brake
command.
3-7
3 Reference Applications
Variant Description
Five-State ABS Five-state ABS control when you simulate the maneuver.1,2,3 The five-
state ABS controller uses logic-switching based on wheel deceleration
and vehicle acceleration to control the braking pressure at each
wheel.
The default ABS parameters are set to work on roads that have either:
The Active Differential Control subsystem generates the differential pressure command. To calculate
the command, the subsystem has these variants.
Variant Description
Rear Diff Controller Implements a controller that generates the differential pressure
command based on the:
• Steer angle
• Vehicle pitch, yaw, and roll
• Brake command
• Wheel speed
• Gear
• Vehicle acceleration
No Control (default) Does not implement a controller. Sets the differential pressure
command to 0.
Passenger Vehicle
The Passenger Vehicle subsystem has an engine, controllers, and a vehicle body with four wheels.
Specifically, the vehicle contains these subsystems.
3-8
Braking Test
Visualization
When you run the simulation, the Visualization subsystem provides driver, vehicle, and response
information. The reference application logs vehicle signals during the maneuver, including steering,
vehicle and engine speed, and lateral acceleration. You can use the Simulation Data Inspector to
import the logged signals and examine the data.
Element Description
Driver Commands Driver commands:
• Handwheel angle
• Acceleration command
• Brake command
3-9
3 Reference Applications
Element Description
Vehicle Response Vehicle response:
• Engine speed
• Vehicle speed
• Lateral acceleration
• ABS indicator
• Electronic stability program (ESP) indicator – Indicates when traction
control system (TCS) is active
Steer, Velocity, Lat Accel • SteerAngle — Steering angle versus time
Scope block • <xdot> — Longitudinal vehicle velocity versus time
• <ay> — Lateral acceleration versus time
Vehicle XY Plotter Vehicle longitudinal versus lateral distance
ISO 15037-1:2006 block Display ISO standard measurement signals in the Simulation Data
Inspector, including steering wheel angle and torque, longitudinal and
lateral velocity, and sideslip angle
If you enable 3D visualization on the Reference Generator block 3D Engine tab by selecting
Enabled, you can view the vehicle response in the AutoVrtlEnv window.
3-10
Braking Test
3-11
3 Reference Applications
L Toggle a camera lag effect on or off. When you enable the lag effect, the
camera view includes:
3-12
Braking Test
References
[1] Pasillas-Lépine, William. "Hybrid modeling and limit cycle analysis for a class of five-phase anti-
lock brake algorithms." Vehicle System Dynamics 44, no. 2 (2006): 173-188.
[2] Gerard, Mathieu, William Pasillas-Lépine, Edwin De Vries, and Michel Verhaegen. "Improvements
to a five-phase ABS algorithm for experimental validation." Vehicle System Dynamics 50, no.
10 (2012): 1585-1611.
[3] Bosch, R. "Bosch Automotive Handbook." 10th ed. Warrendale, PA: SAE International, 2018.
[4] J299_200901. Stopping Distance Test Procedure. Warrendale, PA: SAE International, 2009.
[5] ISO 21994:2007. Passenger cars — Stopping distance at straight-line braking with ABS — Open-
loop test method. Geneva: ISO, 2007.
[6] ISO 14512:1999. Passenger cars — Straight-ahead braking on surfaces with split coefficient of
friction -- Open-loop test procedure. Geneva: ISO, 2007.
See Also
3D Engine | Road Track Friction | Straight Maneuver Reference Generator
More About
• “3D Visualization Engine Requirements and Limitations” on page 8-6
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• “ISO 15037-1:2006 Standard Measurement Signals” on page 5-2
• Simulation Data Inspector
3-13
3 Reference Applications
ISO 3888-2 defines the double-lane change maneuver to test the obstacle avoidance performance of a
vehicle. In the test, the driver:
Typically, cones mark the lane boundaries. If the vehicle and driver can negotiate the maneuver
without hitting a cone, the vehicle passes the test.
To test advanced driver assistance systems (ADAS) and automated driving (AD) perception, planning,
and control software, you can run the maneuver in a 3D environment. For the 3D visualization engine
platform requirements and hardware recommendations, see “3D Visualization Engine Requirements
and Limitations” on page 8-6.
To create and open a working copy of the double-lane change reference application project, enter
vdynblksDblLaneChangeStart
This table summarizes the blocks and subsystems in the reference application. Some subsystems
contain variants.
3-14
Double-Lane Change Maneuver
To override the default variant, on the Modeling tab, in the Design section, click the drop-down. In
the General section, select Variant Manager. In the Variant Manager, navigate to the variant that
you want to use. Right-click and select Override using this Choice.
• Lane signals for the Visualization subsystem — The left and right lane boundaries are a function of
the Vehicle width parameter.
• Velocity and lateral reference signals for the Predictive Driver block — Use the Lateral reference
position breakpoints and Lateral reference data parameters to specify the lateral reference
trajectory as a function of the longitudinal distance.
To specify the target velocity, use the Longitudinal entrance velocity setpoint parameter.
Driver Commands
The Driver Commands block implements the driver model that the reference application uses to
generate acceleration, braking, gear, and steering commands. By default, if you select the Reference
Generator block parameter Use maneuver-specific driver, initial position, and scene, the
reference application selects the driver for the maneuver that you specified.
3-15
3 Reference Applications
Environment
The Environment subsystem generates the wind and ground forces. The reference application has
these environment variants.
Controllers
The Controllers subsystem generates engine torque, transmission gear, brake pressure, and
differential pressure commands.
ECU
The ECU controller generates the engine torque command. The controller prevents over-revving the
engine by limiting the engine torque command to the value specified by model workspace variable
EngRevLim. By default, the value is 7000 rpm. If the differential torque command exceeds the limited
engine torque command, the ECU sets the engine torque command to the commanded differential
torque.
Transmission Control
The Transmission Controller subsystem generates the transmission gear command. The controller
includes these variants.
Variant Description
Transmission Implements a transmission control module (TCM) that uses Stateflow
Controller logic to generate the gear command based on the vehicle
acceleration, wheel speed, and engine speed.
Driver - No Clutch Open loop transmission control. The controller sets the gear
command to the gear request.
PRNDL Controller Implements a transmission control module (TCM) that uses Stateflow
(default) logic to generate the gear command based on the vehicle
acceleration, brake command, wheel speed, engine speed, and gear
request.
Paddles Implements a paddle controller that uses the vehicle acceleration and
engine speed to generate the gear command.
The Brake Controller subsystem implements a Brake Pressure Control subsystem to generate the
brake pressure command. The Brake Pressure Control subsystem has these variants.
3-16
Double-Lane Change Maneuver
Variant Description
Bang Bang ABS Implements an anti-lock braking system (ABS) feedback controller
that switches between two states to regulate wheel slip. The bang-
bang control minimizes the error between the actual slip and desired
slip. For the desired slip, the controller uses the slip value at which
the mu-slip curve reaches a peak value. This desired slip value is
optimal for minimum braking distance.
Open Loop (default) Open loop brake control. The controller sets the brake pressure
command to a reference brake pressure based on the brake
command.
Five-State ABS Five-state ABS control when you simulate the maneuver.1,2,3 The five-
state ABS controller uses logic-switching based on wheel deceleration
and vehicle acceleration to control the braking pressure at each
wheel.
The Active Differential Control subsystem generates the differential pressure command. To calculate
the command, the subsystem has these variants.
Variant Description
Rear Diff Controller Implements a controller that generates the differential pressure
command based on the:
• Steer angle
• Vehicle pitch, yaw, and roll
• Brake command
• Wheel speed
• Gear
• Vehicle acceleration
No Control (default) Does not implement a controller. Sets the differential pressure
command to 0.
Passenger Vehicle
The Passenger Vehicle subsystem has an engine, controllers, and a vehicle body with four wheels.
Specifically, the vehicle contains these subsystems.
3-17
3 Reference Applications
Visualization
When you run the simulation, the Visualization subsystem provides driver, vehicle, and response
information. The reference application logs vehicle signals during the maneuver, including steering,
vehicle and engine speed, and lateral acceleration. You can use the Simulation Data Inspector to
import the logged signals and examine the data.
3-18
Double-Lane Change Maneuver
Element Description
Driver Commands Driver commands:
• Handwheel angle
• Acceleration command
• Brake command
Vehicle Response Vehicle response:
• Engine speed
• Vehicle speed
• Acceleration command
Lane Change Scope block Lateral vehicle displacement versus time:
3-19
3 Reference Applications
Element Description
Steer, Velocity, Lat Accel • SteerAngle — Steering angle versus time
Scope block • <xdot> — Longitudinal vehicle velocity versus time
• <ay> — Lateral acceleration versus time
Vehicle XY Plotter Vehicle longitudinal versus lateral distance
ISO 15037-1:2006 block Display ISO standard measurement signals in the Simulation Data
Inspector, including steering wheel angle and torque, longitudinal and
lateral velocity, and sideslip angle
3D Visualization
Optionally, you can enable or disable the 3D visualization environment. For the 3D visualization
engine platform requirements and hardware recommendations, see “3D Visualization Engine
Requirements and Limitations” on page 8-6. After you open the reference application, in the
Visualization subsystem, open the 3D Engine block. Set these parameters.
• 3D Engine to Enabled.
• Scene to one of the scenes, for example Straight road.
• Recommended for scene — Set the initial vehicle position to values recommended for
the scene
• User-specified — Set your own initial vehicle position
2 Click Update the model workspaces with the initial values to overwrite the initial vehicle
position in the model workspaces with the applied values.
When you run the simulation, view the vehicle response in the AutoVrtlEnv window.
Note
• To open and close the AutoVrtlEnv window, use the Simulink Run and Stop buttons. If you
manually close the AutoVrtlEnv window, Simulink stops the simulation with an error.
• When you enable the 3D visualization environment, you cannot step the simulation back.
3-20
Double-Lane Change Maneuver
3-21
3 Reference Applications
Mouse scroll wheel Control the camera distance from the vehicle.
3-22
Double-Lane Change Maneuver
F Toggle the free camera mode on or off. When you enable the free camera
mode, you can use the mouse to change the pitch and yaw of the camera.
This mode enables you to orbit the camera around the vehicle.
References
[1] Pasillas-Lépine, William. "Hybrid modeling and limit cycle analysis for a class of five-phase anti-
lock brake algorithms." Vehicle System Dynamics 44, no. 2 (2006): 173-188.
3-23
3 Reference Applications
[2] Gerard, Mathieu, William Pasillas-Lépine, Edwin De Vries, and Michel Verhaegen. "Improvements
to a five-phase ABS algorithm for experimental validation." Vehicle System Dynamics 50, no.
10 (2012): 1585-1611.
[3] Bosch, R. "Bosch Automotive Handbook." 10th ed. Warrendale, PA: SAE International, 2018.
[4] ISO 3888-2: 2011. Passenger cars — Test track for a severe lane-change manoeuvre.
See Also
3D Engine | Mapped SI Engine | Predictive Driver | Vehicle Terrain Sensor
Related Examples
• “Send and Receive Double-Lane Change Scene Data” on page 3-81
• “Yaw Stability on Varying Road Surfaces” on page 1-16
More About
• “3D Visualization Engine Requirements and Limitations” on page 8-6
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• “ISO 15037-1:2006 Standard Measurement Signals” on page 5-2
• “Passenger Vehicle Dynamics Models” on page 3-2
• “Send and Receive Double-Lane Change Scene Data” on page 3-81
• Simulation Data Inspector
3-24
Scene Interrogation in 3D Environment
The scene interrogation with camera and ray tracing reference application contains:
• One passenger vehicle with a simple driveline, combined slip wheel, and 3DOF vehicle dynamics
model.
• One camera mounted on the passenger vehicle rearview mirror.
• Steering, acceleration, gear, and braking controls.
• Vehicle light controls.
• 3D visualization environment configured for the Virtual Mcity scene.
Create and open a working copy of the camera and ray tracing reference application project.
vdynblksSceneCameraRayStart
When you run the simulation, the reference application provides this vehicle and scene information.
3-25
3 Reference Applications
Window Description
AutoVrtlEnv Video output of the Unreal Engine® 3D visualization environment image feedback. By
default, the display shows the view from the Simulation 3D Scene Configuration block
Scene view parameter SimulinkVehicle1.
3-26
Scene Interrogation in 3D Environment
Window Description
Key Camera Control
View Animated GIF
Mouse scroll wheel Control the camera distance from the vehicle.
L Toggle a camera lag effect on or off. When you enable the lag
effect, the camera view includes:
3-27
3 Reference Applications
Window Description
Key Camera Control
View Animated GIF
F Toggle the free camera mode on or off. When you enable the
free camera mode, you can use the mouse to change the pitch
and yaw of the camera. This mode enables you to orbit the
camera around the vehicle.
SDL Video Video image output of Simulation 3D Camera Get block. By default, the display shows
Display the view specified by these parameter settings:
3-28
Scene Interrogation in 3D Environment
Name Description
Controls Dials and gauges that control the vehicle steering, gear, acceleration, and braking.
The braking control turns on the vehicle brake lights. Setting the gear control to R
turns on the vehicle reverse lights.
Sensors The Simulation 3D Actor Transform Get block returns the translation, rotation, and
scale for the vehicle passenger vehicle and four wheels from the 3D visualization
environment.
The Simulation 3D Camera Get block returns the camera image from the 3D
visualization environment. By default, the block returns image data for a camera
location specified by these parameter settings:
Implements a Light Controls subsystem that you can use to control the headlights and
signal lights.
Displays The Simulation 3D Vehicle with Ground Following block implements a passenger
vehicle in the 3D visualization environment. The block uses the vehicle position to
adjust the vehicle elevation, roll, and pitch so that the vehicle follows the ground
terrain. By default, the block has these parameter settings:
The TransformDisplay subsystem displays the translation, rotation, and scale of the
SimulinkVehicle1 vehicle body and four wheels.
3-29
3 Reference Applications
Displays Subsystems
TransformDisplay Subsystem
In the TransformDisplay subsystem, the Display block provides the translation, rotation, and scale of
the vehicle body and four wheels. Use the Constant block value to control the display.
• 1 — Translation
• 2 — Rotation
• 3 — Scale
• Vehicle body is at -212.5 m, 65.66 m, and 0.0112 m along the world X-, Y-, and Z- axes,
respectively.
• Wheels are at their initial positions along the world X-, Y-, and Z- axes, respectively.
The Display block provides an array of the vehicle and wheel locations.
• Vehicle translation and rotation are along the world coordinate system axes.
• Wheel translations and rotations are with respect to their initial positions, along the world
coordinate system axes.
ImageDisplay Subsystem
In the ImageDisplay subsystem, the Level-2 MATLAB S-Function block uses the
VideoDisplayMSfcnWin function to display the video image output of Simulation 3D Camera Get
block.
3-30
Scene Interrogation in 3D Environment
See Also
Simulation 3D Actor Transform Get | Simulation 3D Camera Get | Simulation 3D Scene Configuration
| Simulation 3D Vehicle with Ground Following | Virtual Mcity
Related Examples
• “Send and Receive Double-Lane Change Scene Data” on page 3-81
More About
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• “Customize 3D Scenes for Vehicle Dynamics Simulations” on page 6-3
• “How 3D Simulation for Vehicle Dynamics Blockset Works” on page 8-8
External Websites
• Unreal Engine
3-31
3 Reference Applications
The swept-sine steering maneuver tests the vehicle frequency response to steering inputs. In the test,
the driver:
To test advanced driver assistance systems (ADAS) and automated driving (AD) perception, planning,
and control software, you can run the maneuver in a 3D environment. For the 3D visualization engine
platform requirements and hardware recommendations, see “3D Visualization Engine Requirements
and Limitations” on page 8-6.
To create and open a working copy of the swept-sine steering reference application project, enter
vdynblksSweptSineSteeringStart
This table summarizes the blocks and subsystems in the reference application. Some subsystems
contain variants.
3-32
Swept-Sine Steering Maneuver
To override the default variant, on the Modeling tab, in the Design section, click the drop-down. In
the General section, select Variant Manager. In the Variant Manager, navigate to the variant that
you want to use. Right-click and select Override using this Choice.
Driver Commands
The Driver Commands block implements the driver model that the reference application uses to
generate acceleration, braking, gear, and steering commands. By default, if you select the Reference
Generator block parameter Use maneuver-specific driver, initial position, and scene, the
reference application selects the driver for the maneuver that you specified.
Environment
The Environment subsystem generates the wind and ground forces. The reference application has
these environment variants.
3-33
3 Reference Applications
Controllers
The Controllers subsystem generates engine torque, transmission gear, brake pressure, and
differential pressure commands.
ECU
The ECU controller generates the engine torque command. The controller prevents over-revving the
engine by limiting the engine torque command to the value specified by model workspace variable
EngRevLim. By default, the value is 7000 rpm. If the differential torque command exceeds the limited
engine torque command, the ECU sets the engine torque command to the commanded differential
torque.
Transmission Control
The Transmission Controller subsystem generates the transmission gear command. The controller
includes these variants.
Variant Description
Transmission Implements a transmission control module (TCM) that uses Stateflow
Controller logic to generate the gear command based on the vehicle
acceleration, wheel speed, and engine speed.
Driver - No Clutch Open loop transmission control. The controller sets the gear
command to the gear request.
PRNDL Controller Implements a transmission control module (TCM) that uses Stateflow
(default) logic to generate the gear command based on the vehicle
acceleration, brake command, wheel speed, engine speed, and gear
request.
Paddles Implements a paddle controller that uses the vehicle acceleration and
engine speed to generate the gear command.
The Brake Controller subsystem implements a Brake Pressure Control subsystem to generate the
brake pressure command. The Brake Pressure Control subsystem has these variants.
Variant Description
Bang Bang ABS Implements an anti-lock braking system (ABS) feedback controller
that switches between two states to regulate wheel slip. The bang-
bang control minimizes the error between the actual slip and desired
slip. For the desired slip, the controller uses the slip value at which
the mu-slip curve reaches a peak value. This desired slip value is
optimal for minimum braking distance.
Open Loop (default) Open loop brake control. The controller sets the brake pressure
command to a reference brake pressure based on the brake
command.
3-34
Swept-Sine Steering Maneuver
Variant Description
Five-State ABS Five-state ABS control when you simulate the maneuver.1,2,3 The five-
state ABS controller uses logic-switching based on wheel deceleration
and vehicle acceleration to control the braking pressure at each
wheel.
The Active Differential Control subsystem generates the differential pressure command. To calculate
the command, the subsystem has these variants.
Variant Description
Rear Diff Controller Implements a controller that generates the differential pressure
command based on the:
• Steer angle
• Vehicle pitch, yaw, and roll
• Brake command
• Wheel speed
• Gear
• Vehicle acceleration
No Control (default) Does not implement a controller. Sets the differential pressure
command to 0.
Passenger Vehicle
The Passenger Vehicle subsystem has an engine, controllers, and a vehicle body with four wheels.
Specifically, the vehicle contains these subsystems.
3-35
3 Reference Applications
Visualization Subsystem
When you run the simulation, the Visualization subsystem provides driver, vehicle, and response
information. The reference application logs vehicle signals during the maneuver, including steering,
vehicle and engine speed, and lateral acceleration. You can use the Simulation Data Inspector to
import the logged signals and examine the data.
3-36
Swept-Sine Steering Maneuver
Element Description
Driver Commands Driver commands:
• Handwheel angle
• Acceleration command
• Brake command
Vehicle Response Vehicle response:
• Engine speed
• Vehicle speed
• Lateral acceleration
3-37
3 Reference Applications
Element Description
Yaw Rate and Steer Scope Yaw rate and steering angle versus time:
block
• Yellow line — Yaw rate
• Blue lines — Steering angle
Steer vs Ay Scope block Steering angle versus lateral acceleration
Steer, Velocity, Lat Accel • SteerAngle — Steering angle versus time
Scope block • <xdot> — Longitudinal vehicle velocity versus time
• <ay> — Lateral acceleration versus time
Vehicle XY Plotter Plot of vehicle longitudinal versus lateral distance
ISO 15037-1:2006 block Display ISO standard measurement signals in the Simulation Data
Inspector, including steering wheel angle and torque, longitudinal and
lateral velocity, and sideslip angle
3D Visualization
Optionally, you can enable or disable the 3D visualization environment. For the 3D visualization
engine platform requirements and hardware recommendations, see “3D Visualization Engine
Requirements and Limitations” on page 8-6. After you open the reference application, in the
Visualization subsystem, open the 3D Engine block. Set these parameters.
• 3D Engine to Enabled.
• Scene to one of the scenes, for example Straight road.
• Recommended for scene — Set the initial vehicle position to values recommended for
the scene
• User-specified — Set your own initial vehicle position
2 Click Update the model workspaces with the initial values to overwrite the initial vehicle
position in the model workspaces with the applied values.
When you run the simulation, view the vehicle response in the AutoVrtlEnv window.
Note
3-38
Swept-Sine Steering Maneuver
• To open and close the AutoVrtlEnv window, use the Simulink Run and Stop buttons. If you
manually close the AutoVrtlEnv window, Simulink stops the simulation with an error.
• When you enable the 3D visualization environment, you cannot step the simulation back.
3-39
3 Reference Applications
Mouse scroll wheel Control the camera distance from the vehicle.
3-40
Swept-Sine Steering Maneuver
F Toggle the free camera mode on or off. When you enable the free camera
mode, you can use the mouse to change the pitch and yaw of the camera.
This mode enables you to orbit the camera around the vehicle.
References
[1] Pasillas-Lépine, William. "Hybrid modeling and limit cycle analysis for a class of five-phase anti-
lock brake algorithms." Vehicle System Dynamics 44, no. 2 (2006): 173-188.
3-41
3 Reference Applications
[2] Gerard, Mathieu, William Pasillas-Lépine, Edwin De Vries, and Michel Verhaegen. "Improvements
to a five-phase ABS algorithm for experimental validation." Vehicle System Dynamics 50, no.
10 (2012): 1585-1611.
[3] Bosch, R. "Bosch Automotive Handbook." 10th ed. Warrendale, PA: SAE International, 2018.
See Also
3D Engine | Longitudinal Driver | Mapped SI Engine | Vehicle Terrain Sensor
Related Examples
• “Frequency Response to Steering Angle Input” on page 1-47
More About
• “3D Visualization Engine Requirements and Limitations” on page 8-6
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• “ISO 15037-1:2006 Standard Measurement Signals” on page 5-2
• “Passenger Vehicle Dynamics Models” on page 3-2
• Simulation Data Inspector
3-42
Slowly Increasing Steering Maneuver
Based on the constant speed, variable steer test defined in SAE J2664, the slowly increasing steering
maneuver helps characterize the lateral dynamics of the vehicle. In the test, the driver:
To test advanced driver assistance systems (ADAS) and automated driving (AD) perception, planning,
and control software, you can run the maneuver in a 3D environment. For the 3D visualization engine
platform requirements and hardware recommendations, see “3D Visualization Engine Requirements
and Limitations” on page 8-6.
To create and open a working copy of the increasing steering reference application project, enter
vdynblksIncreasingSteeringStart
This table summarizes the blocks and subsystems in the reference application. Some subsystems
contain variants.
3-43
3 Reference Applications
To override the default variant, on the Modeling tab, in the Design section, click the drop-down. In
the General section, select Variant Manager. In the Variant Manager, navigate to the variant that
you want to use. Right-click and select Override using this Choice.
Driver Commands
The Driver Commands block implements the driver model that the reference application uses to
generate acceleration, braking, gear, and steering commands. By default, if you select the Reference
Generator block parameter Use maneuver-specific driver, initial position, and scene, the
reference application selects the driver for the maneuver that you specified.
Environment
The Environment subsystem generates the wind and ground forces. The reference application has
these environment variants.
3-44
Slowly Increasing Steering Maneuver
Controllers
The Controllers subsystem generates engine torque, transmission gear, brake pressure, and
differential pressure commands.
ECU
The ECU controller generates the engine torque command. The controller prevents over-revving the
engine by limiting the engine torque command to the value specified by model workspace variable
EngRevLim. By default, the value is 7000 rpm. If the differential torque command exceeds the limited
engine torque command, the ECU sets the engine torque command to the commanded differential
torque.
Transmission Control
The Transmission Controller subsystem generates the transmission gear command. The controller
includes these variants.
Variant Description
Transmission Implements a transmission control module (TCM) that uses Stateflow
Controller logic to generate the gear command based on the vehicle
acceleration, wheel speed, and engine speed.
Driver - No Clutch Open loop transmission control. The controller sets the gear
command to the gear request.
PRNDL Controller Implements a transmission control module (TCM) that uses Stateflow
(default) logic to generate the gear command based on the vehicle
acceleration, brake command, wheel speed, engine speed, and gear
request.
Paddles Implements a paddle controller that uses the vehicle acceleration and
engine speed to generate the gear command.
The Brake Controller subsystem implements a Brake Pressure Control subsystem to generate the
brake pressure command. The Brake Pressure Control subsystem has these variants.
Variant Description
Bang Bang ABS Implements an anti-lock braking system (ABS) feedback controller
that switches between two states to regulate wheel slip. The bang-
bang control minimizes the error between the actual slip and desired
slip. For the desired slip, the controller uses the slip value at which
the mu-slip curve reaches a peak value. This desired slip value is
optimal for minimum braking distance.
3-45
3 Reference Applications
Variant Description
Open Loop (default) Open loop brake control. The controller sets the brake pressure
command to a reference brake pressure based on the brake
command.
Five-State ABS Five-state ABS control when you simulate the maneuver.1,2,3 The five-
state ABS controller uses logic-switching based on wheel deceleration
and vehicle acceleration to control the braking pressure at each
wheel.
The Active Differential Control subsystem generates the differential pressure command. To calculate
the command, the subsystem has these variants.
Variant Description
Rear Diff Controller Implements a controller that generates the differential pressure
command based on the:
• Steer angle
• Vehicle pitch, yaw, and roll
• Brake command
• Wheel speed
• Gear
• Vehicle acceleration
No Control (default) Does not implement a controller. Sets the differential pressure
command to 0.
Passenger Vehicle
The Passenger Vehicle subsystem has an engine, controllers, and a vehicle body with four wheels.
Specifically, the vehicle contains these subsystems.
3-46
Slowly Increasing Steering Maneuver
Visualization
When you run the simulation, the Visualization subsystem provides driver, vehicle, and response
information. The reference application logs vehicle signals during the maneuver, including steering,
vehicle and engine speed, and lateral acceleration. You can use the Simulation Data Inspector to
import the logged signals and examine the data.
3-47
3 Reference Applications
Element Description
Driver Commands Driver commands:
• Handwheel angle
• Acceleration command
• Brake command
Vehicle Response Vehicle response:
• Engine speed
• Vehicle speed
• Lateral acceleration
3-48
Slowly Increasing Steering Maneuver
Element Description
Yaw Rate and Steer Scope Yaw rate and steering angle versus time:
block
• Yellow line — Yaw rate
• Blue lines — Steering angle
Steer, Velocity, Lat Accel • SteerAngle — Steering angle versus time
Scope block • <xdot> — Longitudinal vehicle velocity versus time
• <ay> — Lateral acceleration versus time
Vehicle XY Plotter Plot of vehicle longitudinal versus lateral distance
ISO 15037-1:2006 block Display ISO standard measurement signals in the Simulation Data
Inspector, including steering wheel angle and torque, longitudinal and
lateral velocity, and sideslip angle
3D Visualization
Optionally, you can enable or disable the 3D visualization environment. For the 3D visualization
engine platform requirements and hardware recommendations, see “3D Visualization Engine
Requirements and Limitations” on page 8-6. After you open the reference application, in the
Visualization subsystem, open the 3D Engine block. Set these parameters.
• 3D Engine to Enabled.
• Scene to one of the scenes, for example Straight road.
• Recommended for scene — Set the initial vehicle position to values recommended for
the scene
• User-specified — Set your own initial vehicle position
2 Click Update the model workspaces with the initial values to overwrite the initial vehicle
position in the model workspaces with the applied values.
When you run the simulation, view the vehicle response in the AutoVrtlEnv window.
Note
3-49
3 Reference Applications
• To open and close the AutoVrtlEnv window, use the Simulink Run and Stop buttons. If you
manually close the AutoVrtlEnv window, Simulink stops the simulation with an error.
• When you enable the 3D visualization environment, you cannot step the simulation back.
3-50
Slowly Increasing Steering Maneuver
Mouse scroll wheel Control the camera distance from the vehicle.
3-51
3 Reference Applications
F Toggle the free camera mode on or off. When you enable the free camera
mode, you can use the mouse to change the pitch and yaw of the camera.
This mode enables you to orbit the camera around the vehicle.
References
[1] Pasillas-Lépine, William. "Hybrid modeling and limit cycle analysis for a class of five-phase anti-
lock brake algorithms." Vehicle System Dynamics 44, no. 2 (2006): 173-188.
3-52
Slowly Increasing Steering Maneuver
[2] Gerard, Mathieu, William Pasillas-Lépine, Edwin De Vries, and Michel Verhaegen. "Improvements
to a five-phase ABS algorithm for experimental validation." Vehicle System Dynamics 50, no.
10 (2012): 1585-1611.
[3] Bosch, R. "Bosch Automotive Handbook." 10th ed. Warrendale, PA: SAE International, 2018.
[4] SAE J266. Steady-State Directional Control Test Procedures For Passenger Cars and Light Trucks.
Warrendale, PA: SAE International, 1996.
See Also
3D Engine | Longitudinal Driver | Mapped SI Engine | Vehicle Terrain Sensor
Related Examples
• “Vehicle Steering Gain at Different Speeds” on page 1-27
More About
• “3D Visualization Engine Requirements and Limitations” on page 8-6
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• “ISO 15037-1:2006 Standard Measurement Signals” on page 5-2
• “Passenger Vehicle Dynamics Models” on page 3-2
• Simulation Data Inspector
3-53
3 Reference Applications
You can configure the reference application for open-loop and closed-loop tests:
• Open-loop — Maintain the target velocity and steering wheel angle to determine the lateral
acceleration, side-slip characteristics, and steering angles for specific accelerations and
subsequent test maneuvers. For the open-loop test, set the Reference Generator block Maneuver
parameter to Increasing Steer.
• Closed-loop — Use the predictive driver to maintain a prespecified turn radius at different
velocities for drivability and handling performance studies. For the closed-loop test, set the
Reference Generator block Maneuver parameter to Constant radius.
To create and open a working copy of the constant radius reference application, enter
vdynblksConstRadiusStart
This table summarizes the blocks and subsystems in the reference application. Some subsystems
contain variants.
3-54
Constant Radius Maneuver
To override the default variant, on the Modeling tab, in the Design section, click the drop-down. In
the General section, select Variant Manager. In the Variant Manager, navigate to the variant that
you want to use. Right-click and select Override using this Choice.
Reference Generator
The Reference Generator block sets the parameters that configure the maneuver and 3D simulation
environment. By default, the block is set for the constant radius maneuver with the 3D simulation
engine environment disabled.
Use the Maneuver parameter to specify the type of maneuver. You can specify the double lane
change, swept sine, sine with dwell, and slowly increasing maneuvers.
If you select the Use maneuver-specific driver, initial position, and scene parameter, the
reference application sets the driver, initial position, and scene for the maneuver that you specified.
Driver Commands
The Driver Commands block implements the driver model that the reference application uses to
generate acceleration, braking, gear, and steering commands. By default, if you select the Reference
Generator block parameter Use maneuver-specific driver, initial position, and scene, the
reference application selects the driver for the maneuver that you specified.
3-55
3 Reference Applications
Environment
The Environment subsystem generates the wind and ground forces. The reference application has
these environment variants.
Controllers
The Controllers subsystem generates engine torque, transmission gear, brake pressure, and
differential pressure commands.
ECU
The ECU controller generates the engine torque command. The controller prevents over-revving the
engine by limiting the engine torque command to the value specified by model workspace variable
EngRevLim. By default, the value is 7000 rpm. If the differential torque command exceeds the limited
engine torque command, the ECU sets the engine torque command to the commanded differential
torque.
Transmission Control
The Transmission Controller subsystem generates the transmission gear command. The controller
includes these variants.
Variant Description
Transmission Implements a transmission control module (TCM) that uses Stateflow
Controller logic to generate the gear command based on the vehicle
acceleration, wheel speed, and engine speed.
Driver - No Clutch Open loop transmission control. The controller sets the gear
command to the gear request.
PRNDL Controller Implements a transmission control module (TCM) that uses Stateflow
(default) logic to generate the gear command based on the vehicle
acceleration, brake command, wheel speed, engine speed, and gear
request.
Paddles Implements a paddle controller that uses the vehicle acceleration and
engine speed to generate the gear command.
The Brake Controller subsystem implements a Brake Pressure Control subsystem to generate the
brake pressure command. The Brake Pressure Control subsystem has these variants.
3-56
Constant Radius Maneuver
Variant Description
Bang Bang ABS Implements an anti-lock braking system (ABS) feedback controller
that switches between two states to regulate wheel slip. The bang-
bang control minimizes the error between the actual slip and desired
slip. For the desired slip, the controller uses the slip value at which
the mu-slip curve reaches a peak value. This desired slip value is
optimal for minimum braking distance.
Open Loop (default) Open loop brake control. The controller sets the brake pressure
command to a reference brake pressure based on the brake
command.
Five-State ABS Five-state ABS control when you simulate the maneuver.1,2,3 The five-
state ABS controller uses logic-switching based on wheel deceleration
and vehicle acceleration to control the braking pressure at each
wheel.
The Active Differential Control subsystem generates the differential pressure command. To calculate
the command, the subsystem has these variants.
Variant Description
Rear Diff Controller Implements a controller that generates the differential pressure
command based on the:
• Steer angle
• Vehicle pitch, yaw, and roll
• Brake command
• Wheel speed
• Gear
• Vehicle acceleration
No Control (default) Does not implement a controller. Sets the differential pressure
command to 0.
Passenger Vehicle
The Passenger Vehicle subsystem has an engine, controllers, and a vehicle body with four wheels.
Specifically, the vehicle contains these subsystems.
3-57
3 Reference Applications
Visualization
When you run the simulation, the Visualization subsystem provides driver, vehicle, and response
information. The reference application logs vehicle signals during the maneuver, including steering,
vehicle and engine speed, and lateral acceleration. You can use the Simulation Data Inspector to
import the logged signals and examine the data.
3-58
Constant Radius Maneuver
Element Description
Driver Commands Driver commands:
• Handwheel angle
• Acceleration command
• Brake command
Vehicle Response Vehicle response:
• Engine speed
• Vehicle speed
• Lateral acceleration
Steer, Velocity, Lat Accel • SteerAngle — Steering angle versus time
Scope block • <xdot> — Longitudinal vehicle velocity versus time
• <ay> — Lateral acceleration versus time
Vehicle XY Plotter Vehicle longitudinal versus lateral distance
ISO 15037-1:2006 block Display ISO standard measurement signals in the Simulation Data
Inspector, including steering wheel angle and torque, longitudinal and
lateral velocity, and sideslip angle
If you enable 3D visualization on the Reference Generator block 3D Engine tab by selecting
Enabled, you can view the vehicle response in the AutoVrtlEnv window.
3-59
3 Reference Applications
3-60
Constant Radius Maneuver
Mouse scroll wheel Control the camera distance from the vehicle.
3-61
3 Reference Applications
F Toggle the free camera mode on or off. When you enable the free camera
mode, you can use the mouse to change the pitch and yaw of the camera.
This mode enables you to orbit the camera around the vehicle.
References
[1] Pasillas-Lépine, William. "Hybrid modeling and limit cycle analysis for a class of five-phase anti-
lock brake algorithms." Vehicle System Dynamics 44, no. 2 (2006): 173-188.
3-62
Constant Radius Maneuver
[2] Gerard, Mathieu, William Pasillas-Lépine, Edwin De Vries, and Michel Verhaegen. "Improvements
to a five-phase ABS algorithm for experimental validation." Vehicle System Dynamics 50, no.
10 (2012): 1585-1611.
[3] Bosch, R. "Bosch Automotive Handbook." 10th ed. Warrendale, PA: SAE International, 2018.
[4] J266_199601. Steady-State Directional Control Test Procedures for Passenger Cars and Light
Trucks. Warrendale, PA: SAE International, 1996.
[5] ISO 4138:2012. Passenger cars — Steady-state circular driving behaviour — Open-loop test
methods. Geneva: ISO, 2012.
See Also
3D Engine | Driver Commands | Reference Generator
Related Examples
• “Vehicle Lateral Acceleration at Different Speeds” on page 1-38
More About
• “3D Visualization Engine Requirements and Limitations” on page 8-6
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• “ISO 15037-1:2006 Standard Measurement Signals” on page 5-2
• Simulation Data Inspector
• “Slowly Increasing Steering Maneuver” on page 3-43
3-63
3 Reference Applications
To create and open a working copy of the K and C virtual test laboratory reference application, enter
vdynblksKandCTestLabStart
The K and C virtual test laboratory contains vehicle, test system, and test control subsystems. The
vehicle system has two variants:
3-64
Kinematics and Compliance Virtual Test Laboratory
1 Use the Spreadsheet file field to provide a data file. By default, the reference application has
KandCTestData.xlsx containing required data. The table summarizes the data file
requirements for generating calibrated tables.
3-65
3 Reference Applications
The model browser opens when the process completes. You can view the camber angle, ca, toe
angle, ta, and vertical force, Fz, response model fits for the data.
In the Model Explorer, you can view the generated suspension parameters.
3-66
Kinematics and Compliance Virtual Test Laboratory
3-67
3 Reference Applications
The test laboratory exercises the suspension system with the DOE settings contained in the DOEMAT
array. To view the DOEMAT array values, open the Model Explorer.
Element Description
DOEMAT(1,1) Suspension height
DOEMAT(1,2) Handwheel angle
DOEMAT(1,3) Chirp signal amplitude
DOEMAT(1,4) Starting chirp frequency
DOEMAT(1,5) Ending chirp frequency
DOEMAT(1,6) Simulation time to complete chirp signal frequency range
The generation can take time to run and slow other computer processes. View progress in the
MATLAB® window.
In the Model Explorer, you can view the generated suspension parameters.
3-68
Kinematics and Compliance Virtual Test Laboratory
3-69
3 Reference Applications
• To stimulate the Simscape Multibody suspension model, the test laboratory uses with the DOE
settings contained in the DOEMAT array.
During the simulation, to view the suspension system, select the Mechanics Explorers tab.
3-70
Kinematics and Compliance Virtual Test Laboratory
• After the simulation completes, use the Simulation Data Inspector to compare the suspension
system response for the mapped suspension and Simscape Multibody suspension model. For
example, compare the vertical force, camber angle, and toe angle responses.
3-71
3 Reference Applications
See Also
Independent Suspension - Mapped | Solid Axle Suspension - Mapped
More About
• Simulation Data Inspector
3-72
Run a Vehicle Dynamics Maneuver in 3D Environment
1 Create and open a working copy of a maneuver reference application. For example, open the
double-lane change reference application.
vdynblksDblLaneChangeStart
2 Run the maneuver simulation. By default, the 3D environment is disabled.
When you run the simulation, the Visualization subsystem provides driver, vehicle, and response
information. The reference application logs vehicle signals during the maneuver, including
steering, vehicle and engine speed, and lateral acceleration. You can use the Simulation Data
Inspector to import the logged signals and examine the data.
3-73
3 Reference Applications
Element Description
Driver Commands Driver commands:
• Handwheel angle
• Acceleration command
• Brake command
Vehicle Response Vehicle response:
• Engine speed
• Vehicle speed
• Acceleration command
Lane Change Scope Lateral vehicle displacement versus time:
block
• Red line — Cones marking right lane boundary
• Orange line — Cones marking left lane boundary
• Blue line — Reference trajectory
• Green line — Actual trajectory
Steer, Velocity, Lat • SteerAngle — Steering angle versus time
Accel Scope block • <xdot> — Longitudinal vehicle velocity versus time
• <ay> — Lateral acceleration versus time
Vehicle XY Plotter Vehicle longitudinal versus lateral distance
ISO 15037-1:2006 block Display ISO standard measurement signals in the Simulation Data
Inspector, including steering wheel angle and torque, longitudinal
and lateral velocity, and sideslip angle
3 Enable the 3D visualization environment. In the Visualization subsystem, open the 3D Engine
block. Set these parameters.
• 3D Engine to Enabled.
• Scene description to one of the scenes, for example Double lane change.
3-74
Run a Vehicle Dynamics Maneuver in 3D Environment
• Recommended for scene — Set the initial vehicle position to values recommended
for the scene
• User-specified — Set your own initial vehicle position
b Click Update the model workspaces with the initial values to overwrite the initial
vehicle position in the model workspaces with the applied values.
4 Rerun the reference application. As the simulation runs, in the AutoVrtlEnv window, view the
vehicle response.
3-75
3 Reference Applications
Mouse scroll wheel Control the camera distance from the vehicle.
3-76
Run a Vehicle Dynamics Maneuver in 3D Environment
F Toggle the free camera mode on or off. When you enable the free
camera mode, you can use the mouse to change the pitch and yaw
of the camera. This mode enables you to orbit the camera around
the vehicle.
For example, when you run the double-lane change maneuver, use the cameras to visualize the
vehicle as it changes lanes.
3-77
3 Reference Applications
• Back
• Front left
3-78
Run a Vehicle Dynamics Maneuver in 3D Environment
• Internal
3-79
3 Reference Applications
Note
• To open and close the AutoVrtlEnv window, use the Simulink Run and Stop buttons. If you
manually close the AutoVrtlEnv window, Simulink stops the simulation with an error.
• When you enable the 3D visualization environment, you cannot step the simulation back.
See Also
More About
• “Double-Lane Change Maneuver” on page 3-14
• “Slowly Increasing Steering Maneuver” on page 3-43
• “Swept-Sine Steering Maneuver” on page 3-32
• Simulation Data Inspector
• “Customize 3D Scenes for Vehicle Dynamics Simulations” on page 6-3
3-80
Send and Receive Double-Lane Change Scene Data
• Simulation 3D Message Get block to retrieve how many cones the vehicle hits during the
maneuver.
• Simulation 3D Message Set block to control the traffic signal light.
For the minimum hardware required to run the example, see the “3D Visualization Engine
Requirements and Limitations” on page 8-6.
1 Create and open a working copy of the double-lane change reference application project.
vdynblksDblLaneChangeStart
2 Enable the 3D visualization environment. In the Visualization subsystem, open the 3D Engine
block mask and select Enabled. Apply the changes and save the model.
3-81
3 Reference Applications
1 Navigate to the Visualization > 3D Engine subsystem. Right-click the 3D Engine block and select
Mask > Look Under Mask. In the Visualization > 3D Engine > 3D Engine subsystem, insert
these blocks:
3-82
Send and Receive Double-Lane Change Scene Data
3-83
3 Reference Applications
5 Verify that the Simulation 3D Scene Configuration block executes before the Simulation 3D
Message Get block. That way, the Unreal Engine 3D visualization environment prepares the data
before the Simulation 3D Message Get block receives it. To check the block execution order,
right-click the blocks and select Properties. On the General tab, confirm these Priority
settings:
For more information about execution order, see “Control and Display Execution Order”.
6 Run the maneuver. As the simulation runs, the display block updates with the ReadMsg boolean
value 1 when the vehicle hits the corresponding cone.
The results indicate that the vehicle hits SM_Cone20 and SM_Cone30 during the maneuver.
3-84
Send and Receive Double-Lane Change Scene Data
This table provides the Double Lane Change scene cone name that corresponds to the ReadMsg
array element.
3-85
3 Reference Applications
This table provides the scene traffic signal light color that corresponds to the WriteMsg value in
the Double Lane Change scene.
3-86
Send and Receive Double-Lane Change Scene Data
Alternatively, at the MATLAB command prompt, enter this code. Apply the block changes and
save the model.
3-87
3 Reference Applications
5 Verify that the Simulation 3D Message Set block executes before the Simulation 3D Scene
Configuration block. That way, Simulation 3D Message Set prepares the signal data before the
Unreal Engine 3D visualization environment receives it. To check the block execution order,
right-click the blocks and select Properties. On the General tab, confirm these Priority
settings:
For more information about execution order, see “Control and Display Execution Order”.
6 Run the maneuver. As the simulation runs, in the AutoVrtlEnv window, you can see the
TrafficLight1 light change from red to yellow to green.
3-88
Send and Receive Double-Lane Change Scene Data
See Also
3D Engine | Double Lane Change | Simulation 3D Message Get | Simulation 3D Message Set |
Simulation 3D Scene Configuration
Related Examples
• “Double Lane Change Reference Application” on page 7-6
• “Yaw Stability on Varying Road Surfaces” on page 1-16
More About
• “Customize 3D Scenes for Vehicle Dynamics Simulations” on page 6-3
3-89
3 Reference Applications
• “Get Started Communicating with the Unreal Engine Visualization Environment” on page 6-20
• “3D Visualization Engine Requirements and Limitations” on page 8-6
3-90
4
Project Templates
4 Project Templates
1 In Simulink, on the Simulation tab, select New > Project > New Project.
In the Simulink start page, browse to Vehicle Dynamics Blockset and select Passenger 3DOF
Vehicle, Passenger 7DOF Vehicle, or Passenger 14DOF Vehicle.
2 In the Create Project dialog box, in Project name, enter a project name.
3 In Folder, enter a project folder or browse to the folder to save the project.
4 Click OK.
If the folder does not exist, the dialog box prompts you to create it. Click Yes.
The software compiles the project and populates the project folders. All models and supporting
files are in place for you to customize your vehicle dynamics model.
4-2
Vehicle Dynamics Blockset Project Templates
See Also
More About
• “Double-Lane Change Maneuver” on page 3-14
• “Slowly Increasing Steering Maneuver” on page 3-43
• “Swept-Sine Steering Maneuver” on page 3-32
4-3
5
Maneuver Standards
5 Maneuver Standards
To configure the ISO signal display, in the reference application Visualization subsystem, open the
ISO 15037-1:2006 block. Select Enabled. After you run the maneuver, the Simulation Data Inspector
opens with standard measurements.
For example, to display the ISO signals when you run the double lane change maneuver:
1 Create and open a working copy of the double-lane change reference application project.
vdynblksDblLaneChangeStart
2 In the Visualization subsystem, open the ISO 15037-1:2006 block. Select Enabled. Save the
reference application.
3 Run the maneuver. As the simulation runs, view the ISO standard measurement signals in the
Simulation Data Inspector, including steering wheel angle and torque, longitudinal and lateral
velocity, and sideslip angle.
References
[1] ISO 15037-1:2006. Road vehicles -- Vehicle dynamics test methods -- Part 1: General conditions for
passenger cars. ISO (International Organization for Standardization), 2014.
5-2
ISO 15037-1:2006 Standard Measurement Signals
See Also
More About
• “Double-Lane Change Maneuver” on page 3-14
• “Slowly Increasing Steering Maneuver” on page 3-43
• “Swept-Sine Steering Maneuver” on page 3-32
• Simulation Data Inspector
External Websites
• International Organization for Standardization
5-3
6
Supporting Data
6 Supporting Data
1 In the Drive Cycle Source block, click Install additional drive cycles to start the installer.
2 Follow the instructions and default settings provided by the installer to complete the installation.
3 On the Select a support package screen, select the data you want to add:
Note You must have write permission for the Installation folder.
See Also
Drive Cycle Source
6-2
Customize 3D Scenes for Vehicle Dynamics Simulations
By using the Unreal Editor and the Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects
support package, you can customize these scenes. You can also use the Unreal Editor and the support
package to simulate within scenes from your own custom project.
With custom scenes, you can co-simulate in both Simulink and the Unreal Editor so that you can
modify your scenes between simulation runs. To customize scenes, you should be familiar with
creating and modifying scenes in the Unreal Editor.
See Also
Simulation 3D Scene Configuration
Related Examples
• “Send and Receive Double-Lane Change Scene Data” on page 3-81
More About
• “How 3D Simulation for Vehicle Dynamics Blockset Works” on page 8-8
• “3D Visualization Engine Requirements and Limitations” on page 8-6
6-3
6 Supporting Data
External Websites
• Unreal Engine
• Unreal Engine 4 Documentation
6-4
Install Support Package and Configure Environment
1 On the MATLAB Home tab, in the Environment section, select Add-Ons > Get Add-Ons.
2 In the Add-On Explorer window, search for the Vehicle Dynamics Blockset Interface for Unreal
Engine 4 Projects support package. Click Install.
Note You must have write permission for the installation folder.
Configure Environment
The Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects support package includes these
components:
• An Unreal project, AutoVrtlEnv.uproject, and its associated files. The project includes
editable versions of the prebuilt 3D scenes that you can select from the Scene description
parameter of the Simulation 3D Scene Configuration block. To use this project, you must copy the
file to a folder on your local machine.
• A plugin file, MathWorkSimulation.uplugin. This plugin establishes the connection between
MATLAB and the Unreal Editor and is required for co-simulation. You must copy this plugin to
your local installation of the editor.
6-5
6 Supporting Data
To copy the project to a local folder and the plugin to your Unreal Editor installation, follow these
one-time steps. Use the “Code That Configures Scene Configuration (Steps 1–4)” on page 6-6.
St Description
ep
1 Specify the location of the support package project files and a local folder destination.
Note You must have write permission for the local folder destination.
2 Specify the location of the Unreal Engine installation, for example C:\Program Files\Epic
Games\UE_4.23.
3 Copy the MathWorksSimulation plugin to the Unreal Engine plugin folder.
4 Copy the support package folder that contains the AutoVrtlEnv.uproject files to the local
folder destination.
%% STEP2
% Specify the location of the Unreal Engine installation.
ueInstFolder = "C:\Program Files\Epic Games\UE_4.23";
%% STEP3
% Copy the MathWorksSimulation plugin to the Unreal Engine plugin folder.
mwPluginName = "MathWorksSimulation";
mwPluginFolder = fullfile(src_root, "plugins");
uePluginFolder = fullfile(ueInstFolder, "Engine", "Plugins");
uePluginDst = fullfile(uePluginFolder, "Marketplace", "MathWorks");
cd(uePluginFolder)
foundPlugins = dir("**/" + mwPluginName + ".uplugin");
if ~isempty(foundPlugins)
numPlugins = size(foundPlugins, 1);
msg2 = cell(1, numPlugins);
pluginCell = struct2cell(foundPlugins);
%% STEP4
% Copy the support package folder that contains the AutoVrtlEnv.uproject
% files to the local folder destination.
projFolderName = "AutoVrtlEnv";
projSrcFolder = fullfile(src_root, "project", projFolderName);
projDstFolder = fullfile(dest_root, projFolderName);
if ~exist(projDstFolder, "dir")
copyfile(projSrcFolder, projDstFolder);
end
If you want to use a project developed using a prior release of the Vehicle Dynamics Blockset
Interface for Unreal Engine 4 Projects support package, you must migrate the project to make it
compatible with Unreal Editor 4.23. See “Migrate Projects Developed Using Prior Support Packages”
6-6
Install Support Package and Configure Environment
on page 6-8. Otherwise, you can “Customize Scenes Using Simulink and Unreal Editor” on page 6-
9.
See Also
Simulation 3D Scene Configuration
More About
• “Customize 3D Scenes for Vehicle Dynamics Simulations” on page 6-3
6-7
6 Supporting Data
1 Open Unreal Engine 4.23. For example, navigate to C:\Program Files\Epic Games
\UE_4.23\Engine\Binaries\Win64 and open UE4Editor.exe.
2 Use the Unreal Project Browser to open the project that you want to migrate.
3 Follow the prompts to open a copy of the project. The editor creates a new project folder in the
same location as the original, appended with 4.23. Close the editor.
4 In a file explorer, remove the space in the migrated project folder name. For example, rename
MyProject 4.23 to MyProject4.23.
5 Use MATLAB to open the migrated project in Unreal Editor 4.23. For example, if you have a
migrated project saved to the C:/Local folder, use this MATLAB code:
path = fullfile('C:','Local','MyProject4.23','MyProject.uproject');
editor = sim3d.Editor(path);
open(editor);
Note The R2020a support package includes changes in the implementation of some actors.
Therefore, if the original project contains actors that are placed in the scene, some of them might
not fully migrate to Unreal Editor 4.23. To check, examine the Output Log.
The log might contain error messages. For more information, see the Unreal Engine 4
Documentation or contact MathWorks Technical Support.
6 Optionally, after you migrate the project, you can use the project to create an Unreal Engine
executable. See “Package Custom Scenes into Executable” on page 6-17.
After you migrate the project, you can create custom scenes. See “Customize Scenes Using Simulink
and Unreal Editor” on page 6-9.
See Also
Simulation 3D Scene Configuration
More About
• “Customize 3D Scenes for Vehicle Dynamics Simulations” on page 6-3
6-8
Customize Scenes Using Simulink and Unreal Editor
To use a project that you developed using a prior release of the support package, first migrate the
project to be compatible with Unreal Engine 4.23. See “Migrate Projects Developed Using Prior
Support Packages” on page 6-8.
The first time that you open the Unreal Editor, you might be asked to rebuild UE4Editor DLL files or
the AutoVrtlEnv module. Click Yes to rebuild these files or modules. The editor also prompts you
that new plugins are available. Click Manage Plugins and verify that the MathWorks Interface
plugin is installed. This plugin is the MathWorksSimulation.uplugin file that you copied into your
Unreal Editor installation in “Install Support Package and Configure Environment” on page 6-5.
When the editor opens, you can ignore any warning messages about files with the name
'_BuiltData' that failed to load.
If you receive a warning that the lighting needs to be rebuilt, from the toolbar above the editor
window, select Build > Build Lighting Only. The editor issues this warning the first time you open
a scene or when you add new elements to a scene. To use the lighting that comes installed with
AutoVrtlEnv in Vehicle Dynamics Blockset, see “Use AutoVrtlEnv Project Lighting in Custom
Scene” on page 6-12.
1 Open a Simulink model configured to simulate in the 3D environment. At a minimum, the model
must contain a Simulation 3D Scene Configuration block.
2 In the Simulation 3D Scene Configuration block of this model, set the Scene source parameter
to Unreal Editor.
3 In the Project parameter, browse for the project file that contains the scenes that you want to
customize.
For example, this sample path specifies the AutoVrtlEnv project that comes installed with the
Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects support package.
C:\Local\AutoVrtlEnv\AutoVrtlEnv.uproject
Z:\UnrealProjects\myProject\myProject.uproject
4 Click Open Unreal Editor. The Unreal Editor opens and loads a scene from your project.
6-9
6 Supporting Data
To open the AutoVrtlEnv.uproject file that was copied from the Vehicle Dynamics Blockset
Interface for Unreal Engine 4 Projects support package, specify the path to where you copied this
project. For example, if you copied the AutoVrtlEnv.uproject to C:/Local/AutoVrtlEnv, use
this code:
path = fullfile('C:','Local','AutoVrtlEnv','AutoVrtlEnv.uproject');
editor = sim3d.Editor(path);
open(editor);
The editor opens the AutoVrtlEnv.uproject file. By default, the project displays the Straight
Road scene.
To open your own project, use the same commands used to open the AutoVrtlEnv.uproject file.
Update the path variable with the path to your .uproject file. For example, if you have a project
saved to the C:/Local folder, use this code:
path = fullfile('C:','Local','myProject','myProject.uproject');
editor = sim3d.Editor(path);
open(editor);
Note If you are using a scene from the AutoVtrlEnv project that comes installed with the Vehicle
Dynamics Blockset Interface for Unreal Engine 4 Projects support package, skip this section.
However, if you create a new scene based off of one of the scenes in this project, then you must
complete this section.
The first time that you open a custom scene from Simulink, you need to associate, or reparent, this
project with the Sim3dLevelScriptActor level blueprint used in Vehicle Dynamics Blockset. The
level blueprint controls how objects interact with the 3D environment once they are placed in it.
Simulink returns an error at the start of simulation if the project is not reparented. You must reparent
each scene in a custom project separately.
1 In the Unreal Editor toolbar, select Blueprints > Open Level Blueprint.
2 In the Level Blueprint window, select File > Reparent Blueprint.
3 Click the Sim3dLevelScriptActor blueprint. If you do not see the Sim3dLevelScriptActor
blueprint listed, use these steps to check that you have the MathWorksSimulation plugin
installed and enabled:
If you do not see the MathWorks Interface plugin in this window, repeat step 3 in
“Configure Environment” on page 6-5 and reopen the editor from Simulink.
c Close the editor and reopen it from Simulink.
4 Close the Level Blueprint window.
6-10
Customize Scenes Using Simulink and Unreal Editor
Open Scene
In the Unreal Editor, scenes within a project are referred to as levels. Levels come in several types,
and scenes have a level type of map.
To open a prebuilt scene from the AutoVrtlEnv.uproject file, in the Content Browser pane
below the editor window, navigate to the Content > Maps folder. Then, select the map that
corresponds to the scene you want to modify.
Note The AutoVrtlEnv.uproject file does not include the Virtual Mcity scene.
To open a scene within your own project, in the Content Browser pane, navigate to the folder that
contains your scenes.
The Simulation 3D Message Get block retrieves data from the Unreal Engine 3D visualization
environment. To use the block, you must configure scenes in the Unreal Engine environment to send
data to the Simulink model.
For detailed information about using the block to send data to the scenes, see “Get Started
Communicating with the Unreal Engine Visualization Environment” on page 6-20.
The Simulation 3D Message Set block sends data to the Unreal Engine 3D visualization environment.
To use the block, you must configure scenes in the Unreal Engine environment to receive data from
the Simulink model.
For detailed information about using the block to receive data from the scene, see “Get Started
Communicating with the Unreal Engine Visualization Environment” on page 6-20.
To create a new scene in your project, from the top-left menu of the editor, select File > New Level.
6-11
6 Supporting Data
Alternatively, you can create a new scene from an existing one. This technique is useful if you want to
use one of the prebuilt scenes in the AutoVtrlEnv project as a starting point for creating your own
scene. To save a version of the currently opened scene to your project, from the top-left menu of the
editor, select File > Save Current As. The new scene is saved to the same location as the existing
scene.
In the Unreal Editor, elements within a scene are referred to as assets. To add assets to a scene, you
can browse or search for them in the Content Browser pane at the bottom and drag them into the
editor window.
When adding assets to a scene that is in the AutoVrtlEnv project, you can choose from a library of
driving-related assets. These assets are built as static meshes and begin with the prefix SM_. Search
for these objects in the Content Browser pane.
The Unreal Editor uses a left-hand Z-up coordinate system, where the Y-axis points to the right. The
vehicle blocks in Vehicle Dynamics Blockset uses a right-hand Z-down coordinate system, where the
Y-axis points to the right. When positioning objects in a scene, keep this coordinate system difference
in mind.
For more information on modifying scenes and adding assets, see Unreal Engine 4 Documentation.
To migrate assets from the AutoVrtlEnv project into your own project file, see Migrating Assets in
the Unreal Engine documentation.
To use the lighting that comes installed with the AutoVrtlEnv project in Vehicle Dynamics Blockset,
follow these steps.
1 On the World Settings tab, clear Force no precomputed lighting.
6-12
Customize Scenes Using Simulink and Unreal Editor
2 Under Build, select Lighting Quality > Production to rebuild the maps with production
quality. Rebuilding large maps can take time.
Run Simulation
Verify that the Simulink model and Unreal Editor are configured to co-simulate by running a test
simulation.
1 In the Simulink model, click Run.
Because the source of the scenes is the project opened in the Unreal Editor, the simulation does
not start. Instead, you must start the simulation from the editor.
2 Verify that the Diagnostic Viewer window in Simulink displays this message:
In the Simulation 3D Scene Configuration block, you set the scene source
to 'Unreal Editor'. In Unreal Editor, select 'Play' to view the scene.
This message confirms that Simulink has instantiated vehicles and other assets in the Unreal
Engine 3D environment.
3 In the Unreal Editor, click Play. The simulation runs in the scene currently open in the Unreal
Editor. If your Simulink model contains vehicles, these vehicles drive through the scene that is
open in the editor.
To control the view of the scene during simulation, in the Simulation 3D Scene Configuration block,
select the vehicle name from the Scene view parameter. To change the scene view as the simulation
runs, use the numeric keypad in the editor. The table shows the position of the camera displaying the
scene, relative to the vehicle selected in the Scene view parameter.
6-13
6 Supporting Data
6-14
Customize Scenes Using Simulink and Unreal Editor
L Toggle a camera lag effect on or off. When you enable the lag effect, the
camera view includes:
6-15
6 Supporting Data
To restart a simulation, click Run in the Simulink model, wait until the Diagnostic Viewer displays the
confirmation message, and then click Play in the editor. If you click Play before starting the
simulation in your model, the connection between Simulink and the Unreal Editor is not established,
and the editor displays an empty scene.
If you are co-simulating a custom project, to enable the numeric keypad, copy the
DefaultInput.ini file from the support package installation folder to your custom project folder.
For example, copy DefaultInput.ini from:
C:\ProgramData\MATLAB\SupportPackages\<MATLABRelease>\toolbox\shared\sim3dprojects\driving\AutoVr
to:
C:\<yourproject>.project\Config
After tuning your custom scene based on simulation results, you can then package the scene into an
executable. For more details, see “Package Custom Scenes into Executable” on page 6-17.
See Also
Simulation 3D Scene Configuration | sim3d.Editor
External Websites
• Unreal Engine
• Unreal Engine 4 Documentation
6-16
Package Custom Scenes into Executable
a In the List of maps to include in a packaged build option, click the Adds Element
button .
b Specify the path to the scene that you want to include in the executable. By default, the
Unreal Editor saves maps to the /Game/Maps folder. For example, if the /Game/Maps folder
has a scene named myScene that you want to include in the executable, enter /Game/Maps/
myScene.
c Add or remove additional scenes as needed.
6 Specify the required asset directories to include in the executable. These directories are located
in the MathWorksSimulation plugin.
Under Additional Asset Directories to Cook, click the Adds Element button to add
elements and specify these directories:
• /MathWorksSimulation/Characters
6-17
6 Supporting Data
• /MathWorksSimulation/VehiclesCommon
• /MathWorksSimulation/Vehicles
• /MathWorksSimulation/Weather
7 Rebuild the lighting in your scenes. If you do not rebuild the lighting, the shadows from the light
source in your executable file are incorrect and a warning about rebuilding the lighting displays
during simulation. In the Unreal Editor toolbar, select Build > Build Lighting Only.
8 Close the Project Settings window.
9 In the top-left menu of the editor, select File > Package Project > Windows > Windows (64-
bit). Select a local folder in which to save the executable, such as to the root of the project file
(for example, C:/Local/myProject).
Note Packaging a project into an executable can take several minutes. The more scenes that you
include in the executable, the longer the packaging takes.
Once packaging is complete, the folder where you saved the package contains a
WindowsNoEditor folder that includes the executable file. This file has the same name as the
project file.
Note If you repackage a project into the same folder, the new executable folder overwrites the
old one.
Suppose you package a scene that is from the myProject.uproject file and save the
executable to the C:/Local/myProject folder. The editor creates a file named
myProject.exe with this path:
C:/Local/myProject/WindowsNoEditor/myProject.exe
1 In the Simulation 3D Scene Configuration block of your Simulink model, set the Scene source
parameter to Unreal Executable.
2 Set the File name parameter to the name of your Unreal Editor executable file. You can either
browse for the file or specify the full path to the file by using backslashes. For example:
C:\Local\myProject\WindowsNoEditor\myProject.exe
3 Set the Scene parameter to the name of a scene from within the executable file. For example:
/Game/Maps/myScene
4 Run the simulation. The model simulates in the custom scene that you created.
If you are simulating a scene from a project that is not based on the AutoVtrlEnv project, then the
scene simulates in full screen mode. To use the same window size as the default scenes, copy the
DefaultGameUserSettings.ini file from the support package installation folder to your custom
project folder. For example, copy DefaultGameUserSettings.ini from:
6-18
Package Custom Scenes into Executable
C:\ProgramData\MATLAB\SupportPackages\<MATLABrelease>\toolbox\shared\sim3dprojects\automotive\Aut
to:
C:\<yourproject>.project\Config
Then, package scenes from the project into an executable again and retry the simulation.
See Also
Simulation 3D Scene Configuration
6-19
6 Supporting Data
• Simulation 3D Message Get receives data from the Unreal Engine environment.
• Simulation 3D Message Set sends data to the Unreal Engine environment.
To use the blocks and communicate with Unreal Engine, make sure you install the Vehicle Dynamics
Blockset Interface for Unreal Engine 4 Projects support package. For more information, see “Install
Support Package and Configure Environment” on page 6-5.
Next, follow these workflow steps to set up the Simulink model and the Unreal Engine environment
and run a simulation.
Workflow Description
“Set Up Simulink Model to Send and Configure the Simulation 3D Message Get and
Receive Data” on page 6-21 Simulation 3D Message Set blocks in Simulink to send
and receive the cone location from Unreal Editor. The
steps provides the general workflow for communicating
with the editor.
6-20
Get Started Communicating with the Unreal Engine Visualization Environment
If you have already downloaded and installed Unreal Engine Version 4.23 and the Vehicle Dynamics
Blockset Interface for Unreal Engine 4 Projects support package, go to the next step.
To install and configure the support package, see “Install Support Package and Configure
Environment” on page 6-5.
Use these block settings to configure blocks to send and receive cone data from the Unreal Editor.
6-21
6 Supporting Data
1 In the Unreal Editor, on the Edit tab, select Plugins. Make sure that the MathWorks
Interface plugin is enabled. If prompted, restart the Unreal Editor.
2 Create an Unreal Engine C++ project. Name it TestSim3dGetSet. For steps on how to create C
++ project, see the Unreal Engine 4 Documentation.
3 In the Unreal Editor, click the Edit tab in the top left corner. Select Plugins and make sure that
the MathWorks Interface plugin is enabled. If the MathWorks Interface plugin is disabled,
enable it and restart Unreal Editor, if prompted.
4 Close the Unreal.
5 If Visual Studio is not open, open it.
6 Add the MathWorksSimulation dependency to the TestSim3dGetSet project build file.
Tip Before rebuilding the project in Visual Studio, make sure that Unreal is not open.
8 Start MATLAB. Change the current folder to the location of the Unreal Engine
TestSim3dGetSet project.
9 In MATLAB, open the project:
editor = sim3d.Editor('TestSim3dGetSet.uproject');
editor.open();
6-22
Get Started Communicating with the Unreal Engine Visualization Environment
2 Name the new Sim3dActor SetGetActorLocation. Select Public. Click Create Class.
3 Close the Unreal Editor.
Visual Studio opens with new C++ files in the project folder:
6-23
6 Supporting Data
• SetGetActorLocation.h
• SetGetActorLocation.cpp
#pragma once
#include "Sim3dActor.h"
#include "SetGetActorLocation.generated.h"
UCLASS()
class TESTSIM3DGETSET_API ASetGetActorLocation : public ASim3dActor
{
GENERATED_BODY()
void *SignalReader;
void *SignalWriter;
public:
// Sets default values for this actor's properties
ASetGetActorLocation();
This code allows you to set a pointer to the parameter Signal Name parameter for the Simulink
blocks Simulation 3D Message Set and Simulation 3D Message Get, respectively.
// Sets default values
ASetGetActorLocation::ASetGetActorLocation():SignalReader(nullptr), SignalWriter(nullptr)
{
}
The following code allows you to access the tag name of this actor after it is instantiated in the scene
with an assigned tag name. The code also initializes the pointers SignalReader and
SignalWriter, to initiate a link between Unreal Editor and Simulink. The variables represent these
block Signal Name parameter values:
6-24
Get Started Communicating with the Unreal Engine Visualization Environment
Add this code to allow Unreal Engine to read the data value set by Simulation 3D Message Set and
then write back to Simulation 3D Message Get during run time. Unreal Engine uses this data to set
the location value of the actor.
void ASetGetActorLocation::Sim3dStep(float DeltaSeconds)
{
unsigned int numElements = 3;
float array[3];
int statusR = ReadSimulation3DMessage(SignalReader, sizeof(float)*numElements, array);
FVector NewLocation;
NewLocation.X = array[0];
NewLocation.Y = array[1];
NewLocation.Z = array[2];
SetActorLocation(NewLocation);
float fvector[3] = { NewLocation.X, NewLocation.Y, NewLocation.Z };
int statusW = WriteSimulation3DMessage(SignalWriter, sizeof(float)*numElements ,fvector);
}
Add this code so that Unreal Engine stops when you press the Simulink stop button. The code
destroys the pointer SignalReader and SignalWriter.
void ASetGetActorLocation::Sim3dRelease()
{
Super::Sim3dRelease();
if (SignalReader) {
StopSimulation3DMessageReader(SignalReader);
}
SignalReader = nullptr;
if (SignalWriter) {
StopSimulation3DMessageWriter(SignalWriter);
}
SignalWriter = nullptr;
}
6-25
6 Supporting Data
{
}
void ASetGetActorLocation::Sim3dSetup()
{
Super::Sim3dSetup();
if (Tags.Num() != 0) {
unsigned int numElements = 3;
FString tagName = Tags.Top().ToString();
void ASetGetActorLocation::Sim3dRelease()
{
Super::Sim3dRelease();
if (SignalReader) {
StopSimulation3DMessageReader(SignalReader);
}
SignalReader = nullptr;
if (SignalWriter) {
StopSimulation3DMessageWriter(SignalWriter);
}
SignalWriter = nullptr;
}
Step 8: Build the Visual Studio Project and Open Unreal Editor
Press F5 on the keyboard to run the Visual Studio solution TestSim3dGetSet. The Unreal Editor
opens.
Note In the Unreal Editor, save the current level by clicking Save Current (located in the top left)
and name it TestMap. Add this level as default to Project Settings by clicking on Edit > Project
Settings > Maps&Modes. Then select TestMap as the default value for the Editor Startup Map and
Game Default Map. Close Project Settings to save the default values.
6-26
Get Started Communicating with the Unreal Engine Visualization Environment
On the World Outliner tab, check that the new instantiated actor, SetGetActorLocation1, is
listed.
6-27
6 Supporting Data
Click on the actor that you created in “Step 9: Check Actor” on page 6-27.
1 In the Details panel, click on Add Component to add a mesh to the actor SetConeLocation1.
Choose Cone as the default mesh.
2 Find the property tags for actor SetConeLocation1. Add a tag by clicking on the plus sign next
to 0 Array elements. Name it ConeLoc.
6-28
Get Started Communicating with the Unreal Engine Visualization Environment
On the Details tab, click Cone. Set the cone to X = 0.0, Y = 0.0, and Z = 0.0. Also set the actor
Mobility property to Movable.
1 Under Blueprints, click Open Level Blueprint, and select Class Settings.
6-29
6 Supporting Data
Call these C++ functions from Sim3dSetup, Sim3dStep, and Sim3dRelease to send and receive
Simulink data.
To C++ Functions
Receive data StartSimulation3DMessageReader
ReadSimulation3DMessage
StopSimulation3DMessageReader
Send data StartSimulation3DMessageWriter
WriteSimulation3DMessage
StopSimulation3DMessageWriter
To use the Simulation 3D Message Set block, you must configure scenes in the Unreal Engine
environment to receive data from the Simulink model:
1 In the Unreal Editor, instantiate the Sim3DGet actor that corresponds to the data type you want
to receive from the Simulink model. This example shows the Unreal Editor Sim3DGet data types.
6-30
Get Started Communicating with the Unreal Engine Visualization Environment
2 Specify an actor tag name that matches the Simulation 3D Message Set block Signal name
parameter.
3 Navigate to the Level Blueprint.
4 Find the blueprint method for the Sim3DGet actor class based on the data type and size that you
want to receive from the Simulink model.
For example, in Unreal Editor, this diagram shows that Read Scalar Integer is the method
for Sim3DGetInteger actor class to receive int32 data type of size scalar.
To configure scenes in the Unreal Engine environment to send data to the Simulink model:
1 In the Unreal Editor, instantiate the Sim3DSet actor that corresponds to the data type you want
to send to the Simulink model. This example shows the Unreal Editor Sim3DSet data types.
6-31
6 Supporting Data
2 Specify an actor tag name that matches the Simulation 3D Message Get block Signal name
parameter.
3 Navigate to the Level Blueprint.
4 Find the blueprint method for the Sim3DSet actor class based on the data type and size specified
by the Simulation 3D Message Get block Data type and Message size parameters.
For this example, the array size is 3. The Unreal Editor diagram shows that Write Array
Float is the method for the Sim3DSetFloat3 actor class that sends float data type of array size
3.
Note Optionally, for better performance, set Read Array Float Max Num Elements to Num El in
the Actor Blueprint.
6-32
Get Started Communicating with the Unreal Engine Visualization Environment
In the Unreal Editor, create a level blueprint connecting the Get and Set actors.
a Under Blueprints, click Open Level Blueprint, and select Class Settings.
6-33
6 Supporting Data
6-34
Get Started Communicating with the Unreal Engine Visualization Environment
Run Simulation
After you configure the Simulink model and Unreal Editor environment, you can run the simulation.
Note At the BeginPlay event, Simulink does not receive data from the Unreal Editor. Simulink
receives data at Tick events.
Because the source of the scenes is the project opened in the Unreal Editor, the simulation does
not start.
2 Verify that the Diagnostic Viewer window in Simulink displays this message:
In the Simulation 3D Scene Configuration block, you set the scene source
to 'Unreal Editor'. In Unreal Editor, select 'Play' to view the scene.
This message confirms that Simulink has instantiated the vehicles and other assets in the Unreal
Engine 3D environment.
3 In the Unreal Editor, click Play. The simulation runs in the scene currently open in the Unreal
Editor.
You can send and receive these data types: double, single, int8, uint8, int16, uint16, int32,
uint32, boolean. The code in “Step 7: Open SetGetActorLocation.cpp” on page 6-24 reads single
data type values (or float values) from Simulink.
See Also
ASim3dActor | Sim3dRelease | Sim3dSetup | Sim3dStep | Simulation 3D Message Get |
Simulation 3D Message Set | Simulation 3D Scene Configuration
More About
• “Animate Custom Actors in the Unreal Editor” on page 8-21
• “Place Cameras on Actors in the Unreal Editor” on page 8-10
• “Send and Receive Double-Lane Change Scene Data” on page 3-81
External Websites
• Unreal Engine
• Unreal Engine 4 Documentation
6-35
6 Supporting Data
Before you start, install the Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects support
package. See “Customize 3D Scenes for Vehicle Dynamics Simulations” on page 6-3.
Step Description
“Step 1: Setup Bone In a 3D creation environment, setup the vehicle mesh bone hierarchy and
Hierarchy” on page 6-36 specify part names.
“Step 2: Assign Materials” Optionally, assign materials to the vehicle parts.
on page 6-37
“Step 3: Export Mesh and Export the vehicle mesh and armature in .fbx file format.
Armature” on page 6-39
“Step 4: Import Mesh to Import the vehicle mesh into the Unreal Editor.
Unreal Editor” on page 6-
40
“Step 5: Set Block Setup the Simulation 3D Vehicle or Simulation 3D Vehicle with Ground
Parameters” on page 6- Following block parameters.
41
Note To create the mesh, this example uses the 3D creation software Blender® Version 2.80.
6-36
Prepare Custom Vehicle Mesh for the Unreal Editor
6-37
6 Supporting Data
1 Create and assign material slots to the vehicle chassis. Confirm that the first vehicle slot
corresponds to the vehicle body. For example, this image shows the hierarchy in Blender.
6-38
Prepare Custom Vehicle Mesh for the Unreal Editor
• Scale to 1.00
• Apply Scalings to All Local
• Forward to X Forward
6-39
6 Supporting Data
• Up to Z Up
6-40
Prepare Custom Vehicle Mesh for the Unreal Editor
• Type to Custom.
• Path to the path in the Unreal Engine project that contains the imported mesh.
See Also
Simulation 3D Vehicle with Ground Following | Simulation 3D Scene Configuration | Simulation 3D
Vehicle
More About
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• “How 3D Simulation for Vehicle Dynamics Blockset Works” on page 8-8
• “3D Visualization Engine Requirements and Limitations” on page 8-6
External Websites
• Blender
6-41
7
To create or modify other scenes, you need the Vehicle Dynamics Blockset Interface for Unreal
Engine 4 Projects support package. For more information, see “Customize 3D Scenes for Vehicle
Dynamics Simulations” on page 6-3.
For the minimum hardware required to run the example, see “3D Visualization Engine Requirements
and Limitations” on page 8-6.
For more information about the reference application, see “Scene Interrogation in 3D Environment”
on page 3-25.
See Also
Simulation 3D Actor Transform Get | Simulation 3D Camera Get | Simulation 3D Scene Configuration
| Simulation 3D Vehicle with Ground Following | Vehicle Body 3DOF
More About
• “3D Visualization Engine Requirements and Limitations” on page 8-6
• “How 3D Simulation for Vehicle Dynamics Blockset Works” on page 8-8
7-2
Scene Interrogation with Camera and Ray Tracing Reference Application
External Websites
• Unreal Engine
7-3
7 Vehicle Dynamics Blockset Examples
For more information about the reference application, see “Braking Test” on page 3-4.
References
[1] J299_200901. Stopping Distance Test Procedure. Warrendale, PA: SAE International, 2009.
[2] ISO 21994:2007. Passenger cars — Stopping distance at straight-line braking with ABS — Open-
loop test method. Geneva: ISO, 2007.
[3] ISO 14512:1999. Passenger cars — Straight-ahead braking on surfaces with split coefficient of
friction -- Open-loop test procedure. Geneva: ISO, 2007.
See Also
3D Engine | Road Track Friction | Straight Maneuver Reference Generator
More About
• “3D Visualization Engine Requirements and Limitations” on page 8-6
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• “ISO 15037-1:2006 Standard Measurement Signals” on page 5-2
7-4
Braking Test Reference Application
7-5
7 Vehicle Dynamics Blockset Examples
For more information about the reference application, see “Double-Lane Change Maneuver” on page
3-14.
References
[1] ISO 3888-2: 2011. Passenger cars — Test track for a severe lane-change manoeuvre.
See Also
3D Engine | Mapped SI Engine | Predictive Driver | Vehicle Terrain Sensor
Related Examples
• “Send and Receive Double-Lane Change Scene Data” on page 3-81
• “Yaw Stability on Varying Road Surfaces” on page 1-16
More About
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• Simulation Data Inspector
7-6
Swept-Sine Steering Reference Application
For more information about the reference application, see “Swept-Sine Steering Maneuver” on page
3-32.
See Also
3D Engine | Longitudinal Driver | Mapped SI Engine | Vehicle Terrain Sensor
Related Examples
• “Frequency Response to Steering Angle Input” on page 1-47
More About
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• Simulation Data Inspector
7-7
7 Vehicle Dynamics Blockset Examples
For more information about the reference application, see “Slowly Increasing Steering Maneuver” on
page 3-43.
References
[1] SAE J266. Steady-State Directional Control Test Procedures For Passenger Cars and Light Trucks.
Warrendale, PA: SAE International, 1996.
See Also
3D Engine | Longitudinal Driver | Mapped SI Engine | Vehicle Terrain Sensor
Related Examples
• “Vehicle Steering Gain at Different Speeds” on page 1-27
More About
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• Simulation Data Inspector
7-8
Constant Radius Reference Application
For more information about the reference application, see “Constant Radius Maneuver” on page 3-54.
References
[1] J266_199601. Steady-State Directional Control Test Procedures for Passenger Cars and Light
Trucks. Warrendale, PA: SAE International, 1996.
[2] ISO 4138:2012. Passenger cars — Steady-state circular driving behaviour — Open-loop test
methods. Geneva: ISO, 2012.
See Also
3D Engine | Driver Commands | Reference Generator
Related Examples
• “Vehicle Lateral Acceleration at Different Speeds” on page 1-38
More About
• “Coordinate Systems in Vehicle Dynamics Blockset” on page 2-2
• Simulation Data Inspector
7-9
7 Vehicle Dynamics Blockset Examples
Generate Mapped Suspension from Spreadsheet Data uses Model-Based Calibration Toolbox™
to generate calibrated suspension parameters from measured vertical force and suspension geometry
data.
Compare Mapped and Simscape Suspension Responses compares the mapped suspension with
the Simscape Multibody suspension results.
For more information about the reference application, see “Kinematics and Compliance Virtual Test
Laboratory” on page 3-64.
See Also
Independent Suspension - Mapped | Solid Axle Suspension - Mapped
7-10
Kinematics and Compliance Virtual Test Laboratory Reference Application
More About
• Simulation Data Inspector
7-11
7 Vehicle Dynamics Blockset Examples
To view the simulation in the 3D visualization environment, use the Vehicle Monitor 3D variant. Right-
click the Vehicle Monitor block and select Variant > Label Mode Active Choice > Vehicle Monitor
3D. See Run Simulation in 3D Visualization Environment.
To implement the tractor and trailer, by default, the three DOF model uses the Vehicle Body 3DOF
and Trailer Body 3DOF blocks. You can use the Toggle Between 3DOF and 6DOF button to
configure a six DOF model that uses the Vehicle Body 6 DOF block, Trailer Body 6DOF block, and a
6DOF hitch subsystem. See Six Degree-of-Freedom Model.
Model
Run Simulation
On the Simulation tab, click Run. As the simulation runs, the Vehicle Position window provides the
trace of the tractor and trailer.
7-12
Three-Axle Tractor Towing a Three-Axle Trailer
To steer and drive the tractor, the three-axle tractor subsystem uses a sinusoidal wave steering input
and an axle torque applied to the rear wheels. The subsystem includes models for the wheels,
suspension, and vehicle body.
7-13
7 Vehicle Dynamics Blockset Examples
The three-axle trailer subsystem includes models for the wheels, suspension, and the trailer body.
Hitch Subsystem
When you select the three DOF model variant, the hitch model allows relative longitudinal, lateral,
and yaw motion between the tractor and trailer. To limit the longitudinal and lateral motion, the hitch
model implements a stiff translational spring-damper in the xy plane of the vehicle-fixed reference
frame. The resulting spring-damper forces approximately limits the relative motion between the
tractor and trailer to yaw rotation about a vertical axis at the hitch connection point. The hitch model
transfers the vertical hitch force from the trailer to the tractor.
When you select the six DOF model variant, the hitch model allows relative longitudinal, lateral,
vertical, and yaw motion between the tractor and trailer. The hitch model implements another
7-14
Three-Axle Tractor Towing a Three-Axle Trailer
translational spring-damper along the z-axis of the vehicle-fixed reference frame. The effects of hitch
moments due to the relative rotations of the hitches are considered negligible.
• Spring forces are linear functions of the planar distance from the tractor hitch location to the first
trailer front hitch location in the inertial reference frame.
• Damper forces are linear functions of the planar velocity from the tractor hitch location to the first
trailer front hitch location in the inertial reference frame.
7-15
7 Vehicle Dynamics Blockset Examples
In the Vehicle Monitor subsystem, use the Vehicle Monitor 3D variant to visualize the tractor and
trailer in the 3D simulation environment.
1 Right-click the Vehicle Monitor block and select Variant > Label Mode Active Choice >
Vehicle Monitor 3D.
2. Click Run. In the AutoVrtlEnv window, view the tractor and trailer in the 3D visualization
environment. You can use the key numbers to change camera views of the tractor and trailer. For
example, press 7 for a front left camera view.
To implement a 6 DOF tractor, trailer and hitch model, click Toggle Between 3DOF and 6DOF.
Then, on the Simulation tab, click Run.
7-16
Three-Axle Tractor Towing a Three-Axle Trailer
To view the simulation in the 3D visualization environment, use the Vehicle Monitor 3D variant.
See Also
Trailer Body 3DOF | Trailer Body 6DOF | Vehicle Body 3DOF | Vehicle Body 6DOF
More About
• “Two-Axle Tractor Towing a Two-Axle Trailer” on page 7-18
7-17
7 Vehicle Dynamics Blockset Examples
To implement the tractor and trailer, by default, the three degree-of-freedom (DOF) model uses the
Vehicle Body 3DOF and Trailer Body 3DOF blocks. You can use the Toggle Between 3DOF and
6DOF button to configure a six DOF model that uses the Vehicle Body 6 DOF block, Trailer Body
6DOF block, and a 6DOF hitch subsystem. See Six Degree-of-Freedom Model.
Model
Run Simulation
On the Simulation tab, click Run. As the simulation runs, the Vehicle Position window provides the
trace of the tractor and trailer.
7-18
Two-Axle Tractor Towing a Two-Axle Trailer
To steer and drive the tractor, the two-axle tractor subsystem uses a sinusoidal wave steering input
and an axle torque applied to the rear wheels. The subsystem includes models for the wheels,
suspension, and vehicle body.
The two-axle trailer subsystem includes models for the wheels, suspension, and the trailer body.
7-19
7 Vehicle Dynamics Blockset Examples
Hitch Subsystem
When you select the three DOF model variant, the hitch model allows relative longitudinal, lateral,
and yaw motion between the tractor and trailer. To limit the longitudinal and lateral motion, the hitch
model implements a stiff translational spring-damper in the xy plane of the vehicle-fixed reference
frame. The resulting spring-damper forces approximately limits the relative motion between the
tractor and trailer to yaw rotation about a vertical axis at the hitch connection point. The hitch model
transfers the vertical hitch force from the trailer to the tractor.
When you select the six DOF model variant, the hitch model allows relative longitudinal, lateral,
vertical, and yaw motion between the tractor and trailer. The hitch model implements another
translational spring-damper along the z-axis of the vehicle-fixed reference frame. The effects of hitch
moments due to the relative rotations of the hitches are considered negligible.
• Spring forces are linear functions of the planar distance from the tractor hitch location to the first
trailer front hitch location in the inertial reference frame.
• Damper forces are linear functions of the planar velocity from the tractor hitch location to the first
trailer front hitch location in the inertial reference frame.
7-20
Two-Axle Tractor Towing a Two-Axle Trailer
To implement a six DOF tractor, trailer and hitch model, click Toggle Between 3DOF and 6DOF.
Then, on the Simulation tab, click Run.
7-21
7 Vehicle Dynamics Blockset Examples
See Also
Trailer Body 3DOF | Trailer Body 6DOF | Vehicle Body 3DOF | Vehicle Body 6DOF
More About
• “Three-Axle Tractor Towing a Three-Axle Trailer” on page 7-12
7-22
Follow Waypoints Around Oval Track
To create your own track and use it Unreal®, you can use RoadRunner and a RoadRunner plugin. To
simulate a vehicle on the track in Unreal, you need the Vehicle Dynamics Blockset™ Interface for
Unreal Engine® 4 Projects support package. For more information, see “Install Support Package and
Configure Environment” on page 6-5.
Load Waypoints
On the model canvas, click Load Waypoints to load a minimum number of waypoints and
corresponding reference poses. This action loads waypoints that specify an oval track like the Indy
500 racing track.
7-23
7 Vehicle Dynamics Blockset Examples
The waypoints are specified as the X and Y locations in the Z -down vehicle coordinate system, in m.
The reference poses are specified in deg.
Loading the waypoints also creates equally spaced intermediate waypoints and reference poses for
the straight-line and circular portions of the track.
Run Simulation
On the Simulation tab, click Run. As the simulation runs, the Vehicle Position window provides the
trace of the vehicle as it moves around the track.
The Oval Track Reference block includes a MATLAB® Function block that determines the next
heading waypoint based on the current vehicle position and pose. The reference block then provides
the vehicle commands to the driver block.
7-24
Follow Waypoints Around Oval Track
See Also
MATLAB Function | Predictive Driver | Vehicle Body 3DOF
More About
• “Install Support Package and Configure Environment” on page 6-5
• “Export to Unreal” (RoadRunner)
• “RoadRunner”
7-25
7 Vehicle Dynamics Blockset Examples
Open the Mapped SI Engine block in the double-lane change reference application.
workDir = pwd;
vdynblksDblLaneChangeStart;
cd(workDir);
The functions in the example overwrite the workspace variables with the values in the data file.
First, specify the file name. This example file SiEngineData.xlsx contains three sheets. The first
sheet contains scalar values for commanded torque breakpoints, breakpoints for engine speed input
breakpoints, number of cylinders, crank revolutions, and total displaced volume. The second sheet
contains a table values for the brake torque map. The third sheet contains table values for the fuel
torque map.
fileName = 'SiEngineData.xlsx';
Note that the first sheet in the file specifies the Number of cylinders, Ncyl parameter as 6.
7-26
Read and Write Block Parameters to Excel
Next, define the configuration data for the engine subsystem. This example sets a configuration for
double variables of size scalar, vector, or a 2D array.
% Scalar data
engData.Ncyl = struct('xlSheet','Main', 'xlRange','C7:C7', 'slBlockPath',bp, 'slBlockParam','Ncyl
engData.Cps = struct('xlSheet','Main', 'xlRange','C8:C8', 'slBlockPath',bp, 'slBlockParam','Cps')
engData.Vd = struct('xlSheet','Main', 'xlRange','C9:C9', 'slBlockPath',bp, 'slBlockParam','Vd');
% Vector data
engData.t_bpt = struct('xlSheet','Main', 'xlRange','C3:R3', 'slBlockPath',bp, 'slBlockParam','f_t
engData.n_bpt = struct('xlSheet','Main', 'xlRange','C4:R4', 'slBlockPath',bp, 'slBlockParam','f_t
% 2D array data
engData.torque = struct('xlSheet','Brake Torque', 'xlRange','B2:Q17', 'slBlockPath',bp, 'slBlockP
engData.fuel = struct('xlSheet','Fuel Map', 'xlRange','B2:Q17', 'slBlockPath',bp, 'slBlockParam',
Update the Mapped SI Engine block to the values specified in the data file.
Use this code to read the data file and update the Mapped SI Engine block parameters.
f = fields(engData);
for idx = 1:length(f)
try
var = getfield(engData, f{idx});
% read value from Excel
val = readmatrix(fileName, 'Sheet',var.xlSheet, 'Range',var.xlRange);
% open Simulink model
mdl = fileparts(var.slBlockPath);
open_system(mdl);
% set parameter value and save model
set_param(var.slBlockPath, var.slBlockParam, mat2str(val));
save_system(mdl);
catch ME
% return any error info
7-27
7 Vehicle Dynamics Blockset Examples
In the Mapped SI Engine block, change the Number of cylinders, NCyl parameter from 6 to 8.
Click Apply. Save the model.
Alternatively, use this code to update the parameter and save the model.
set_param(bp,'Ncyl','8');
save_system('SiMappedEngineV');
Create a copy of the data file. Write the modified parameter data to the copy of the data file.
copyfile('SiEngineData.xlsx','SiEngineDataCopy.xlsx','f');
fileName = 'SiEngineDataCopy.xlsx';
7-28
Read and Write Block Parameters to Excel
Next, use this code to write the Mapped SI Engine block Breakpoints for commanded torque,
Breakpoints for engine speed input, Number of cylinders, Crank revolutions per power
stroke, Total displaced volume, Brake torque map, and Fuel flow map parameters to the data
file.
Open the file with the modified data. Confirm that the number of cylinders in the data file is 8.
See Also
Mapped SI Engine
Related Examples
• “Double Lane Change Reference Application” on page 7-6
7-29
8
3D Simulation
8 3D Simulation
Simulink blocks related to the 3D simulation environment can be found in the Vehicle Dynamics
Blockset > Vehicle Scenarios > Sim3D block library. These blocks provide the ability to:
This simulation tool is commonly used to supplement real data when developing, testing, and
verifying the vehicle performance of automated driving algorithms. In conjunction with a vehicle
model, you can use these blocks to perform realistic closed-loop simulations that encompass the
entire automated driving stack, from perception to control.
For more details on the simulation environment, see “How 3D Simulation for Vehicle Dynamics
Blockset Works” on page 8-8.
3D Simulation Blocks
Scenes
To configure a model to co-simulate with the 3D simulation environment, add a Simulation 3D Scene
Configuration block to the model. Using this block, you can choose from a set of prebuilt 3D scenes
where you can test and visualize your vehicle performance. The following image is from the Virtual
Mcity scene.
8-2
3D Simulation for Vehicle Dynamics Blockset
Scene Description
Straight Road Straight road segment
Curved Road Curved, looped road
Parking Lot Empty parking lot
Double Lane Change Straight road with barrels and traffic signs that
are set up for executing a double lane change
maneuver
Open Surface Flat, black pavement surface with no road objects
US City Block City block with intersections, barriers, and traffic
lights
US Highway Highway with cones, barriers, traffic lights, and
traffic signs
Large Parking Lot Parking lot with parked cars, cones, curbs, and
traffic signs
Virtual Mcity City environment that represents the University
of Michigan proving grounds (see Mcity Test
Facility); includes cones, barriers, an animal,
traffic lights, and traffic signs
If you have the Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects support package,
then you can modify these scenes or create new ones. For more details, see “Customize 3D Scenes for
Vehicle Dynamics Simulations” on page 6-3.
8-3
8 3D Simulation
To define a virtual vehicle in a scene, add a Simulation 3D Vehicle with Ground Following, Simulation
3D Vehicle, Simulation 3D Tractor, or Simulation 3D Trailer block to your model. Using the blocks,
you can control the movement of the vehicle by supplying the X, Y, and yaw values that define its
position and orientation at each time step.
You can also specify the color and type of vehicle. The toolbox includes these vehicle types:
• Box Truck
• Hatchback
• Muscle Car
• Sedan
• Small Pickup Truck
• Sport Utility Vehicle
• Conventional Tractor
• Two-Axle Trailer
• Three-Axle Trailer
Communication
You can define virtual sensors and attach them at various positions on the vehicles. The toolbox
includes these sensor modeling and configuration blocks.
Block Description
Simulation 3D Camera Get Provides an interface to an ideal camera in the
3D visualization environment. The image output
is a red, green, and blue (RGB) array.
Simulation 3D Actor Transform Get Gets the actor translation, rotation, and scale for
the Simulink simulation environment.
Simulation 3D Actor Transform Set Sets the actor translation, rotation, and scale in
the Unreal Engine 3D visualization environment
Simulation 3D Message Get Retrieves data from the Unreal Engine 3D
visualization environment.
Simulation 3D Message Set Sends data to the Unreal Engine 3D visualization
environment.
Closed-Loop Systems
After you design and test a perception system within the 3D simulation environment, you can then
use it to drive a control system that actually steers a vehicle. In this case, rather than manually set up
a trajectory, the vehicle uses the perception system to drive itself. By combining perception and
control into a closed-loop system in the 3D simulation environment, you can develop and test more
complex algorithms, such as lane keeping assist and adaptive cruise control.
8-4
3D Simulation for Vehicle Dynamics Blockset
See Also
More About
• “Get Started Communicating with the Unreal Engine Visualization Environment” on page 6-20
• “How 3D Simulation for Vehicle Dynamics Blockset Works” on page 8-8
8-5
8 3D Simulation
Software Requirements
To use the Vehicle Dynamics Blockset 3D visualization engine, consider these minimum hardware
requirements:
• A Windows® 64-bit platform. If you do not enable the 3D visualization engine, Vehicle Dynamics
Blockset runs on Windows, Mac, and Linux® 64-bit platforms.
• Visual Studio 2019.
• Microsoft® DirectX®. If it is not already installed on your machine, Vehicle Dynamics Blockset
prompts you to install the software the first time you enable 3D visualization.
If you are customizing scenes, verify that your Unreal Engine project is compatible with the Unreal
Engine version supported by your MATLAB release.
Limitations
The 3D visualization engine and blocks do not support:
• Code generation.
• Model reference.
• Multiple instances of the Simulation 3D Scene Configuration block.
• Multiple instances of the same actor tag. To refer to the same scene actor when you use the 3D
block pairs (e.g. Simulation 3D Actor Transform Get and Simulation 3D Actor Transform Set),
specify the same Tag for actor in 3D scene, Actortag parameter.
• Parallel simulations.
• Rapid accelerator mode.
8-6
3D Visualization Engine Requirements and Limitations
In addition, when using these blocks in a closed-loop simulation, all 3D simulation environment blocks
must be in the same subsystem.
See Also
Simulation 3D Scene Configuration
More About
• “How 3D Simulation for Vehicle Dynamics Blockset Works” on page 8-8
• “Scene Interrogation in 3D Environment” on page 3-25
External Websites
• Unreal Engine
8-7
8 3D Simulation
Understanding how this simulation environment works can help you troubleshoot issues and
customize your models.
• Determines the next position of objects by using 3D visualization environment feedback and
vehicle dynamics models.
• Configures the 3D visualization environment, specifically:
• Ray tracing
• Scene capture cameras
• Initial object positions
In the visualization engine environment, Vehicle Dynamics Blockset positions the objects and uses ray
tracing to query the environment.
The diagram summarizes the communication between Simulink and the visualization engine.
1 The vehicle blocks initialize the vehicles and send their X, Y, and Yaw signal data to the
Simulation 3D Scene Configuration block.
2 The Simulation 3D Scene Configuration block receives the vehicle data and sends it to the sensor
blocks.
3 The sensor blocks receive the vehicle data and use it to accurately locate and visualize the
vehicles.
8-8
How 3D Simulation for Vehicle Dynamics Blockset Works
The Priority property of the blocks controls this execution order. To access this property for any
block, right-click the block, select Properties, and click the General tab. By default, Simulation 3D
Vehicle with Ground Following blocks have a priority of -1, Simulation 3D Scene Configuration blocks
have a priority of 0, and sensor blocks have a priority of 1.
If your sensors are not detecting vehicles in the scene, it is possible that the 3D simulation blocks are
executing out of order. Try updating the execution order and simulating again. For more details on
execution order, see “Control and Display Execution Order”.
Also be sure that all 3D simulation blocks are located in the same subsystem. Even if the blocks have
the correct Priority settings, if they are located in different subsystems, they still might execute out
of order.
See Also
Related Examples
• “Send and Receive Double-Lane Change Scene Data” on page 3-81
More About
• “3D Visualization Engine Requirements and Limitations” on page 8-6
• “Scene Interrogation in 3D Environment” on page 3-25
External Websites
• Unreal Engine
8-9
8 3D Simulation
To follow this workflow, you should be comfortable using Unreal Engine. Make sure that you have
Visual Studio 2019 installed on your computer.
1 In a Simulink model, add the Simulation 3D Scene Configuration, Simulation 3D Camera Get, and
To Video Display blocks.
Set these block parameters. In the Simulation 3D Scene Configuration block, select Open
Unreal Editor.
8-10
Place Cameras on Actors in the Unreal Editor
3 In the Unreal Editor, from the Modes tab, add a Cone to the world, scene, or map.
4 On the World Outliner tab, right-click the Sim3DSceneCap and attach it to the Cone.
8-11
8 3D Simulation
5 On the Details tab, under Transform, add a location offset of -500,0,100 in the X, Y, and Z
world coordinate system, respectively. This attaches the camera 500 cm behind the cone and 100
cm above it. The values match the Simulation 3D Camera Get block parameter Relative
translation [X, Y, Z] value.
6 On the Details tab, under Actor, tag the Sim3DSceneCap with the name Camera1.
8-12
Place Cameras on Actors in the Unreal Editor
Because the source of the scenes is the project opened in the Unreal Editor, the simulation
does not start.
b Verify that the Diagnostic Viewer window in Simulink displays this message:
This message confirms that Simulink has instantiated the vehicles and other assets in the
Unreal Engine 3D environment.
c In the Unreal Editor, click Play. The simulation runs in the scene currently open in the
Unreal Editor.
Observe the results in the To Video display window. The window displays the image from the
camera.
1 In a Simulink model, add the Simulation 3D Scene Configuration, Simulation 3D Camera Get, and
To Video Display blocks.
8-13
8 3D Simulation
For more information about the Epic Games Launcher, see Unreal Engine.
b Select the New Project tab. On the Blueprint or C++ tab, select Vehicle Advanced. For
more information about the Epic Games Launcher, see Unreal Engine.
8-14
Place Cameras on Actors in the Unreal Editor
The Epic Games Launcher creates a new project and opens the Unreal Editor.
c Save the project. Close the Unreal Editor.
3 Open the Simulink model that you saved in step 1. Set these block parameters. In the Simulation
3D Scene Configuration block, select Open Unreal Editor.
8-15
8 3D Simulation
8-16
Place Cameras on Actors in the Unreal Editor
6 On the vehicle VehicleBlueprint, drag and drop a camera. Choose a vehicle socket or bone to
attach the camera to.
8-17
8 3D Simulation
7 On the Details tab, tag the Sim3dCamera1 with the name Camera1.
a Under Blueprints, click Open Level Blueprint, and select Class Settings.
8-18
Place Cameras on Actors in the Unreal Editor
Because the source of the scenes is the project opened in the Unreal Editor, the simulation
does not start.
b Verify that the Diagnostic Viewer window in Simulink displays this message:
This message confirms that Simulink has instantiated the vehicles and other assets in the
Unreal Engine 3D environment.
c In the Unreal Editor, click Play. The simulation runs in the scene currently open in the
Unreal Editor.
8-19
8 3D Simulation
See Also
Simulation 3D Camera Get | Simulation 3D Scene Configuration
More About
• “Animate Custom Actors in the Unreal Editor” on page 8-21
• “Get Started Communicating with the Unreal Engine Visualization Environment” on page 6-20
External Websites
• Unreal Engine
8-20
Animate Custom Actors in the Unreal Editor
This examples provides the workflow for animating a bicycle actor. The general workflow is adapted
from the Unreal Engine Vehicle User Guide.
8-21
8 3D Simulation
Note This tag should match the Unreal Editor tag name in
“Step 6: Instantiate the Bicycle Actor” on page 8-36.
• Number of parts per actor to set, NumberOfParts — 3
• Initial Values tab:
8-22
Animate Custom Actors in the Unreal Editor
1 In your Simulink model, use the Simulation 3D Scene Configuration block Open Unreal Editor
parameter to open the Unreal Editor.
2 Select File > New C++ Class. In the Choose Parent Class dialog box, select Show All
Classes. Search for AnimInst. Add the AnimInstance parent class.
In the Unreal Editor Message dialog box, click No to not open the Output Log.
8-23
8 3D Simulation
Tip For this example, the code includes FWheelRotation and RWheelRotation properties to
animate the bicycle wheel rotation. You can add additional properties to animate other parts of
the bicycle.
Code: SimulinkBikeAnimInst.h
// Copyright 2019 The MathWorks, Inc.
#pragma once
#include "CoreMinimal.h"
#include "Animation/AnimInstance.h"
8-24
Animate Custom Actors in the Unreal Editor
#include "SimulinkBikeAnimInst.generated.h"
/**
*
*/
UCLASS(transient, Blueprintable, hideCategories = AnimInstance, BlueprintType)
class AUTOVRTLENV_API USimulinkBikeAnimInst : public UAnimInstance
{
GENERATED_UCLASS_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WheelRotation)
float FWheelRotation;
Code: SimulinkBikeAnimInst.cpp
// Copyright 2019 The MathWorks, Inc.
#include "SimulinkBikeAnimInst.h"
1 In your Simulink model, use the Simulation 3D Scene Configuration block Open Unreal Editor
parameter to open the Unreal Editor.
2 In the Unreal Editor, on the Content Browser tab, under View Options, select Show Engine
Content and Show Plugin Content.
8-25
8 3D Simulation
3 Add the animation mesh. On the Content Browser tab, navigate to MathWorksSimulation
Content > Vehicles > Bicyclist > Meshes.
8-26
Animate Custom Actors in the Unreal Editor
8-27
8 3D Simulation
Click OK.
6 Name the blueprint BikeAnimation. Right-click and select Save.
8-28
Animate Custom Actors in the Unreal Editor
8-29
8 3D Simulation
1 In the Unreal Editor, on the Content Browser tab, under View Options, select Show Engine
Content and Show Plugin Content.
8-30
Animate Custom Actors in the Unreal Editor
8-31
8 3D Simulation
Tip If you do not see the MathWorksSimulation C++ Classes folder, use these steps to check that
you have the MathWorksSimulation plugin installed and enabled:
If you do not see the MathWorks Interface plugin in this window, repeat step 3 in
“Configure Environment” on page 6-5 and reopen the editor from Simulink.
c Close the editor and reopen it from Simulink.
3 Name the new Sim3dActor BicycleActor. Select Public. Click Create Class.
8-32
Animate Custom Actors in the Unreal Editor
Tip For this example, the code includes logic to animate the bike body (BIKE_BODY), front
wheel (FRONT_WHEEL), and rear wheel (REAR_WHEEL). You can add additional logic to animate
other parts of the bicycle.
Code: BicycleActor.h
// Copyright 2019 The MathWorks, Inc.
#pragma once
#include "CoreMinimal.h"
#include "Sim3dActor.h"
#include "BicycleActor.generated.h"
UCLASS()
class AUTOVRTLENV_API ABicycleActor : public ASim3dActor
{
GENERATED_BODY()
8-33
8 3D Simulation
Z = 2
};
enum {
PITCH = 0,
ROLL = 1,
YAW = 2
};
public:
//Containers to receive data from Simulink
float Translation[NumberOfParts][3];
float Rotation[NumberOfParts][3];
float Scale[NumberOfParts][3];
ABicycleActor();
protected:
virtual int GetNumberOfParts() { return (NumberOfParts); }
};
Code: BicycleActor.cpp
// Copyright 2019 The MathWorks, Inc.
#include "BicycleActor.h"
#include "SimulinkBikeAnimInst.h"
#include "AutoVrtlEnv.h"
#include "Math/UnrealMathUtility.h"
ABicycleActor::ABicycleActor() {
void ABicycleActor::Sim3dInit() {
Super::Sim3dInit();
}
void ABicycleActor::Sim3dSetup() {
SetMesh(TEXT("/MathWorksSimulation/Vehicles/Bicyclist/Meshes/SK_Bicycle"));
SetAnim(TEXT("/MathWorksSimulation/Vehicles/Bicyclist/Meshes/BikeAnimation.BikeAnimation_C"));
8-34
Animate Custom Actors in the Unreal Editor
GetMesh()->SetSkeletalMesh(BicycleMesh);
GetMesh()->SetAnimationMode(EAnimationMode::AnimationBlueprint);
GetMesh()->SetAnimInstanceClass(BicycleAnimation);
Transform();
}
void ABicycleActor::Sim3dRelease() {
Super::Sim3dRelease();
}
void ABicycleActor::Transform() {
//Initialize
int status = 0;
FVector ActorLocation;
FRotator ActorRotation;
FVector ActorScale;
USimulinkBikeAnimInst* Animation = NULL;
Animation = Cast<USimulinkBikeAnimInst>(GetMesh()->GetAnimInstance());
SetActorLocation(ActorLocation);
SetActorRotation(ActorRotation);
SetActorScale3D(ActorScale);
Translation[FRONT_WHEEL][X] = 0.0f;
Translation[FRONT_WHEEL][Y] = 0.0f;
Translation[FRONT_WHEEL][Z] = 0.0f;
Translation[REAR_WHEEL][X] = 0.0f;
Translation[REAR_WHEEL][Y] = 0.0f;
Translation[REAR_WHEEL][Z] = 0.0f;
Rotation[FRONT_WHEEL][PITCH] = 0.0f;
Rotation[FRONT_WHEEL][ROLL] = FMath::DegreesToRadians(Animation->FWheelRotation);
Rotation[FRONT_WHEEL][YAW] = 0.0f;
Rotation[REAR_WHEEL][PITCH] = 0.0f;
8-35
8 3D Simulation
Rotation[REAR_WHEEL][ROLL] = FMath::DegreesToRadians(Animation->RWheelRotation);
Rotation[REAR_WHEEL][YAW] = 0.0f;
Scale[FRONT_WHEEL][X] = 1.0f;
Scale[FRONT_WHEEL][Y] = 1.0f;
Scale[FRONT_WHEEL][Z] = 1.0f;
Scale[REAR_WHEEL][X] = 1.0f;
Scale[REAR_WHEEL][Y] = 1.0f;
Scale[REAR_WHEEL][Z] = 1.0f;
Tip In the code, make sure to use relative paths when you specify the mesh and animation asset
locations.
void ABicycleActor::Sim3dSetup() {
SetMesh(TEXT("/MathWorksSimulation/Vehicles/Bicyclist/Meshes/SK_Bicycle"));
SetAnim(TEXT("/MathWorksSimulation/Vehicles/Bicyclist/Meshes/BikeAnimation.BikeAnimation_C"));
GetMesh()->SetSkeletalMesh(BicycleMesh);
GetMesh()->SetAnimationMode(EAnimationMode::AnimationBlueprint);
GetMesh()->SetAnimInstanceClass(BicycleAnimation);
Transform();
}
1 In your Simulink model, use the Simulation 3D Scene Configuration block Open Unreal Editor
parameter to open the Unreal Editor.
2 Place the Bicycle Actor in the scene.
8-36
Animate Custom Actors in the Unreal Editor
3 Set the tag to the same value as the Simulation 3D Actor Transform Set block Tag for actor in
3D scene, ActorTag. For this example, set the value to Bike1.
8-37
8 3D Simulation
8-38
Animate Custom Actors in the Unreal Editor
8-39
8 3D Simulation
8-40
Animate Custom Actors in the Unreal Editor
4 In the level blueprint, make these connections. If you right-click on the Event Graph to find
nodes, clear Context Sensitive. If you have a CameraActor, you can drag it to the Event Graph
from the World Outliner view in the editor.
Run Simulation
After you configure the Simulink model and Unreal Editor environment, run a simulation.
8-41
8 3D Simulation
1 In your Simulink model, make sure that you have set the Simulation 3D Scene Configuration
parameters to these values:
Because the source of the scenes is the project opened in the Unreal Editor, the simulation
does not start.
b Verify that the Diagnostic Viewer window in Simulink displays this message:
This message confirms that Simulink has instantiated the vehicles and other assets in the
Unreal Engine 3D environment.
c In the Unreal Editor, click Play. The simulation runs in the scene currently open in the
Unreal Editor.
See Also
Simulation 3D Actor Transform Set | Simulation 3D Scene Configuration
More About
• “Get Started Communicating with the Unreal Engine Visualization Environment” on page 6-20
• “Place Cameras on Actors in the Unreal Editor” on page 8-10
External Websites
• Unreal Engine
8-42