Main Content

Install Support Package and Configure Environment

To customize scenes in your installation of the Unreal® Editor and simulate within these scenes in Simulink®, you must first install and configure the Aerospace Blockset™ Interface for Unreal Engine® Projects support package.

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 Aerospace Blockset Interface for Unreal Engine 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 Aerospace Blockset Interface for Unreal Engine Projects support package. Click Install.

    Note

    You must have write permission for the installation folder.

Configure Environment

The Aerospace Blockset Interface for Unreal Engine 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, MathWorkSimulation. 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.

  • A second plugin, MathWorksAerospace. This plugin contains the aerospace components and connects them to MATLAB using the MathWorksSimulation plugin. You must also copy this plugin to your local installation of the editor.

To copy the project to a local folder and the two plugins to your Unreal Editor installation, follow these one-time steps. Use the Code That Configures Scene Configuration (Steps 1–4).

StepDescription
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.25.

3

Copy the MathWorksSimulation and the MathWorksAerospace plugin folders to the Unreal Engine plugin folder.

4

Copy the support package folder that contains the AutoVrtlEnv.uproject files to the local folder destination.

Code That Configures Scene Configuration (Steps 1–4)

%% STEP1
% Specify the location of the support package project files and a local folder destination
% Note:  Only one path is supported. Select latest download path.
dest_root = "C:\Local";
src_root = fullfile(matlabshared.supportpkg.getSupportPackageRoot, ...
    "toolbox", "shared", "sim3dprojects", "spkg");

%% STEP2
% Specify the location of the Unreal Engine installation.
ueInstFolder = "C:\Program Files\Epic Games\UE_4.25";

%% 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", "MathWorksSimulation");

cd(uePluginFolder)
foundPlugins = dir("**/" + mwPluginName + ".uplugin");

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', 'MathWorksSimulation'), uePluginDst);
    disp("Successfully copied MathWorksSimulation plugin to UE4 engine plugins!")
end

% Copy the MathWorksAerospace plugin to the Unreal Engine plugin folder.
asbPluginName = "MathWorksAerospace";
asbPluginDst = fullfile(uePluginFolder, "Marketplace", "MathWorksAerospace");
foundPlugins = dir("**/" + asbPluginName + ".uplugin");

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_aerospace', 'MathWorksAerospace'), asbPluginDst);
    disp("Successfully copied MathWorksAerospace plugin to UE4 engine plugins!")
end

%% 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

See Also

Related Topics