|
MocoExtendProblem: Interface Between OpenSim and MATLAB for Rapidly Developing Direct Collocation Goals in Moco 1.1.0
add custom Moco goals to existing matlab scripts
|
Goal that minimizes a custom model output. More...
#include <MocoCustomOutputGoal.h>

Public Member Functions | |
| void | setOutputPath (std::string path) |
| Set the absolute path to the output to minimize. | |
| const std::string & | getOutputPath () const |
| Get the output path. | |
| void | setExponent (int exponent) |
| Set the exponent for the output value. | |
| int | getExponent () const |
| Get the current exponent value. | |
| void | setOutputIndex (int index) |
| Set the index for vector outputs. | |
| int | getOutputIndex () const |
| Get the output index. | |
| void | setDivideByDisplacement (bool tf) |
| Set whether to divide by displacement. | |
| bool | getDivideByDisplacement () const |
| Get whether the goal is divided by displacement. | |
| void | setDivideByMass (bool mass) |
| Set whether to divide by model mass. | |
| bool | getDivideByMass () const |
| Get whether the goal is divided by mass. | |
Constructors | |
| MocoCustomOutputGoal () | |
| Default constructor. | |
| MocoCustomOutputGoal (std::string name) | |
| Constructor with name. | |
| MocoCustomOutputGoal (std::string name, double weight) | |
| Constructor with name and weight. | |
Protected Member Functions | |
Required implementations of virtual methods | |
| void | initializeOnModelBase () const |
| Initialize the goal on the base model. | |
| double | calcOutputValue (const SimTK::State &) const |
| Calculate the output value for the current state. | |
| double | setValueToExponent (double value) const |
| Apply the exponent to a value. | |
| const SimTK::Stage & | getDependsOnStage () const |
| Get the stage that this goal depends on. | |
| void | initializeOnModelImpl (const Model &) const override |
| Initialize the goal with the model. | |
| void | calcIntegrandImpl (const IntegrandInput &state, double &integrand) const override |
| Calculate the integrand value for the cost function. | |
| void | calcGoalImpl (const GoalInput &input, SimTK::Vector &values) const override |
| Calculate the goal value. | |
| bool | getSupportsEndpointConstraintImpl () const override |
| Whether this goal supports endpoint constraint mode. | |
| Mode | getDefaultModeImpl () const override |
| Get the default mode for this goal. | |
Private Types | |
Data type enumeration | |
| enum | DataType { Type_double , Type_Vec3 , Type_SpatialVec } |
| Enumeration of possible output data types. More... | |
Private Member Functions | |
| OpenSim_DECLARE_CONCRETE_OBJECT (MocoCustomOutputGoal, MocoGoal) | |
| void | constructProperties () |
| Initialize the goal's properties. | |
Properties | |
| OpenSim_DECLARE_PROPERTY (output_path, std::string, "The absolute path to the output in the model to use as the " "integrand for this goal.") | |
| OpenSim_DECLARE_PROPERTY (exponent, int, "The exponent applied to the output value in the integrand. " "The output can take on negative values in the integrand when the " "exponent is set to 1 (the default value). When the exponent is " "set to a value greater than 1, the absolute value function is " "applied to the output (before the exponent is applied), meaning " "that odd numbered exponents (greater than 1) do not take on " "negative values.") | |
| OpenSim_DECLARE_PROPERTY (output_index, int, "The index to the value to be minimized when a vector type " "Output is specified. For SpatialVec Outputs, indices 0, 1, " "and 2 refer to the rotational components and indices 3, 4, " "and 5 refer to the translational components. A value of -1 " "indicates to minimize the vector norm (default: -1).") | |
| OpenSim_DECLARE_PROPERTY (divide_by_displacement, bool, "Divide by the model's displacement over the phase (default: " "false)") | |
| OpenSim_DECLARE_PROPERTY (divide_by_mass, bool, "Divide by the model's total mass (default: false)") | |
Private Attributes | |
Internal working variables | |
| DataType | m_data_type |
| SimTK::ReferencePtr< const AbstractOutput > | m_output |
| Reference to the output being minimized. | |
| std::function< double(const double &)> | m_power_function |
| Function to compute power of values. | |
| int | m_index1 |
| First index for vector components. | |
| int | m_index2 |
| Second index for vector components. | |
| bool | m_minimizeVectorNorm |
| Whether to minimize vector norm. | |
| SimTK::Stage | m_dependsOnStage = SimTK::Stage::Acceleration |
| Stage at which the goal depends on the model. | |
Goal that minimizes a custom model output.
This goal minimizes any model output that can be specified by its absolute path, integrated over the phase. The output can be a scalar value, a component of a vector output, or the norm of a vector output.
For vector outputs (including SpatialVec), you can either:
For SpatialVec outputs:
This goal can be useful for:
The goal value can optionally be:
|
private |
|
inline |
Default constructor.
|
inline |
Constructor with name.
| name | The name of the goal |
|
inline |
Constructor with name and weight.
| name | The name of the goal |
| weight | Weight for this goal term in the optimization |
|
overrideprotected |
Calculate the goal value.
| input | Input data containing the integral |
| values | Vector to store the calculated values |
|
overrideprotected |
Calculate the integrand value for the cost function.
| state | Input data for the current state |
| integrand | Reference to store the calculated integrand value |

|
protected |
Calculate the output value for the current state.
| state | The current state |

|
private |
Initialize the goal's properties.
|
inlineoverrideprotected |
Get the default mode for this goal.
|
protected |
Get the stage that this goal depends on.

|
inline |
Get whether the goal is divided by displacement.
|
inline |
Get whether the goal is divided by mass.
|
inline |
Get the current exponent value.
|
inline |
Get the output index.
|
inline |
Get the output path.
|
inlineoverrideprotected |
Whether this goal supports endpoint constraint mode.
|
protected |
Initialize the goal on the base model.

|
overrideprotected |
Initialize the goal with the model.

|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
Set whether to divide by displacement.
| tf | True to divide by displacement, false otherwise |
|
inline |
Set whether to divide by model mass.
| mass | True to divide by mass, false otherwise |
|
inline |
Set the exponent for the output value.
| exponent | The exponent value |
|
inline |
Set the index for vector outputs.
| index | The index to minimize (-1 for vector norm) |
|
inline |
Set the absolute path to the output to minimize.
| path | The output path in the model |
|
protected |
Apply the exponent to a value.
| value | The value to modify |

|
mutableprivate |
Type of data being processed
|
mutableprivate |
Stage at which the goal depends on the model.
|
mutableprivate |
First index for vector components.
|
mutableprivate |
Second index for vector components.
|
mutableprivate |
Whether to minimize vector norm.
|
mutableprivate |
Reference to the output being minimized.
|
mutableprivate |
Function to compute power of values.