Scripting Versions of OpenSim C++ API Calls

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.Ā Templates are advanced C++ constructs that are used extensively throughout the OpenSim API and Simbody API. If you see notation like Array<double> in theĀ doxygenĀ or C++ code that you are trying to replicate, this means you're working with a templatized class and will need to find its appropriate mapping in the scripting environment.

C++ templates allow the compiler to automatically generate multiple new classes from a common code base. This approach is useful primarily for containers (e.g. Array<double>, Array<int>, Array<string>) since it avoids code duplication making the code easier to maintain; however, these templates exist only in C++ and do not map easily to scripting languages.

One way to work around this is to specialize templates into classes, give those classes unique names, and then use them in scripting. The table below lists template specializations used in OpenSim API (C++) & Doxygen and the corresponding named classes to be used in scripting:


Jump to:



Math types

MatlabC++
Vec2SimTK::Vec<2>
Vec3SimTK::Vec<3>
Vec4SimTK::Vec<4>
Vec6SimTK::Vec<6>
Mat33SimTK::Mat<3, 3>
SpatialVecSimTK::Vec<2, SimTK::Vec3>
VectorSimTK::Vector_<double>
VectorVec3SimTK::Vector_<SimTK::Vec3>
RowVectorSimTK::RowVector_<double>
RowVectorVec3SimTK::RowVector_<SimTK::Vec3>
MatrixSimTK::Matrix_<double>
MatrixVec3SimTK::Matrix_<SimTK::Vec3>
MatrixOfSpatialVecSimTK::Matrix_<SimTK::SpatialVec>
VectorOfSpatialVecSimTK::Vector_<SimTK::SpatialVec>
VectorVec3SimTK::Vector_<SimTK::Vec3>
RotationSimTK::Rotation_<double>
InverseRotationSimTK::InverseRotation_<double>
TransformSimTK::Transform_<double>
InertiaSimTK::Inertia_<double>
MassPropertiesSimTK::MassProperties_<double>
SimTKArrayCoordinateReferenceSimTK::Array_<OpenSim::CoordinateReference>
ArrayDecorativeGeometrySimTK::Array_<SimTK::DecorativeGeometry>
SimTKArrayStringSimTK::Array_<std::string>
SimTKArrayDoubleSimTK::Array_<double>
SimTKArrayVec3SimTK::Array_<SimTK::Vec3>
SimTKArrayIntSimTK::Array_<int>
SimTKArrayMobilizedBodyIndexSimTK::Array_<MobilizedBodyIndex>
ArrayXYPointOpenSim::Array<XYPoint>
ArrayBoolOpenSim::Array<bool>
ArrayDoubleOpenSim::Array<double>
ArrayIntOpenSim::Array<int>
ArrayVec3OpenSim::Array<SimTK::Vec3>
ArrayStrOpenSim::Array<std::string>


Types from the C++ Standard Library

StdVectorStringstd::vector<std::string>
StdVectorUnsignedstd::vector<unsigned>
StdVectorIntstd::vector<int>
StdVectorDoublestd::vector<double>
StdVectorVec3std::vector<SimTK::Vec3>
StdVectorMatrixstd::vector<SimTK::Matrix_<double>>
StdVectorStatestd::vector<SimTK::State>


Sets

SetIKTasksOpenSim::Set<OpenSim::IKTask>
SetMarkerPairsOpenSim::Set<OpenSim::MarkerPair>
SetMeasurementsOpenSim::Set<OpenSim::Measurement>
SetTrackingTasksOpenSim::Set<OpenSim::TrackingTask>
SetGeometryOpenSim::Set<OpenSim::DisplayGeometry>
SetFunctionsOpenSim::Set<OpenSim::Function>
SetScalesOpenSim::Set<OpenSim::Scale>
SetModelComponentsOpenSim::Set<OpenSim::ModelComponent>
ModelComponentSetModelComponentOpenSim::ModelComponentSet<OpenSim::ModelComponent>

SetMuscles

OpenSim::Set<OpenSim::Muscle>

SetWrapObject

OpenSim::Set<OpenSim::WrapObject>

SetFrames

OpenSim::Set<OpenSim::Frame>

ModelComponentSetFrames

OpenSim::ModelComponentSet<OpenSim::Frame>

SetBodies

OpenSim::Set<OpenSim::Body>

ModelComponentSetBodies

OpenSim::ModelComponentSet<OpenSim::Body>

SetBodyScales

OpenSim::Set<OpenSim::BodyScale>

SetCoordinates

OpenSim::Set<OpenSim::Coordinate>

ModelComponentSetCoordinates

OpenSim::ModelComponentSet<OpenSim::Coordinate>

SetJoints

OpenSim::Set<OpenSim::Joint>

ModelComponentSetJoints

OpenSim::ModelComponentSet<OpenSim::Joint>

SetConstraints

OpenSim::Set<OpenSim::Constraint>

ModelComponentSetConstraints

OpenSim::ModelComponentSet<OpenSim::Constraint>

SetForces

OpenSim::Set<OpenSim::Force>

ModelComponentSetForces

OpenSim::ModelComponentSet<OpenSim::Force>

SetExternalForces

OpenSim::Set<OpenSim::ExternalForce>

SetControllers

OpenSim::Set<OpenSim::Controller>

ModelComponentSetControllers

OpenSim::ModelComponentSet<OpenSim::Controller>

ModelComponentSetExternalForces

OpenSim::ModelComponentSet<OpenSim::ExternalForce>

