Install Support Package for Customizing Scenes
To customize scenes in your installation of the Unreal® Editor and simulate within these scenes in Simulink®, you must first install the Automated Driving Toolbox Interface for Unreal Engine 4 Projects.
Note
These installation instructions apply to R2022a. If you are using a previous release, see the documentation for Other Releases.
Verify Software and Hardware Requirements
Before installing the support package, make sure that your environment meets the minimum software and hardware requirements described in Unreal Engine Simulation Environment Requirements and Limitations.
Install Support Package
To install the Automated Driving Toolbox™ Interface for Unreal Engine® 4 Projects support package, follow these steps:
On the MATLAB® Home tab, in the Environment section, select Add-Ons > Get Add-Ons.
In the Add-On Explorer window, search for the Automated Driving Toolbox Interface for Unreal Engine 4 Projects support package. Click Install.
Note
You must have write permission for the installation folder.
Set Up Scene Customization Using Support Package
The Automated Driving Toolbox Interface for Unreal Engine 4 Projects support package includes these components:
AutoVrtlEnv
folder — An Unreal Engine project folder containing theAutoVrtlEnv.uproject
file and corresponding supporting files. This project contains editable versions of the prebuilt scenes that you can select from the Scene name parameter of the Simulation 3D Scene Configuration block.MathWorkSimulation
— A plugin that establishes the connection between Simulink and the Unreal Editor. It is required for co-simulation.RoadRunnerScenes
folder — A folder containing the Unreal Engine project and corresponding executable for a scene that was created by using the RoadRunner scene editing software. This folder contains these subfolders:RRScene
— An Unreal Engine project folder containing theRRScene.uproject
file and corresponding supporting files. This project contains an editable version of the scene used in the Highway Lane Following with RoadRunner Scene example.WindowsPackage
— A folder containing the executableRRScene.exe
and supporting files. Use this executable to co-simulate the Simulink models explained in the Highway Lane Following with RoadRunner Scene example.
To set up scene customization, you must copy the
AutoVrtlEnv
project and MathWorksSimulation
plugin folder onto your local machine. To customize the RoadRunner scene used in the Highway Lane Following with RoadRunner Scene example, you must
also copy the RRScene
project onto your local machine and download
the RoadRunnerMaterials
plugin and copy it into your local
project.
Copy AutoVrtlEnv
Project to Local Folder
Copy the AutoVrtlEnv
project folder into a folder on your local
machine.
Specify the path to the support package folder that contains the project. If you previously downloaded the support package, specify only the latest download path, as shown here. Also specify a local folder destination in which to copy the project. This code specifies the local folder of
C:\Local
.supportPackageFolder = fullfile( ... matlabshared.supportpkg.getSupportPackageRoot, ... "toolbox","shared","sim3dprojects","spkg"); localFolder = "C:\Local";
Copy the
AutoVrtlEnv
project from the support package folder to the local destination folder.projectFolderName = "AutoVrtlEnv"; projectSupportPackageFolder = fullfile(supportPackageFolder,"project",projectFolderName); projectLocalFolder = fullfile(localFolder,projectFolderName); if ~exist(projectLocalFolder,"dir") copyfile(projectSupportPackageFolder,projectLocalFolder); end
The
AutoVrtlEnv.uproject
file and all of its supporting files are now located in a folder namedAutoVrtlEnv
within the specified local folder. For example:C:\Local\AutoVrtlEnv
.
Copy MathWorksSimulation
and MathWorksAutomotiveContent
Plugin to Unreal Editor
Copy the MathWorksSimulation
and
MathWorksAutomotiveContent
plugin folders into the
Plugins
folder of your Unreal Engine installation.
Specify the local folder containing your Unreal Engine installation. This code shows the default installation location for the editor on a Windows® machine.
ueInstallFolder = "C:\Program Files\Epic Games\UE_4.26";
Copy the plugin from the support package into the
Plugins
folder.mwSimPluginName = "MathWorksSimulation.uplugin"; mwAutoPluginName = "MathWorksAutomotiveContent.uplugin"; mwPluginFolder = fullfile(supportPackageFolder,"plugins"); uePluginFolder = fullfile(ueInstallFolder,"Engine","Plugins"); uePluginDestination = fullfile(uePluginFolder,"Marketplace","MathWorks"); cd(uePluginFolder) foundPlugins = [dir("**/" + mwSimPluginName); dir("**/" + mwAutoPluginName)] if ~isempty(foundPlugins) numPlugins = size(foundPlugins,1); msg2 = cell(1,numPlugins); pluginCell = struct2cell(foundPlugins); msg1 = "Plugin(s) already exist here:" + newline + newline; for n = 1:numPlugins msg2{n} = " " + pluginCell{2,n} + newline; end msg3 = newline + "Please remove plugin folder(s) and try again."; msg = msg1 + msg2 + msg3; warning(msg); else copyfile(fullfile(mwPluginFolder,'mw_simulation'),uePluginDestination); copyfile(fullfile(mwPluginFolder,'mw_automotive'),uePluginDestination); disp("Successfully copied MathWorksSimulation and MathWorksAutomotiveContent plugins to UE4 engine plugins!") end
(Optional) Copy RRScene
Project to Local Folder
To customize the scene in the RRScene
project folder, copy the
project onto your local machine.
Specify the path to the support package folder that contains the project. Also specify a local folder destination to copy the project. This code uses the support package path and local folder path from previous sections.
rrProjectSupportPackageFolder = fullfile( ... matlabshared.supportpkg.getSupportPackageRoot, ... "toolbox","shared","sim3dprojects","driving", ... "RoadRunnerScenes","RRScene"); rrProjectLocalFolder = fullfile(localFolder,"RRScene");
Copy the
RRScene
project from the support package folder to the local destination folder.if ~exist(rrProjectLocalFolder,"dir") copyfile(rrProjectSupportPackageFolder,rrProjectLocalFolder); end
The RRScene.uproject
file and all of its supporting files are
now located in a folder named RRScene
within the specified local
folder. For example: C:\Local\RRScene
.
(Optional) Copy RoadRunnerMaterials
Plugin to Unreal Editor
When customizing the scene in the RRScene
project folder, you
must also copy the RoadRunnerMaterials
plugin to your plugin
project folder.
Download the ZIP file containing the latest RoadRunner plugins. See Downloading Plugins (RoadRunner). Extract the contents of the ZIP file to your local machine. The extracted folder name is of the form
RoadRunner Plugins x.x.x
, wherex.x.x
is the plugin version number.Specify the path to the
RoadRunnerMaterials
plugin. This plugin is located in theUnreal/Plugins
folder of the extracted folder. Update this code to match the location where you downloaded the plugin and the plugin version number.rrMaterialsPluginFolder = fullfile("C:","Local","RoadRunner Plugins 1.0.3", ... "Unreal","Plugins","RoadRunnerMaterials");
In your local
RRScene
project, create aPlugins
folder in which to copy the plugin. This code uses the path to the localRRScene
project specified in the previous section.rrProjectPluginFolder = fullfile(rrProjectLocalFolder,"Plugins","RoadRunnerMaterials");
Copy the
RoadRunnerMaterials
plugin to thePlugins
folder of your local project.copyStatus = copyfile(rrMaterialsPluginFolder,rrProjectPluginFolder); if copyStatus disp("Successfully copied RoadRunnerMaterials plugin to RRScene project plugins folder.") else disp("Unable to copy RoadRunnerMaterials plugin to RRScene project plugins folder.") end
After you install and set up the support package, you can begin customizing scenes. If you want to use a project developed using a prior release of the Automated Driving Toolbox Interface for Unreal Engine 4 Projects support package, you must migrate the project to make it compatible with the currently supported Unreal Editor version. See Migrate Projects Developed Using Prior Support Packages. Otherwise, see Customize Scenes Using Simulink and Unreal Editor.