MATLAB: How to create a Simulink executable that will update a Virtual Reality node using External Mode in Simulink

realitySimulink 3D Animationsimulink codersimviewingdevicevirtual

I want to generate code from a model that contains a Virtual Reality node. In the model, an embedded MATLAB function performs some calculations on the signal and updates the VR node accordingly. The executable should send signal values to the model using External Mode.

Best Answer

To obtain the described behavior, you must define the Embedded MATLAB block as a "SimViewingDevice":
1. Open the attached model
2. Use the command:
set_param('spine_tst_embed_rtw2/Subsystem', 'SimViewingDevice','on')
3) Make sure that "Configuration Parameters > Real-Time Workshop > Interface" is set to "External Mode".
3. Generate code from the model (GRT Target, for example).
4. Run the executable by using the command:
!spine_tst_embed_rtw2 & -w
5. Connect to the executable and run the model.
You should be able to see the Virtual Reality node updated based on the executable signals.