SetContactGeometry

OpenSim::Set<OpenSim::ContactGeometry>

ModelComponentSetContactGeometry

OpenSim::ModelComponentSet<OpenSim::ContactGeometry>

SetActuators

OpenSim::Set<OpenSim::Actuator>

SetAnalysis

OpenSim::Set<OpenSim::Analysis>

SetControls

OpenSim::Set<OpenSim::Control>

SetMarkers

OpenSim::Set<OpenSim::Marker>

ModelComponentSetMarkers

OpenSim::ModelComponentSet<OpenSim::Marker>

SetPathWrap

OpenSim::Set<OpenSim::PathWrap>

SetProbes

OpenSim::Set<OpenSim::Probe>

ModelComponentSetProbes

OpenSim::ModelComponentSet<OpenSim::Probe>

SetPathPoint

OpenSim::Set<OpenSim::AbstractPathPoint>

SetMarkerWeights

Ā OpenSim::Set<MarkerWeight>


ComponentList

ComponentsListOpenSim::ComponentList<const OpenSim::Component>
ComponentListIteratorOpenSim::ComponentListIterator<const OpenSim::Component>

FrameList

OpenSim::ComponentList<const OpenSim::Frame>

FrameIterator

OpenSim::ComponentListIterator<const OpenSim::Frame>

BodyList

OpenSim::ComponentList<const OpenSim::Body>

BodyIterator

OpenSim::ComponentListIterator<const OpenSim::Body>

MuscleList

OpenSim::ComponentList<const OpenSim::Muscle>

MuscleIterator

OpenSim::ComponentListIterator<const OpenSim::Muscle>

ModelComponentList

OpenSim::ComponentList<const OpenSim::ModelComponent>

ModelComponentIterator

OpenSim::ComponentListIterator<const OpenSim::ModelComponent>

JointList

OpenSim::ComponentList<const OpenSim::Joint>

JointIterator

OpenSim::ComponentListIterator<const OpenSim::Joint>

ActuatorList

OpenSim::ComponentList<const OpenSim::Actuator>

ActuatorIterator

OpenSim::ComponentListIterator<const OpenSim::Actuator>

Thelen2003MuscleList

OpenSim::ComponentList<OpenSim::Thelen2003Muscle>

Thelen2003MuscleIterator

OpenSim::ComponentListIterator<const OpenSim::Thelen2003Muscle>

Millard2012EquilibriumMuscleList

OpenSim::ComponentList<OpenSim::Millard2012EquilibriumMuscle>

Millard2012EquilibriumMuscleIterator

OpenSim::ComponentListIterator<const OpenSim::Millard2012EquilibriumMuscle>


Outputs and Inputs

OutputDoubleOpenSim::Output<double>
OutputVec3OpenSim::Output<SimTK::Vec3>
OutputTransformOpenSim::Output<SimTK::Transform>
OutputVectorOpenSim::Output<SimTK::Vector>
OutputSpatialVecOpenSim::Output<SimTK::SpatialVec>
InputDoubleOpenSim::Input<double>
InputVec3OpenSim::Input<SimTK::Vec3>


DataTables and related classes

DataTableOpenSim::DataTable_<double, double>
DataTableVec3OpenSim::DataTable_<double, SimTK::Vec3>
DataTableUnitVec3OpenSim::DataTable_<double, SimTK::UnitVec3>
DataTableQuaternionOpenSim::DataTable_<double, SimTK::Quaternion>
DataTableVec6OpenSim::DataTable_<double, SimTK::Vec6>
DataTableSpatialVecOpenSim::DataTable_<double, SimTK::SpatialVec>
TimeSeriesTableOpenSim::TimeSeriesTable_<double>
TimeSeriesTableVec3OpenSim::TimeSeriesTable_<SimTK::Vec3>
TimeSeriesTableUnitVec3OpenSim::TimeSeriesTable_<SimTK::UnitVec3>
TimeSeriesTableQuaternionOpenSim::TimeSeriesTable_<SimTK::Quaternion>
TimeSeriesTableVec6OpenSim::TimeSeriesTable_<SimTK::Vec6>
TimeSeriesTableSpatialVecOpenSim::TimeSeriesTable_<SimTK::SpatialVec>
STOFileAdapterOpenSim::STOFileAdapter_<double>
STOFileAdapterVec3OpenSim::STOFileAdapter_<SimTK::Vec3>
STOFileAdapterUnitVec3OpenSim::STOFileAdapter_<SimTK::UnitVec3>
STOFileAdapterQuaternionOpenSim::STOFileAdapter_<SimTK::Quaternion>
STOFileAdapterVec6OpenSim::STOFileAdapter_<SimTK::Vec6>
STOFileAdapterSpatialVecOpenSim::STOFileAdapter_<SimTK::SpatialVec>
TableSourceOpenSim::TableSource_<SimTK::Real>
TableSourceVec3OpenSim::TableSource_<SimTK::Vec3>
TableReporterDoubleOpenSim::TableReporter<SimTK::Real>
TableReporterVec3OpenSim::TableReporter<SimTK::Vec3>
TableReporterSpatialVecOpenSim::TableReporter<SimTK::SpatialVec>
TableReporterVectorOpenSim::TableReporter<SimTK::Vector>
ConsoleReporterVec3OpenSim::ConsoleReporter<SimTK::Vec3>
ConsoleReporterSpatialVecOpenSim::ConsoleReporter<SimTK::SpatialVec>

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.