You are viewing the documentation for OpenSim 3.x. Are you looking for the latest OpenSim 4.0 Documentation?

Performing a Simulation

Overview

In this chapter, we will write a main program to perform a forward dynamic simulation using the OpenSim API. We will build it up in pieces, starting from the simplest possible OpenSim model, a single block experiencing the force of gravity. In the end, we will have an OpenSim model with two muscles performing a tug-of-war on the block, with the muscles and ground reactions counteracting the gravitational force. The resulting source code and associated files for this example come with the OpenSim distribution under the directory:

<OpenSimInstallDir>\sdk\APIExamples\ExampleMain

Performing a forward dynamic simulation in OpenSim involves a series of steps. Each of these steps usually requires only a few lines of code. The following sections explain the steps by gradually developing a complete program, stopping at points where the partial program can be compiled, run, and its results visualized.

For your convenience, we have provided the source code as a series of exercise-labeled development snapshots, gradually leading up to the complete program which is called TugOfWar_Complete.cpp. After most steps, we will be using the OpenSim GUI to visualize the model and the motions that result from running the simulations. See the OpenSim User's Guide for details on using the OpenSim GUI. Each of the steps below generates output files with the same names:

 

 

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.