Interfacing MATLAB Simulink with OpenSim

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
jeevan jayasuriya
Posts: 7
Joined: Wed Jan 12, 2022 5:34 am

Interfacing MATLAB Simulink with OpenSim

Post by jeevan jayasuriya » Tue Apr 12, 2022 3:07 pm

I am trying to get the MEX interface working which is available in the following link which may enables designing custom controllers for OpenSim model in MATLAB Simulink environment.

https://simtk.org/projects/opensimmatlab

However, different errors comes for different combinations of software versions (Visual Studio, MATLAB, CMake, OpenSim, SimBody).

If any of you succeeded in this regard, please kindly let me know with what software version combination it worked properly.

Also any other directions to how OpenSim could be connected with MATLAB Simulink is highly appreciated.

Tags:

User avatar
Nicos Haralabidis
Posts: 195
Joined: Tue Aug 16, 2016 1:46 am

Re: Interfacing MATLAB Simulink with OpenSim

Post by Nicos Haralabidis » Tue Apr 12, 2022 8:37 pm

Hello Jeevan,

A long time ago I used the MEX functionality in Matlab 2017b together with OpenSim 3.3. The function I have attached (see below) should compile a *.cpp source file. You may need to modify the location of where I point to the dynamic link libraries! I hope that helps!

function compileMEX(cppFileName)

% Input
% cppFileName - .cpp Filename as a string

% Function for compiling Matlab mex function with OpenSim Compatibility
eval(['mex ',cppFileName,' -L''c:\OpenSim 3.3\sdk\lib'' -losimCommon -losimSimulation -losimAnalyses -losimActuators -losimTools -lOpenSim_SimTKcommon -lOpenSim_SimTKmath -lOpenSim_SimTKsimbody -losimJavaJNI -losimLepton -losimSimmFileWriter -I''C:\OpenSim 3.3\sdk\include'' -I''C:/OpenSim 3.3/sdk/include/SimTK/include'' -DWIN32 -D_WINDOWS -DNDEBUG'])

end

Best wishes,

Nicos Haralabidis

User avatar
Nicos Haralabidis
Posts: 195
Joined: Tue Aug 16, 2016 1:46 am

Re: Interfacing MATLAB Simulink with OpenSim

Post by Nicos Haralabidis » Tue Apr 12, 2022 8:46 pm

You will likely also need to use and install Microsoft Visual Studio 2015 such that the compiler matches the one used for OpenSim 3.3...

User avatar
jeevan jayasuriya
Posts: 7
Joined: Wed Jan 12, 2022 5:34 am

Re: Interfacing MATLAB Simulink with OpenSim

Post by jeevan jayasuriya » Mon Apr 25, 2022 1:57 pm

Thank you for your reply. I will try this in the way you had specified.

POST REPLY