Simulink model stops when matlab script runs
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Antworten (1)
Walter Roberson
am 1 Jun. 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 Kommentare
Walter Roberson
am 7 Jun. 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 ?
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!