Simulink model stops when matlab script runs

1 visualización (últimos 30 días)
Dimuthu Arachchige
Dimuthu Arachchige el 1 de Jun. de 2022
Comentada: Walter Roberson el 7 de Jun. de 2022
I have the following matlab script which simply configures a disparity map and opens it with imshow. The script runs just fine on its own
load('stereoParams.mat');
vidobj=videoinput('winvideo',1);%,'MJPG_1280x480');
triggerconfig(vidobj, 'manual');
N=500;
start(vidobj)
try
for i=1:N
img=getsnapshot(vidobj);
imgL = img(:,1:640,:);
imgR = img(:,641:1280,:);
[JL,JR] = rectifyStereoImages(imgL,imgR,stereoParams);
IL = rgb2gray(JL);
IR = rgb2gray(JR);
disparityMap = disparitySGM(IL,IR);
imshow(disparityMap,[0,64],'InitialMagnification',50);
end
catch
delete(vidobj);
close all
Additionally, I have a simulink model that I am using to control a robot with a joystick. However, the simulink model and the matlab script are not able to run simultaneously. If the script is running and the model begins, the script freezes. If the model is running and the script is started, the model freezes. Any help would be appreciated.

Respuestas (1)

Walter Roberson
Walter Roberson el 1 de Jun. de 2022
Simulink and MATLAB normally run in the same context, not in different threads or processes (you can tell by the way that Simulink has access to MATLAB variables.)
If your model can be run without access to graphics, then potentially you might be able to start it in a Background Pool, if you have a new enough MATLAB.
Question: how is the model getting control information? In particular is it trying to use the same camera?
  2 comentarios
Dimuthu Arachchige
Dimuthu Arachchige el 7 de Jun. de 2022
Thank you for your suggestion. The answers to your questions, I don't take any information from the camera to the controller. I just need to get the disparity map from the camera and control the robot seperately.
Any suggestion for this?
Walter Roberson
Walter Roberson el 7 de Jun. de 2022
Suppose you get the disparity map from the camera into the MATLAB session. And then you process it, and display results... and you manually use that information to inform you of where you should turn your joystick? But the joystick is connected to the Simulink session ?

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by