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.
Interfacing MATLAB Simulink with OpenSim
- jeevan jayasuriya
- Posts: 7
- Joined: Wed Jan 12, 2022 5:34 am
- Nicos Haralabidis
- Posts: 196
- Joined: Tue Aug 16, 2016 1:46 am
Re: Interfacing MATLAB Simulink with OpenSim
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
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
- Nicos Haralabidis
- Posts: 196
- Joined: Tue Aug 16, 2016 1:46 am
Re: Interfacing MATLAB Simulink with OpenSim
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...
- jeevan jayasuriya
- Posts: 7
- Joined: Wed Jan 12, 2022 5:34 am
Re: Interfacing MATLAB Simulink with OpenSim
Thank you for your reply. I will try this in the way you had specified.