Simulation 3D of Simulink 3D animation is working in real-time?
Mostrar comentarios más antiguos
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
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
Giada Parodi
el 7 de Oct. de 2024
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
el 9 de Oct. de 2024
Categorías
Más información sobre System Configuration en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!