Versions Compared

Key

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

Using the OpenSim API

The Developer's Guide has examples using the API, including:

Performing a Simulation Simulation - Write a main C++ program (a "tug of war") to create a model and run a forward simulation

Creating Your Own Analysis Analysis - Write your own Analysis to output the center of mass of each body in a model, plus velocities and accelerations

Creating a Controller Controller - Extend the tug of war example with a custom controller

Creating an Optimization Optimization - Write an optimization to find muscle controls to maximize the forward velocity of the hand

Creating a Customized Actuator Actuator - Implement a spring with controllable stiffness

Creating a Customized Muscle Model Model - Implement a muscle model with fatigue

 


Building the API Examples

A summary of the steps to build the API examples is below. There are more details in the Developer's Guide.  We will use the tug-of-war Example (Located in your OpenSimInstallationDirectory\sdk\APIExamples\ExampleMain folder) as an example.

...

  • Prepare a working directory: Copy the example folder from the installation folder (by default, this is C:\OpenSim 3.0\sdk\APIExamples\ExampleMain) to a working folder. In this example, we will assume the working folder is C:\ExampleMain, but the name and path are arbitrary.
  • Run CMake. Launch CMake. In the dialog box that appears:
    1. For the field "Where is the source code," select the working plug-in directory you just created (e.g., C:\ExampleMain).
    2. Select a directory for "Where to build the binaries." For this example, we will use the folder C:\TugOfWarBuild. (If the directory does not exist CMake will prompt you to ask if it should create the directory after you hit Configure)



    3. Hit Configure and you will see things highlighted in red. Make sure that the correct installation directory is specified for OPENSIM_INSTALL_DIR, and update it if needed. If you use any directory other than the default for installation, you will also need to update CMAKE_INSTALL_PREFIX to have the same value as OPENSIM_INSTALL_DIR.



    4. Click Configure again, and the highlighted red should be cleared, and then Generate.


...




  • You will see a solution file (.sln) generated in the build directory. Double click on it and it will launch Visual Studio

...