Use Unreal Engine with Simulink, Part 2: Preparations for Creating Custom Scenes
From the series: Using Unreal Engine with Simulink
Part 2 of this series explains how to download and set up the necessary files from a support package to create and connect to a custom Unreal Engine® scene. You can read more about the setup on this help page. You can also find information about RoadRunner in this video series.
Published: 13 Oct 2021
Welcome back to our video series on Using Unreal Engine with Simulink. So far, we've shown you an example that uses one of our pre-built scenes. But what if you wanted to customize those scenes or create one of your own? In this video, we will show you how to set up the software to do that.
So let's say that you want to create a brand new scene where you can create the specific layout of the roads and other objects you want. In this case, I would recommend you start with Roadrunner. This is a MathWorks products designed for just that purpose.
You can even build your own scene in Roadrunner then export it to Unreal Engine, so you can connect it to your Simulink models. There is great tutorial on this workflow already. So I won't repeat it all here. Check out the links to that video in the description.
Another way to create custom scenes is to use the Unreal Editor directly. To do that, you'll need to install a support package, which includes some Unreal engine assets; vehicles, buildings, roads, and the plugin for communicating between Simulink and the Unreal editor.
The support package files are specific to the version of MATLAB, and each version of MATLAB supports a specific version of Unreal. So check the help page to make sure you have compatible versions of the tools that you'll need. Installing the sport package is pretty straightforward, just go to the Add-On Explorer in MATLAB, and search for Unreal Engine Interface. You'll find a few hits, so select the one for the product that you're using. In my case, that's the Vehicle Dynamics block set.
Now just follow the prompts to download and install the files. Because the Unreal Engine assets can be quite large. This might take a while. Once you've installed the files, you'll need to perform a one time setup. The setup steps may differ for the version of MATLAB that you're using. On using R2021a here. But the online help page will walk you through it for your specific version. The help page includes a script that you can use to automate this process, but I'm going to do it manually here so you can see what's happening.
First, I need to copy some Unreal Engine plugin files from the support package install directory into my Unreal Engine installed directory. If you use the MathWorks plugin with the older versions of MATLAB, you'll want to remove that first to make sure that you're Unreal Engine plug-in is compatible with the version of MATLAB that you're using.
Second, I'm going to make a copy of the Unreal Engine project from the sport package install directory into a local folder so I can customize it without modifying the original version. At this point, I'm ready to create some custom scenes. Now there are a couple of ways you can do that.
One is to co-simulate directly with the Unreal editor. So you can quickly make changes to that scene, and then run it with Simulink The other is to compile that scene into a standalone executable that you can run without the Unreal editor. In the next video, or cover the workflow for co-simulating with the Unreal editor.