API  4.3
For MATLAB, Python, Java, and C++ users
OpenSim::ModelFactory Class Reference

This class provides utilities for creating OpenSim models. More...

Static Public Member Functions

Create a model
static Model createNLinkPendulum (int numLinks)
 Create a pendulum with the provided number of links. More...
 
static Model createPendulum ()
 This is a convenience for createNLinkPendulum(1). More...
 
static Model createDoublePendulum ()
 This is a convenience for createNLinkPendulum(2). More...
 
static Model createSlidingPointMass ()
 This model contains: More...
 
static Model createPlanarPointMass ()
 This model contains: More...
 
Modify a Model
static void replaceMusclesWithPathActuators (Model &model)
 Replace muscles in a model with a PathActuator of the same GeometryPath, optimal force, and min/max control defaults. More...
 
static void removeMuscles (Model &model)
 Remove muscles from the model. More...
 
static void replaceJointWithWeldJoint (Model &model, const std::string &jointName)
 Replace a joint in the model with a WeldJoint. More...
 
static void createReserveActuators (Model &model, double optimalForce, double bound=SimTK::NaN, bool skipCoordinatesWithExistingActuators=true)
 Add CoordinateActuators for each unconstrained coordinate (e.g., ! Coordinate::isConstrained()) in the model, using the provided optimal force. More...
 

Detailed Description

This class provides utilities for creating OpenSim models.

Member Function Documentation

◆ createDoublePendulum()

static Model OpenSim::ModelFactory::createDoublePendulum ( )
inlinestatic

This is a convenience for createNLinkPendulum(2).

◆ createNLinkPendulum()

static Model OpenSim::ModelFactory::createNLinkPendulum ( int  numLinks)
static

Create a pendulum with the provided number of links.

For each link, there is a body /bodyset/b# (where # is the link index starting at 0), a PinJoint /jointset/j# with coordinate /jointset/j#/q#, a CoordinateActuator /tau#, a Marker /markerset/marker# at the origin of the link's body, and a PhysicalOffsetFrame /b#center at the center of the link.

◆ createPendulum()

static Model OpenSim::ModelFactory::createPendulum ( )
inlinestatic

This is a convenience for createNLinkPendulum(1).

◆ createPlanarPointMass()

static Model OpenSim::ModelFactory::createPlanarPointMass ( )
static

This model contains:

  • 2 bodies: a massless body "intermed", and "body" with mass 1.
  • 2 slider joints: "tx" and "ty" (coordinates "tx" and "ty").
  • 2 coordinate actuators: "force_x" and "force_y". Gravity is default; that is, (0, -g, 0).

◆ createReserveActuators()

static void OpenSim::ModelFactory::createReserveActuators ( Model model,
double  optimalForce,
double  bound = SimTK::NaN,
bool  skipCoordinatesWithExistingActuators = true 
)
static

Add CoordinateActuators for each unconstrained coordinate (e.g., ! Coordinate::isConstrained()) in the model, using the provided optimal force.

Increasing the optimal force decreases the required control signal to generate a given actuation level. The actuators are added to the model's ForceSet and are named "reserve_<coordinate-path>" with forward slashes converted to underscores. The bound argument, if supplied, sets the min and max controls to -bound and bound, respectively. The fourth (optional) argument specifies whether or not to skip coordinates that already have CoordinateActuators associated with them (default: true).

Referenced by OpenSim::ModOpAddReserves::operate().

◆ createSlidingPointMass()

static Model OpenSim::ModelFactory::createSlidingPointMass ( )
static

This model contains:

  • 1 body: mass 1.0 kg, /bodyset/body.
  • 1 joint: SliderJoint along x axis, /jointset/slider, with coordinate /jointset/slider/position.
  • 1 actuator: CoordinateActuator, controls [-10, 10], /actuator. Gravity is default; that is, (0, -g, 0).

◆ removeMuscles()

static void OpenSim::ModelFactory::removeMuscles ( Model model)
static

Remove muscles from the model.

Note
This only removes muscles within the model's ForceSet.

Referenced by OpenSim::ModOpRemoveMuscles::operate().

◆ replaceJointWithWeldJoint()

static void OpenSim::ModelFactory::replaceJointWithWeldJoint ( Model model,
const std::string &  jointName 
)
static

Replace a joint in the model with a WeldJoint.

Note
This assumes the joint is in the JointSet and that the joint's connectees are PhysicalOffsetFrames.

Referenced by OpenSim::ModOpReplaceJointsWithWelds::operate().

◆ replaceMusclesWithPathActuators()

static void OpenSim::ModelFactory::replaceMusclesWithPathActuators ( Model model)
static

Replace muscles in a model with a PathActuator of the same GeometryPath, optimal force, and min/max control defaults.

Note
This only replaces muscles within the model's ForceSet.

The documentation for this class was generated from the following file: