Send a single Integer data from Simulink to UnrealEngine
5 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Dinesh
2023-5-4
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 个评论
Dinesh
2023-5-4
@JUDITH NJOKU to use the shared memory approach, you can use the following steps:
- 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.
- 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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!