Install Support Package for Customizing Scenes

To customize scenes in the Unreal® Editor and use them in Simulink®, you must install the Automated Driving Toolbox™ Interface for Unreal Engine® 4 Projects.

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. In particular, verify that you have Visual Studio® 2017 installed. This software is required for using the Unreal Editor to customize scenes.

In addition, verify that your project is compatible with Unreal Engine, Version 4.23. If your project was created with an older version of the Unreal Editor, upgrade your project to version 4.23.

Install Support Package

To install the Automated Driving Toolbox Interface for Unreal Engine 4 Projects support package, follow these steps:

  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 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 the AutoVrtlEnv.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.uplugin — A plugin file 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 the RRScene.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 executable RRScene.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 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.

  1. 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","driving");
    localFolder = "C:\Local";
    
  2. Copy the AutoVrtlEnv project from the support package folder to the local destination folder.

    projectFolderName = "AutoVrtlEnv";
    projectSupportPackageFolder = fullfile(supportPackageFolder,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 named AutoVrtlEnv within the specified local folder. For example: C:\Local\AutoVrtlEnv.

Copy MathWorksSimulation Plugin to Unreal Editor

Copy the MathWorksSimulation plugin into the Plugins folder of your Unreal Engine installation.

  1. 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.23";
  2. Copy the plugin from the support package into the Plugins folder.

    mwPluginName = "MathWorksSimulation.uplugin";
    mwPluginFolder = fullfile(supportPackageFolder,"PluginResources","UE423");
    uePluginFolder = fullfile(ueInstallFolder,"Engine","Plugins");
    uePluginDestination = fullfile(uePluginFolder,"Marketplace","MathWorks");
    
    cd(uePluginFolder)
    foundPlugins = dir("**/" + mwPluginName);
    
    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(mwPluginFolder,uePluginDestination);
        disp("Successfully copied MathWorksSimulation plugin 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.

  1. 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(supportPackageFolder, ...
        "RoadRunnerScenes","RRScene");
    rrProjectLocalFolder = fullfile(localFolder,"RRScene");
  2. 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.

  1. 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, where x.x.x is the plugin version number.

  2. Specify the path to the RoadRunnerMaterials plugin. This plugin is located in the Unreal/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");
  3. In your local RRScene project, create a Plugins folder in which to copy the plugin. This code uses the path to the local RRScene project specified in the previous section.

    rrProjectPluginFolder = fullfile(rrProjectLocalFolder,"Plugins","RoadRunnerMaterials");
  4. Copy the RoadRunnerMaterials plugin to the Plugins 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. See Customize Scenes Using Simulink and Unreal Editor.

Related Topics