Simulink model stops when matlab script runs

조회 수: 2 (최근 30일)
Dimuthu Arachchige
Dimuthu Arachchige 2022년 6월 1일
댓글: Walter Roberson 2022년 6월 7일
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.

답변 (1개)

Walter Roberson
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
Dimuthu Arachchige
Dimuthu Arachchige 2022년 6월 7일
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 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 CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by