Simulink model stops when matlab script runs
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2022-6-1
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 个评论
Walter Roberson
2022-6-7
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 ?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!