How do I control a virtual world using code generated by Real-Time Workshop?

Illustration
programming_center - 2021-08-16T12:33:34+00:00
Question: How do I control a virtual world using code generated by Real-Time Workshop?

I created a model that drives a virtual world. When I generate and build code from this model, I am unable to control the virtual world with the generated executable.  

Expert Answer

Profile picture of John Michell John Michell answered . 2025-11-20

he generated code alone cannot be used to control the virtual world. You must interface to the generated code using External mode. For example, open the demo vrmaglev and follow these steps.
 
1. Select Tools->Real-Time Workshop->Options
2. Click on the Interface node.
3. In the Data Exchange section, select External Mode from the pull down menu.
4. Push the OK button.
5. Build the model (CTRL-B).
6. From the model menu, select Simulation->External Mode
7. Type the following at the MATLAB command window
!vrmaglev -w
to start the generated executable. Note the -w option will put the executable into a wait state until the host (Simulink) connects to the code.
8. Open the VR window by double clicking on the VR Sink block.
9. Next, you will connect to the running code by selecting Simulation->Connect to Target
10. Once the target is connected, the Simulink "Play" button should be active. Pushing the "Play" button will cause the generated code to drive the VR animation.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!