필터 지우기
필터 지우기

Send a single Integer data from Simulink to UnrealEngine

조회 수: 2 (최근 30일)
JUDITH NJOKU
JUDITH NJOKU 2023년 5월 4일
댓글: JUDITH NJOKU 2023년 5월 4일
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.

답변 (1개)

Dinesh
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
Dinesh 2023년 5월 4일
@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 2023년 5월 4일
Thank you so much for this guide. I will try it out and revert.

댓글을 달려면 로그인하십시오.

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by