Simulation 3D of Simulink 3D animation is working in real-time?

30 visualizaciones (últimos 30 días)
Giada Parodi
Giada Parodi el 4 de Oct. de 2024
Comentada: Giada Parodi el 9 de Oct. de 2024
Hello everyone,
I'm currently working on a project in Simulink where I need to control 3D objects in real-time. These objects are connected to controllers like a mouse or a robot. For instance, I have a cursor that moves based on mouse input, and its position changes continuously.
I have been using Simulink Desktop Real-Time (SLDRT) to achieve the real-time performance required for my project. However, I've learned that in upcoming versions of MATLAB, the Virtual Reality (VR) Sink blocks used for 3D visualization will be removed. The MATLAB documentation suggests using Simulation 3D blocks (like Simulation 3D Scene Configuration, Simulation 3D Actor, etc.) as replacements.
I attempted to implement these Simulation 3D blocks, but I've run into several limitations, which are also detailed Unreal Engine Simulation Environment Requirements and Limitations - MATLAB & Simulink - MathWorks Italia. The main issue is that the Simulation 3D blocks do not support SLDRT. When I try to run my model, I receive the following error: "The selected system target file 'sldrt.tlc' is not currently supported for concurrent execution."
My question is: How can I achieve real-time 3D visualization in Simulink, given that the VR Sink blocks are being deprecated and the Simulation 3D blocks don't support SLDRT? Are there alternative methods or tools that I can use to visualize my 3D models in real-time while still using SLDRT?
Any advice or suggestions would be greatly appreciated!
Thank you.

Respuestas (1)

Maneet Kaur Bagga
Maneet Kaur Bagga el 7 de Oct. de 2024
Hi,
As per my understanding you want to achieve "real-time 3D visualization" using SLDRT and the recommended "Simulation 3D block" in the deprecated "VR Sink block" documentation throws the error "The selected system target file 'sldrt.tlc' is not currently supported for concurrent execution".
As a possible workaround you can use "Simulation 3D Animation" to control your objects in real time using SLDRT. To implement real-time 3D visualization using Simulink 3D Animation with SLDRT please refer to the following steps:
  • Set up your real-time control model in Simulink using SLDRT. Use blocks like "To Workspace", "UDP Send", or "Serial Send" to output the real-time position and orientation data from your SLDRT model. This data will be used to update the virtual world’s 3D objects. Under Code Generation, choose the target as "Simulink Desktop Real-Time (sldrt.tlc)" to run the control model in real time.
  • Use the 3D World Editor to create or import a virtual world (*.wrl file) where you can place and animate 3D objects. Save this world as a ".wrl file". Insert node for each 3D dynamic object to be animated in real-time.
vrworld('filename.wrl');
vredit('filename.wrl');
  • Open and connect to the virtual world. Using the "vrnode" function access these nodes programatically.
vw = vrworld('filename.wrl');
open(vw);
view(vw); % Opens the 3D world in the viewer
cursorNode = vrnode(vw, 'Cursor'); % Access the "Cursor" node
  • Update the positions of the 3D objects in the virtual world using the real time control data.
while true
% Read real-time data from the workspace or SLDRT model
cursorPos = evalin('base', 'cursorPosition'); % Assume 'cursorPosition' is output from SLDRT
% Update the virtual world object position
cursorNode.translation = cursorPos; % Update position in 3D world
pause(0.01); % Pause briefly to simulate real-time
end
  • Visualize the real time interaction uisng "3D Viewer".
view(vw);
Please refer to the following MathWorks documentation for further understanding.
I hope this helps!
  3 comentarios
Maneet Kaur Bagga
Maneet Kaur Bagga el 9 de Oct. de 2024
Editada: Maneet Kaur Bagga el 9 de Oct. de 2024
Hi Giada,
As per the documentation of the "Simulation 3D Scene Configuration" the version history suggests that it works for the Unreal Engine Simulation Environment.
Can you please try turning off the "concurrent execution" and try again if it helps.
Giada Parodi
Giada Parodi el 9 de Oct. de 2024
Hi! I received this from the staff:
"You are correct in your understanding of the limitations of Simulation 3D blocks that we currently do not support SLDRT. I apologize that we have not achieved the same level of functionality just yet, but know that this is an important consideration for the team and are looking into this for future releases.
There are a couple of different options here that I can think of while we improve the parity between Virtual Reality blocks and Simulation 3D blocks:
  1. The first one was what I believe tech support suggested to you: Split your model into two separate models: The first is running the Simulation 3D blocks and sends/receives data from the second model via UDP, ROS, etc. The second model contains any Simulink Desktop Real Time blocks and the rest of your application that supports the sldrt.tlc target as well as the blocks necessary to send/receive UDP data from the first model.
  2. Continue using this functionality that is still supported in R2024b, and only move onto a newer MATLAB version once the sldrt.tlc target is supported with Simulation 3D blocks. "
So for now these are the solutions.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by