OpenSim Moco  0.4.0
Public Member Functions | Protected Member Functions | List of all members
OpenSim::MocoAngularVelocityTrackingGoal Class Reference

Description

The squared difference between a model frame's angular velocity and a reference angular velocity value, summed over the frames for which a reference is provided, and integrated over the phase.

This can be used to track angular velocity quantities in the model that don't correspond to model degrees of freedom. The reference can be provided as a trajectory of SimTK::Vec3s representing the angular velocity reference data, or as a states trajectory from which the tracked angular velocity reference is computed. Both angular velocity and states references can be provided as a file name to a STO or CSV file (or other file types for which there is a FileAdapter), or programmatically as a TimeSeriesTableVec3 (for the angular velocity reference) or as a scalar TimeSeriesTable (for the states reference).

Errors for this cost are computed assuming that the provided reference angular velocity data is expressed in the ground frame. If you are using this cost to track raw signals from an inertial measurement unit (IMU), make sure that the frame you're tracking produces angular velocity values that correspond to the real-world placement of your IMU.

This cost requires realization to SimTK::Stage::Velocity.

Inheritance diagram for OpenSim::MocoAngularVelocityTrackingGoal:
OpenSim::MocoGoal

#include <Moco/Moco/MocoGoal/MocoAngularVelocityTrackingGoal.h>

Public Member Functions

 MocoAngularVelocityTrackingGoal (std::string name)
 
 MocoAngularVelocityTrackingGoal (std::string name, double weight)
 
void setAngularVelocityReferenceFile (const std::string &filepath)
 Set directly the angular velocities of individual frames in ground to be tracked in the cost. More...
 
void setAngularVelocityReference (const TimeSeriesTableVec3 &ref)
 Each column label must be the path of a valid frame path (see setAngularVelocityReferenceFile()). More...
 
void setStatesReference (const TableProcessor &ref)
 Provide a table containing values of model state variables. More...
 
void setFramePaths (const std::vector< std::string > &paths)
 Set the paths to frames in the model that this cost term will track. More...
 
void setWeightForFrame (const std::string &frameName, const double &weight)
 Set the weight for an individual frame's angular velocity tracking. More...
 
void setWeightSet (const MocoWeightSet &weightSet)
 Provide a MocoWeightSet to weight frame angular velocity tracking in the cost. More...
 
const TableProcessorgetStatesReference () const
 If no states reference has been provided, this returns an empty processor. More...
 
std::string getAngularVelocityReferenceFile () const
 If no angular velocity reference file has been provided, this returns an empty string. More...
 
- Public Member Functions inherited from OpenSim::MocoGoal
 MocoGoal (std::string name)
 
 MocoGoal (std::string name, double weight)
 
void setEnabled (bool enabled)
 Set whether this goal is used in the problem.
 
bool getEnabled () const
 
void setWeight (double weight)
 In cost mode, the goal is multiplied by this weight. More...
 
double getWeight () const
 
void setMode (std::string mode)
 Set the mode property to either 'cost' or 'endpoint_constraint'. More...
 
std::string getModeAsString () const
 This returns the default mode of the goal, unless the user overrode the default using setMode(). More...
 
Mode getMode () const
 
bool getModeIsCost () const
 
bool getModeIsEndpointConstraint () const
 
Mode getDefaultMode () const
 Types of goals have a class-level default for whether they are enforced as a cost or endpoint constraint. More...
 
bool getSupportsEndpointConstraint () const
 Can this constraint be used in endpoint constraint mode?
 
const MocoConstraintInfogetConstraintInfo () const
 Get bounds for the constraints when using this goal in endpoint constraint mode. More...
 
MocoConstraintInfoupdConstraintInfo ()
 
int getNumOutputs () const
 Get the length of the return value of calcGoal().
 
int getNumIntegrals () const
 Get the number of integrals required by this cost. More...
 
SimTK::Real calcIntegrand (const SimTK::State &state) const
 Calculate the integrand that should be integrated and passed to calcCost(). More...
 
void calcGoal (const GoalInput &input, SimTK::Vector &goal) const
 In cost mode, the returned cost includes the weight, and the elements of the returned vector should be summed by the caller to obtain the total cost. More...
 
void initializeOnModel (const Model &model) const
 For use by solvers. This also performs error checks on the Problem.
 
void printDescription (std::ostream &stream=std::cout) const
 Print the name type and mode of this goal. More...
 

Protected Member Functions

void initializeOnModelImpl (const Model &model) const override
 Perform any caching before the problem is solved. More...
 
void calcIntegrandImpl (const SimTK::State &state, double &integrand) const override
 
void calcGoalImpl (const GoalInput &input, SimTK::Vector &cost) const override
 The Lagrange multipliers for kinematic constraints are not available.
 
