plugin in Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Bas de Kruif
Posts: 7
Joined: Tue Sep 15, 2015 4:28 am

plugin in Matlab

Post by Bas de Kruif » Mon Feb 22, 2016 8:03 am

Hello all,

Thanks for reading this post. I wrote a plugin for a controller and would like to use the model with this controller from within Matlab. The plugin works when I use it in OpenSim, but I cannot get the model to work in Matlab. I get stuck in the first step in which I try to load the plugin in Matlab.

There is already some information on this topic:
http://simtk-confluence.stanford.edu:80 ... ng+Plugins
https://simtk.org/forums/viewtopic.php? ... tlab#p8878
https://simtk.org/forums/viewtopic.php? ... ary#p11969

However, this doesn't help me to get it to work. I have copied the files MyController.dll to the plugin directory of Opensim. Then I added the path to the plugin directory to librarypath.txt, and tried to load the dll with:

Code: Select all

loadlibrary('MyController.dll','C:\Users\bas\Documents\OSanalysis\controllerPlugin\MyController.h','includepath','C:\Program Files\OpenSim 3.3\sdk\include\')
As a result I get some warnings and errors:

Code: Select all

Warning: Function input has the same name as a MATLAB builtin. We suggest you rename the function to avoid
a potential name conflict. 
> In loadlibrary>@()cd(savedir)
  In onCleanup/delete (line 60)
  In loadlibrary 
Warning: Function version has the same name as a MATLAB builtin. We suggest you rename the function to
avoid a potential name conflict. 
> In loadlibrary>@()cd(savedir)
  In onCleanup/delete (line 60)
  In loadlibrary 
Error using loadlibrary
Failed to preprocess the input file.
 Output from preprocessor is:MyController.h
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xtgmath.h(214) : warning C4602: #pragma
pop_macro : 'new' no previous #pragma push_macro for this identifier
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\eh.h(27) : fatal error C1189: #error :
"eh.h is only for C++!"
Is there a way to circumvent these issues?
I hope somebody can help me get it to work. Thanks for all your time
Bas

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: plugin in Matlab

Post by Christopher Dembia » Mon Feb 22, 2016 10:19 am

Try using Model.LoadOpenSimLibrary("<full-path-to-DLL file>") instead.

User avatar
Bas de Kruif
Posts: 7
Joined: Tue Sep 15, 2015 4:28 am

Re: plugin in Matlab

Post by Bas de Kruif » Tue Feb 23, 2016 2:11 am

Great!

This is working. Thank you very much.
Might it be an idea to add this to the documentation at the top link in the first post?
It works much easier than the loadlibrary().

Keep up the good work.
Bas

POST REPLY