how can i do interface between matlab and opensim simulink without the error below ?

17 views (last 30 days)
i have error when I run the example built with matlab to interface with opensim , while the same example do it in other PC with no error!
I instillation : 2014b,2014a,2013a and same problem. 1) when i run : OpenSimCreateTugOfWarModel.m file , it is work with no error 2) but when i have to run : TugOfWar_CompleteRunVisualize.m to complete simulation i got these errors:
>> TugOfWar_CompleteRunVisualize Loaded model TugOfWar from file tug_of_war_muscles_controller.osim Error using TugOfWar_CompleteRunVisualize (line 38) Java exception occurred: java.lang.RuntimeException: SimTK Exception thrown at VisualizerProtocol.cpp:121: Error detected by Simbody method VisualizerProtocol::ctor(): Unable to spawn executable 'VisualizerGUI' from directories: c:\Program Files\MATLAB\R2014a\bin\win64\ C:\Program Files\Simbody\bin\ C:\Program Files\SimTK\bin\ Final system error was errno=2 (No such file or directory). (Required condition 'status == 0' was not met.)
at org.opensim.modeling.opensimModelJNI.Model_initSystem(Native Method)
at org.opensim.modeling.Model.initSystem(Model.java:179) please answer me ASAP PhD student Sahar

Answers (1)

João Paulo Bonfim
João Paulo Bonfim on 13 Oct 2024
I found this in Scripting part of OpenSim documentation:
Additional information
Advanced background information on how MATLAB scripting works...
MATLAB allows one to load and use Java libraries. OpenSim has a Java interface/library (used by the GUI), allowing us to leverage MATLAB's Java capabilities to provide a MATLAB interface to OpenSim.
  1. OpenSim's Java library is located in the file org-opensim-modeling.jar in the OpenSim installation. To allow MATLAB to use OpenSim's Java library, the configureOpenSim.m file tells MATLAB where this .jar library is located by adding the path to the .jar file to the javaclasspath.txt file in MATLAB's preferences directory (determined by running prefdir in MATLAB).
  2. The .jar file depends on OpenSim's C++ library osimJavaJNI.dll (or libosimJavaJNI.dylib on macOS), and the configureOpenSim.m file tells MATLAB the location of this library by adding the appropriate directory to the javalibrarypath.txt file in MATLAB's preferences directory.
  3. The osimJavaJNI library depends on OpenSim's other C++ libraries. On Windows, for MATLAB to find these other libraries, the directory containing these libraries must be on the system PATH. This step is not necessary on macOS.
  4. The MATLAB interface also involves a few pure MATLAB functions in the C:/Users/<username>/Documents/OpenSim/4.0/Code/Matlab/Utilities folder (by default). The configureOpenSim.m file adds this directory to the MATLAB path.
Troubleshooting
  • OpenSim 4.0 requires 64-bit Matlab.
  • When referring to indexed elements remember that Matlab begins indexing at 1 while OpenSim data structures begin at 0.
  • Errors related to osimJavaJNI not being on the path or "java.lang.NoClassDefFoundError" occur because the OPENSIM_INSTALL_DIR/bin directory is not on the system (Windows) path. Be sure the OPENSIM_INSTALL_DIR/bin directory has been added to the system PATH environment variable. (Note that the system PATH environment variable is distinct from MATLAB's path variable.)
  • If you're seeing errors saying failed dependencies with osimJavaJNI.dll, you would need to have Visual Studio redistribution package installed (which would come with any Visual Studio installation). You can just install the package files without Visual Studio on the Microsoft download site (For example 32-bit VS 2010 package is located here).

Categories

Find more on Simulink Environment Customization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!