void printDescriptionImpl (std::ostream &stream=std::cout) const override
 Print a more detailed description unique to each goal.
 
- Protected Member Functions inherited from OpenSim::MocoGoal
void setNumIntegralsAndOutputs (int numIntegrals, int numOutputs) const
 Set the number of integral terms required by this goal and the length of the vector passed into calcGoalImpl(). More...
 
virtual Mode getDefaultModeImpl () const
 
virtual bool getSupportsEndpointConstraintImpl () const
 
const Model & getModel () const
 For use within virtual function implementations.
 
double calcSystemDisplacement (const SimTK::State &initial, const SimTK::State &final) const
 

Additional Inherited Members

- Public Types inherited from OpenSim::MocoGoal
enum  Mode { Cost, EndpointConstraint }
 

Member Function Documentation

◆ calcIntegrandImpl()

void OpenSim::MocoAngularVelocityTrackingGoal::calcIntegrandImpl ( const SimTK::State &  state,
double &  integrand 
) const
overrideprotectedvirtual
Precondition(s):
The state is realized to SimTK::Stage::Position. If you need access to the controls, you must realize to Velocity:
getModel().realizeVelocity(state);
The Lagrange multipliers for kinematic constraints are not available.

Reimplemented from OpenSim::MocoGoal.

◆ getAngularVelocityReferenceFile()

std::string OpenSim::MocoAngularVelocityTrackingGoal::getAngularVelocityReferenceFile ( ) const
inline

If no angular velocity reference file has been provided, this returns an empty string.

◆ getStatesReference()

const TableProcessor& OpenSim::MocoAngularVelocityTrackingGoal::getStatesReference ( ) const
inline

If no states reference has been provided, this returns an empty processor.

◆ initializeOnModelImpl()

void OpenSim::MocoAngularVelocityTrackingGoal::initializeOnModelImpl ( const Model &  ) const
overrideprotectedvirtual

Perform any caching before the problem is solved.

You must override this function and invoke setNumIntegralsAndOutputs().

Precondition(s):
The model is initialized (initSystem()) and getModel() is available. The passed-in model is equivalent to getModel(). Use this opportunity to check for errors in user input.

Implements OpenSim::MocoGoal.

◆ setAngularVelocityReference()

void OpenSim::MocoAngularVelocityTrackingGoal::setAngularVelocityReference ( const TimeSeriesTableVec3 &  ref)
inline

Each column label must be the path of a valid frame path (see setAngularVelocityReferenceFile()).

Calling this function clears the states_reference_file and angular_velocity_reference_file properties or the table provided via setStatesReference(), if any.

◆ setAngularVelocityReferenceFile()

void OpenSim::MocoAngularVelocityTrackingGoal::setAngularVelocityReferenceFile ( const std::string &  filepath)
inline

Set directly the angular velocities of individual frames in ground to be tracked in the cost.

The column labels of the provided reference must be paths to frames in the model, e.g. /bodyset/torso. If the frame_paths property is empty, all frames with data in this reference will be tracked. Otherwise, only the frames specified via setFramePaths() will be tracked. Calling this function clears the values provided via setStatesReference(), setAngularVelocityReference(), or the states_reference_file property, if any.

◆ setFramePaths()

void OpenSim::MocoAngularVelocityTrackingGoal::setFramePaths ( const std::vector< std::string > &  paths)
inline

Set the paths to frames in the model that this cost term will track.

The names set here must correspond to OpenSim::Components that derive from OpenSim::Frame, which includes 'angular_velocity' (SimTK::Vec3) as an output. Replaces the frame path set if it already exists.

◆ setStatesReference()

void OpenSim::MocoAngularVelocityTrackingGoal::setStatesReference ( const TableProcessor ref)
inline

Provide a table containing values of model state variables.

These data are used to create a StatesTrajectory internally, from which the angular velocity data for the frames specified in setFramePaths() are computed. Each column label in the reference must be the path of a state variable, e.g., /jointset/ankle_angle_r/value. Calling this function clears the table provided via setAngularVelocityReference(), or the angular_velocity_reference_file property, if any. The table is not loaded until the MocoProblem is initialized.

◆ setWeightForFrame()

void OpenSim::MocoAngularVelocityTrackingGoal::setWeightForFrame ( const std::string &  frameName,
const double &  weight 
)
inline

Set the weight for an individual frame's angular velocity tracking.

If a weight is already set for the requested frame, then the provided weight replaces the previous weight. An exception is thrown if a weight for an unknown frame is provided.

◆ setWeightSet()

void OpenSim::MocoAngularVelocityTrackingGoal::setWeightSet ( const MocoWeightSet weightSet)
inline

Provide a MocoWeightSet to weight frame angular velocity tracking in the cost.

Replaces the weight set if it already exists.


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