Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

Often the best way of figuring out how to code is to use examples from already written scripts or functions. Many example scripts and functions can be found in the OpenSim 4.0 resources directory (Typically /Documents/OpenSim/4.0/Code/Matlab). You can also download some additional example scripts that use the current API;

plotMuscleFLCurves.mFunction to compute and plot the active and passive force-length muscle curves
createActuatorsFile.mFunction to generate a generic OpenSim Actuator File from a Model
build_and_simulate_simple_arm.mDemonstrates building and simulating a simple arm model
pendulum_marker_positions.mBuild, simulate, and generate outputs for a double-pendulum model. Writes the results to .sto and .trc files.

...

As you look through the OpenSim doxygen or if you look at OpenSim API examples, in C++, you may see objects/classes with names like Array_<double> or Vec<3>. These are called templatized classes; this is another functionality that exists in C++ to help programmers simplify and reuse common code. But this doesn't exist in Matlab. So we have created scripting versions of the most commonly used templatized classes. You can find a list of all of these on the page Scripting Versions of OpenSim C++ API Calls. If you see a class name with angle brackets (< >), you can look it up on this page to find the class name to use in Matlab. 

 


...

Adding Geometry Paths to Matlab 

...

Alternatively, a 'workaround' that if you are not visualizing the model is to remove the geometry from the model. This should only be used if you are doing many model instantiations or initSystem() calls and don't need to visualize the model.   

...

Outputs

OpenSim 4.0 uses component outputs and reporters to collect variables of interest and print them to file. To display the output names for a component, use the method getOutputNames();

Code Block
>>> muscle.getOutputNames();