MATLAB Answers

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

4 views (last 30 days)
준기 홍
준기 홍 on 26 Feb 2021
Answered: Aghamarsh Varanasi on 11 Mar 2021
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.

Answers (1)

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

Community Treasure Hunt

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

Start Hunting!