Send a single Integer data from Simulink to UnrealEngine

8 visualizzazioni (ultimi 30 giorni)
I am wondering if anyone has tried to communicate data from Simulink simulation to UnrealEngine scenes. I am trying to visualize the output of MATLAb in Unreal.

Risposte (1)

Dinesh
Dinesh il 4 Mag 2023
Hi Judith.
In your case, the easiest method is to use a MATLAB Function block and a shared memory (file). You can create a MATLAB Function block in Simulink that writes integer data to a shared file. In Unreal Engine, you can create a custom C++ or Blueprint node to read the integer data from the shared file. Now that data can be used to visualize Simulink model result in Unreal Engine.
There are other inbuilt ways in Simulink that can help you with communicating between Simulink and Unreal Engine with some additional installation. It includes installing the Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects support package.
The following link will guide you to getting started with communication to the Unreal Engine.
If your use case includes working with the Vehicle Dynamics Blockset extensively, then the following guide will help you get started.
  3 Commenti
Dinesh
Dinesh il 4 Mag 2023
@JUDITH NJOKU to use the shared memory approach, you can use the following steps:
  1. In your Simulink model, add a MATLAB Function Block to take an input that is the integer that you want to send to Unreal Engine.
  2. Now, you can use a function like the following to save the output from the Simulink model to a text file.
function writeDataToFile(data)
% data is the input of this function to send to Unreal Engine
fileId = fopen('shared_data.txt', 'w');
fprintf(fileId, '%d', data); % saving data to a text file
fclose(fileId);
end
Make sure to add an input port to the block and connect the input of the block to the "data" that you would like to send to Unreal Engine.
3. Now, you can create a C++ function in Unreal Engine to read the data from the shared file.
The following link can help you to do the same.
Now that you have the data in Unreal Engine, you can use it to visualize the result.
JUDITH NJOKU
JUDITH NJOKU il 4 Mag 2023
Thank you so much for this guide. I will try it out and revert.

Accedi per commentare.

Prodotti


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by