How can i use ' libisloaded() ' function and ' addpath' function in SIMULINK?

5 次查看(过去 30 天)
Hi, I have a project using RPLIDAR A1M8, Dynamixel MX-64 and two motors with encoder to make 3D scan with 2D lidar.
Connectting and using each thing was not that problem. and I made it act step by step (scan -> turn lidar -> move -> scan ....).
I tried it to act parallel but I can't load library in parpool. It showed error.
So I'm trying to make it in Simulink. (I think it will be more convenient because motor PID file is simulink file.)
But it showed error too.
when I use
hardwarex_init;
this mfile is
%hardwarex_init
if not(libisloaded('hardwarex'))
addpath('.');
switch (computer)
case 'PCWIN64'
addpath('x64');
%loadlibrary('hardwarex', @hardwarex_proto);
[notfound,warnings]=loadlibrary('hardwarex', @hardwarex_proto);
case 'PCWIN'
addpath('x86');
%loadlibrary('hardwarex');
[notfound,warnings]=loadlibrary('hardwarex', @hardwarex_proto);
otherwise
%loadlibrary('hardwarex');
[notfound,warnings]=loadlibrary('hardwarex', 'hardwarex.h', 'includepath', 'MAVLinkSDK', 'includepath', '/usr/local/include', 'includepath', 'sbgECom/src', 'includepath', 'sbgECom/common', 'includepath', '/usr/local/include/sbgECom/src', 'includepath', '/usr/local/include/sbgECom/common', 'includepath', 'rplidar_sdk/sdk/sdk/include', 'includepath', 'rplidar_sdk/sdk/sdk/src', 'includepath', '/usr/local/include/rplidar_sdk/sdk/sdk/include', 'includepath', '/usr/local/include/rplidar_sdk/sdk/sdk/src');
end
%libfunctions hardwarex -full
end
libisloaded and addpath were problem when this file was processed.
I got this file in github.

回答(1 个)

Aghamarsh Varanasi
Aghamarsh Varanasi 2021-3-11
Hi,
You can call this MATLAB Script in the 'PreLoadFcn' callback of Simulink.
Refer to this documentation page to learn more about Model Callbacks.

类别

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