Versions Compared

Key

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

The topics covered in this section include:

...

To use the OpenSim API in both scripting and development reasons, its important to know the OpenSim API structure and its dependencies. OpenSim is written using object-oriented programming. It consists of a large set of classes. You can view all classes and their hierarchical structure available in OpenSim using . This is an automatically generated overview of all available code from internal C++ files. Doxygen is your best resource to view all the different classes and functions that are available during scripting and development. Information on how to use OpenSim Doxygen can be found on the Guide to Using Doxygen page.

By interacting with the API, you can interface with OpenSim's libraries and use them in your scripting environment or in development. This could mean that you could use Matlab or Python to manipulate OpenSim objects and run methods (Scale, Inverse Kinematics) or you could use C++ language to build your own class that OpenSim can use, e.g. a new muscle model. It could also mean that you build a standalone (main) program that uses existing OpenSim classes to run custom simulations.

...

NameDescriptionExample
Class

Classes can be thought of as the instruction set to build an object. Classes represent generalizable features and behaviors (methods) of some type (e.g., forces, bodies, muscle, list of objects, analysis) and contain properties, attributes, or data members that are used to create an object of that type.

An abstract Class defines the shared methods of many 'like' classes and can not be instantiated to an object directly. Concrete Classes can be instantiated to objects and inherit the methods of parent abstract classes while defining their own unique methods.

To create a Rectus Femoris (RF) muscle object you could use the Thelen2003Muscle class. This class has a number of editable properties (e.g., maximum isometric force, tendon slack length), as well as a number of sub-objects such as Geometry Path. Once the properties inherited by this Thelen2003Muscle class have been set, an instance (object) of the class called 'Rectus Femoris' can be created.

Object

Objects are considered instances of classes. Objects contain both properties and methods (behaviors) inherited by their class. Classes can create objects that represent analyses (e.g., InverseKinematicsTool) and data lists (e.g., MarkerData) as well as physical systems.

Every muscle attached to the gait2392 model is an "object" (an instance of the Thelen2003Muscle class). The properties of each muscle can be individually specified.

Method

Methods define the behavior of an object when you run a program.

OpenSim::InverseKinematicsTool::run () executes the run method of the InverseKinematicsTool object, performing inverse kinematics according to the specified inputs.

Inheritance

Classes can inherit attributes and behavior from pre-existing classes called base classes, superclasses, or parent classes. The resulting classes are known as derived classes, subclasses, or child classes. The relationships of classes through inheritance give rise to a hierarchy.

Thelen2003Muscle (class) inherits the attributes and behaviors of its parent class 'ActivationFiberLengthMuscle', which in turn inherits the attributes and behaviors of the more general class 'Muscle', which in turn turn inherits the attributes and behaviors of the more general class 'Actuator', etc.
HandleA handle is a reference to an object's resources that, once accessed, gives you the ability to read and write.

ECRB = myModel.getMuscles().get("ECRB") would give you a handle to the ECRB object that exists in the model. You could then edit the parameters of the ECRB muscle (ECRB.setTendonSlackLength(0.22))

ModelComponent

Model components are a specific type of Object that is found in OpenSim. As such, when talking about Components, all Components are Objects but not all Objects are Components.

Components have a simplified interface that allows each component to connect and communicate with other components and the system as a whole. This specially designed communication layer affords users with the ability to build models much like building with lego blocks, stacking components in series or parallel.

Actuators, Bodies, Controllers, and Joints are all ModelComponents. Analyses and Tools are not ModelComponents.

...

Coming soon: a list of key references used in constructing this page

 

Include Page
OpenSim:_Programming Resources
OpenSim:_Programming Resources

 

Panel
borderColorgrey
bgColorwhite
borderWidth5

Next: The OpenSim API

Previous: Introduction to the OpenSim API

Home: Scripting and Development

...