/
C++ API Examples

C++ API Examples

OpenSim comes with a variety of C++ API examples, located in <OpenSimResourcesDir>/Code/CPP (where, by default, <OpenSimResourcesDir> is C:\Users\<username>\Documents\OpenSim\4.x on Windows and ~/Documents/OpenSim/4.x on Mac). In the list below, we provide the subdirectory in the Code/CPP folder where you can find each example.

  1. Performing a Simulation (ExampleMain) Write a main C++ program (a "tug of war") to create a model and run a forward simulation.
    1. This example requires updating. For now, refer to the complete code in the ExampleMain/OutputReference folder.

  2. Creating Your Own Analysis (Plugins/AnalysisPluginExample) Write your own Analysis to output the center of mass and orientation of each body in a model.
  3. Creating a Controller (ControllerExample) Extend the tug of war example with a custom controller.
  4. Creating an Optimization (OptimizationExample_Arm26) Write an optimization to find muscle controls to maximize the forward velocity of the hand.
  5. Creating a Customized Actuator (CustomActuatorExample) Implement a spring with controllable stiffness.
  6. Creating a Customized Muscle Model (MuscleExample) Implement a muscle model with fatigue.
  7. Managing data in (DataTable, DataAdapter) Build a DataTable and read data files into memory.
  8. Use Sockets, Inputs, and Outputs (ExampleHopperDevice) Attach an assistive device to a model to maximize jump height.
  9. Build a model of a muscle-actuated Luxo Lamp (ExampleLuxoMuscle) This model uses kinematic constraints to form a parallel linkage.

This list is not comprehensive. Search the Code/CPP folder for additional examples.

To get started with any of these examples, refer to How to Build a C++ Example.

 

 

 

Related content

API Examples
More like this
Scripting
More like this
Introduction to the OpenSim API
Introduction to the OpenSim API
More like this
Examples and Tutorials
Examples and Tutorials
More like this
Technical Background
Technical Background
More like this

OpenSim is supported by the Mobilize Center , an NIH Biomedical Technology Resource Center (grant P41 EB027060); the Restore Center , an NIH-funded Medical Rehabilitation Research Resource Network Center (grant P2C HD101913); and the Wu Tsai Human Performance Alliance through the Joe and Clara Tsai Foundation. See the People page for a list of the many people who have contributed to the OpenSim project over the years. ©2010-2024 OpenSim. All rights reserved.