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
Matlab | C++ |
---|---|
Vec2 | SimTK::Vec<2> |
Vec3 | SimTK::Vec<3> |
Vec4 | SimTK::Vec<4> |
Vec6 | SimTK::Vec<6> |
Mat33 | SimTK::Mat<3, 3> |
SpatialVec | SimTK::Vec<2, SimTK::Vec3> |
Vector | SimTK::Vector_<double> |
VectorVec3 | SimTK::Vector_<SimTK::Vec3> |
RowVector | SimTK::RowVector_<double> |
RowVectorVec3 | SimTK::RowVector_<SimTK::Vec3> |
Matrix | SimTK::Matrix_<double> |
MatrixVec3 | SimTK::Matrix_<SimTK::Vec3> |
MatrixOfSpatialVec | SimTK::Matrix_<SimTK::SpatialVec> |
VectorOfSpatialVec | SimTK::Vector_<SimTK::SpatialVec> |
VectorVec3 | SimTK::Vector_<SimTK::Vec3> |
Rotation | SimTK::Rotation_<double> |
InverseRotation | SimTK::InverseRotation_<double> |
Transform | SimTK::Transform_<double> |
Inertia | SimTK::Inertia_<double> |
MassProperties | SimTK::MassProperties_<double> |
SimTKArrayCoordinateReference | SimTK::Array_<OpenSim::CoordinateReference> |
ArrayDecorativeGeometry | SimTK::Array_<SimTK::DecorativeGeometry> |
SimTKArrayString | SimTK::Array_<std::string> |
SimTKArrayDouble | SimTK::Array_<double> |
SimTKArrayVec3 | SimTK::Array_<SimTK::Vec3> |
SimTKArrayInt | SimTK::Array_<int> |
SimTKArrayMobilizedBodyIndex | SimTK::Array_<MobilizedBodyIndex> |
ArrayXYPoint | OpenSim::Array<XYPoint> |
ArrayBool | OpenSim::Array<bool> |
ArrayDouble | OpenSim::Array<double> |
ArrayInt | OpenSim::Array<int> |
ArrayVec3 | OpenSim::Array<SimTK::Vec3> |
ArrayStr | OpenSim::Array<std::string> |
Types from the C++ Standard Library
StdVectorString | std::vector<std::string> |
StdVectorUnsigned | std::vector<unsigned> |
StdVectorInt | std::vector<int> |
StdVectorDouble | std::vector<double> |
StdVectorVec3 | std::vector<SimTK::Vec3> |
StdVectorMatrix | std::vector<SimTK::Matrix_<double>> |
StdVectorState | std::vector<SimTK::State> |
Sets
SetIKTasks | OpenSim::Set<OpenSim::IKTask> |
SetMarkerPairs | OpenSim::Set<OpenSim::MarkerPair> |
SetMeasurements | OpenSim::Set<OpenSim::Measurement> |
SetTrackingTasks | OpenSim::Set<OpenSim::TrackingTask> |
SetGeometry | OpenSim::Set<OpenSim::DisplayGeometry> |
SetFunctions | OpenSim::Set<OpenSim::Function> |
SetScales | OpenSim::Set<OpenSim::Scale> |
SetModelComponents | OpenSim::Set<OpenSim::ModelComponent> |
ModelComponentSetModelComponent | OpenSim::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
ComponentsList | OpenSim::ComponentList<const OpenSim::Component> |
ComponentListIterator | OpenSim::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
OutputDouble | OpenSim::Output<double> |
OutputVec3 | OpenSim::Output<SimTK::Vec3> |
OutputTransform | OpenSim::Output<SimTK::Transform> |
OutputVector | OpenSim::Output<SimTK::Vector> |
OutputSpatialVec | OpenSim::Output<SimTK::SpatialVec> |
InputDouble | OpenSim::Input<double> |
InputVec3 | OpenSim::Input<SimTK::Vec3> |
DataTables and related classes
DataTable | OpenSim::DataTable_<double, double> |
DataTableVec3 | OpenSim::DataTable_<double, SimTK::Vec3> |
DataTableUnitVec3 | OpenSim::DataTable_<double, SimTK::UnitVec3> |
DataTableQuaternion | OpenSim::DataTable_<double, SimTK::Quaternion> |
DataTableVec6 | OpenSim::DataTable_<double, SimTK::Vec6> |
DataTableSpatialVec | OpenSim::DataTable_<double, SimTK::SpatialVec> |
TimeSeriesTable | OpenSim::TimeSeriesTable_<double> |
TimeSeriesTableVec3 | OpenSim::TimeSeriesTable_<SimTK::Vec3> |
TimeSeriesTableUnitVec3 | OpenSim::TimeSeriesTable_<SimTK::UnitVec3> |
TimeSeriesTableQuaternion | OpenSim::TimeSeriesTable_<SimTK::Quaternion> |
TimeSeriesTableVec6 | OpenSim::TimeSeriesTable_<SimTK::Vec6> |
TimeSeriesTableSpatialVec | OpenSim::TimeSeriesTable_<SimTK::SpatialVec> |
STOFileAdapter | OpenSim::STOFileAdapter_<double> |
STOFileAdapterVec3 | OpenSim::STOFileAdapter_<SimTK::Vec3> |
STOFileAdapterUnitVec3 | OpenSim::STOFileAdapter_<SimTK::UnitVec3> |
STOFileAdapterQuaternion | OpenSim::STOFileAdapter_<SimTK::Quaternion> |
STOFileAdapterVec6 | OpenSim::STOFileAdapter_<SimTK::Vec6> |
STOFileAdapterSpatialVec | OpenSim::STOFileAdapter_<SimTK::SpatialVec> |
TableSource | OpenSim::TableSource_<SimTK::Real> |
TableSourceVec3 | OpenSim::TableSource_<SimTK::Vec3> |
TableReporterDouble | OpenSim::TableReporter<SimTK::Real> |
TableReporterVec3 | OpenSim::TableReporter<SimTK::Vec3> |
TableReporterSpatialVec | OpenSim::TableReporter<SimTK::SpatialVec> |
TableReporterVector | OpenSim::TableReporter<SimTK::Vector> |
ConsoleReporterVec3 | OpenSim::ConsoleReporter<SimTK::Vec3> |
ConsoleReporterSpatialVec | OpenSim::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.