Is it possible to integrate a vrml file with simulink and .m file simultaneously

Illustration
matlab_qus - 2021-08-14T10:38:24+00:00
Question: Is it possible to integrate a vrml file with simulink and .m file simultaneously

I am using a simulink model to control a transform node of a .wrl file (using vr sink). Along with that I want to display the path traversed by the object(same transform node) using pointSet node. Since the points are generated using the simulink model dynamically, I planned to use a .m file to access transform nodes current position and pass it to the coordinate node of pointSet node. But I found that I am not able to simultaneously access the file(.wrl) from both simulink as well as .m file(maybe because it might create a memory lock situation though i am not writing same variables at both the places). Kindly provide an answer. If my approach is completely wrong, please tell me an alternative approach to display path traversed by an object when the object is controlled using a simulink model.  

Expert Answer

Profile picture of Neeta Dsouza Neeta Dsouza answered . 2025-11-20

You should be able to access a single virtual world simultaneously from both MATLAB and Simulink. If you get any errors, this is probably a problem with your code
 
The following code illustrates how to do a task very similar to yours, using a shipping example:
% open and start an example model
vrbounce
set_param(gcs, 'SimulationCommand', 'start');

% open the virtual world in MATLAB
w = vrworld('vrbounce.wrl');
open(w);

% read a value being changed by the running Simulink model
for i=1:10;
  w.Ball.translation
  pause(0.1);
end

% clean up
set_param(gcs, 'SimulationCommand', 'stop');
close(w);

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!