Problem with building a model controlling Quanser hardware with signals from a webcam

8 views (last 30 days)
Hi,
I'm currently trying to use a camera to control a ball and plate experiment with Quanser Hardware. I'm using Windows 10 (64 Bit), Matlab 2016b (the version of the toolboxes are mentioned after the error-protocol) I can compile and run a Simulink-Model which reads the coordinates of the ball from a touch panel and I can run a script reading images from a camera and returning the coordinates from this picture. However, if I want to implement this script into the Simulink Model and want to build this model, I get an error:
Error using tlc_c (line 179)
Error due to multiple causes.
Error in coder.internal.ModelBuilder/make_rtw (line 630)
[buildResult, profilingInstrumentationData] = tlc_c(h,...
Error in coder.internal.ModelCodegenMgr/make_rtw (line 8)
buildResult = obj.make_rtw(varargin);
Error in make_rtw (line 18)
buildResult = h.make_rtw(varargin{:});
Error in build_target
Error in build_target
Error in build_standalone_rtw_target
Error in slbuild_private
Error in slbuild_private
Error in sl (line 15)
[varargout{1:nargout}]=feval(varargin{:});
Error in slbuild (line 61)
sl('slbuild_private', mdl, varargin{:});
Error in rtwbuild (line 207)
slbuild(sys, 'StandaloneRTWTarget', ...
Error in lq_design (line 176)
rtwbuild(main.menu.sim_name);
Error in run (line 96)
evalin('caller', [script ';']);
Error in exe (line 74)
run('./data/lq_design.m')
Error in run (line 96)
evalin('caller', [script ';']);
Caused by:
Error using tlc_c (line 179)
Errors occurred during parsing of MATLAB function 'MATLAB Function' Error using tlc_c (line 179)
Error occurred in 'lqr_System_prefilter/MATLAB Function'.
The following toolboxes are used:
MATLAB Version 9.1 (R2016b)
Simulink Version 8.8
Image Acquisition Toolbox Version 5.1 (R2016b)
Image Processing Toolbox Version 9.5
MATLAB Coder Version 3.2 (R2016b)
MATLAB Compiler Version 6.3 (R2016b)
MATLAB Compiler SDK Version 6.3
Quanser HIL MATLAB API Version 3.7.1637.0
Quanser Real-Time Control (QUARC) Version 2.5.1637.0
Quanser Real-Time Control (QUARC) Demonstrations Version 2.5.1637.0
Quanser Real-Time Control (QUARC) Simulink blocks Version 2.5.1637.0
Which additional information are needed to solve this question? Does anyone have ever build a Simulink-Model using Quanser Hardware together with other Hardware? What can be possible be wrong? Where can I search for further information?
With kind regards, Alexander Härtel

Answers (3)

Roberto Chan
Roberto Chan on 24 Nov 2017
Hello Alexander,
The problem might be with a function called on the script. This function might not be compatible with Simulink Coder. If this is the case, you might be able to run the script outside of the Simulink model and interface both (script and model) using QUARC's Stream functions. You can find an example on how to do this in the QUARC example library (the examples can be access by entering qc_show_demos in MATLAB command window). The example is called "QUARC Blocking Client Script Demo". This is under the "Stream" section.
You can contact tech@quanser.com for more information. You can email the script you are using for more information.

Alexander Härtel
Alexander Härtel on 29 Nov 2017
Edited: Alexander Härtel on 29 Nov 2017
Thank you for your help. I got values from the camera. But, how can I start the external script together with the Simulink-Model? And I was not able, to read two parameters from the Stream Server. I thought, that I could Use a demultiplexer, but it says, that the dimensions are set to one. Also with a self written function, see end of this text, I could not extract the values. Now there would be the possibility to multiply the second value in the script for example with 1000 (after truncate so that it does not influence the other value) and then in SIMULINK divide by 1000 and for the first value calculate the modulo 1. But there has to exist a better method.
Self written function
function [x,y]=data_to_points(data_in)
x=data_in(1);
y=data_in(2);
end;

Alexander Härtel
Alexander Härtel on 30 Nov 2017
Edited: Alexander Härtel on 5 Dec 2017
As I saw, that this will be too complicated, I wanted to get the data from the camera (Logitech Webcam C930e) using "From Video Device" Block in Simulink. Normally, the device should be chosen when dragging the block into the Simulink model. However, when I drag this Block into Simulink, It asks for a Camera File. Where do I get this file from? The help to this block only shows blocks, where the camera is chosen automatically (see attached image).
Also, I can use an existing block, where the camera is specified. However, when I want to start the model, I get the following error:
Could not connect to image acquisition device.
Undefined function or variable 'imaqfind'.
When I open the block, the Block Parameters window looks the one where I couldn't specify the video device.
As I posted at the start post, I have image aquisition toolbox installed. But I saw, that there is no license for the Computer Vision System Toolbox, even so it is listed when I type "ver" in the matlab console.
With much hope and kind regards,
Alexander Härtel

Community Treasure Hunt

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

Start Hunting!