|
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 the squared sum of muscle activations. More...
#include <MocoActivationSquaredGoal.h>

Public Member Functions | |
| void | setEndPointGoal (double end_point_goal) |
| Set the target value for endpoint goal evaluation. | |
| double | getEndPointGoal () const |
| Get the endpoint goal target value. | |
| void | setDivideByDisplacement (bool tf) |
| Set whether to divide the sum of squared activations by displacement. | |
| bool | getDivideByDisplacement () const |
| Get whether the sum is divided by displacement. | |
| void | setEndPointGoal (double end_point_goal) |
| Set the target value when using this goal as an endpoint constraint. | |
| double | getEndPointGoal () const |
| Get the endpoint constraint target value. | |
Constructors | |
| MocoActivationSquaredGoal () | |
| Default constructor. | |
| MocoActivationSquaredGoal (std::string name) | |
| Constructor with name. | |
| MocoActivationSquaredGoal (std::string name, double weight) | |
| Constructor with name and weight. | |
| MocoActivationSquaredGoal () | |
| Default constructor. | |
| MocoActivationSquaredGoal (std::string name) | |
| Constructor with name. | |
| MocoActivationSquaredGoal (std::string name, double weight) | |
| Constructor with name and weight. | |
Protected Member Functions | |
Required implementations of virtual methods | |
| Mode | getDefaultModeImpl () const override |
| Get the default mode for this goal. | |
| bool | getSupportsEndpointConstraintImpl () const override |
| Whether this goal supports endpoint constraint mode. | |
| void | initializeOnModelImpl (const Model &) const override |
| Initialize the goal with the model. | |
| void | calcIntegrandImpl (const IntegrandInput &input, double &integrand) const override |
| Calculate the integrand value for the cost function. | |
| void | calcGoalImpl (const GoalInput &input, SimTK::Vector &cost) const override |
| Calculate the goal value. | |
| Mode | getDefaultModeImpl () const override |
| Get the default mode for this goal. | |
| bool | getSupportsEndpointConstraintImpl () const override |
| Whether this goal supports endpoint constraint mode. | |
| void | initializeOnModelImpl (const Model &) const override |
| Initialize the goal with the model. | |
| void | calcIntegrandImpl (const IntegrandInput &input, double &integrand) const override |
| Calculate the integrand value for the cost function. | |
| void | calcGoalImpl (const GoalInput &input, SimTK::Vector &cost) const override |
| Calculate the goal value. | |
Private Member Functions | |
| OpenSim_DECLARE_CONCRETE_OBJECT (MocoActivationSquaredGoal, MocoGoal) | |
| void | constructProperties () |
| Initialize the goal's properties. | |
| OpenSim_DECLARE_CONCRETE_OBJECT (MocoActivationSquaredGoal, MocoGoal) | |
| void | constructProperties () |
| Initialize the goal's properties. | |
Properties | |
| 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 (end_point_goal, double, "Target value for end-point goal (default: 0)") | |
| OpenSim_DECLARE_PROPERTY (divide_by_displacement, bool, "Divide by the model's displacement over the phase (default: " "false)") | |
| 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 (end_point_goal, double, "Target value for end-point goal (default: 0)") | |
Private Attributes | |
Internal working variables | |
| std::vector< int > | m_act_indices |
| Indices of activation states in the model. | |
| std::function< double(const double &)> | m_power_function |
| Function to compute power of activation values. | |
Goal that minimizes the squared sum of muscle activations.
This goal minimizes the sum of squared muscle activations, integrated over the phase. It is equivalent to using MocoActivationGoal with exponent=2. The squared activation cost is commonly used as a proxy for metabolic cost and effort minimization.
This goal can be useful for:
The goal can optionally be configured as an endpoint goal, where the squared activations are evaluated only at the final time point instead of being integrated over the phase.
This goal minimizes the sum of squared muscle activation values, integrated over the phase. The integrand is:
![\[
\sum_i a_i^2
\]](form_16.png)
where 
This goal can be useful for:
The goal can optionally be divided by the total displacement of the model during the phase to make the cost invariant to the distance traveled.
|
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 |
|
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 |
| cost | Vector to store the calculated cost |
|
overrideprotected |
Calculate the goal value.
| input | Input data containing the integral |
| cost | Vector to store the calculated cost |
|
overrideprotected |
Calculate the integrand value for the cost function.
| input | Input data for the current state |
| integrand | Reference to store the calculated integrand value |
|
overrideprotected |
Calculate the integrand value for the cost function.
| input | Input data for the current state |
| integrand | Reference to store the calculated integrand value |
|
private |
Initialize the goal's properties.
|
private |
Initialize the goal's properties.
|
inlineoverrideprotected |
Get the default mode for this goal.
|
inlineoverrideprotected |
Get the default mode for this goal.
|
inline |
Get whether the sum is divided by displacement.
|
inline |
Get the endpoint goal target value.
|
inline |
Get the endpoint constraint target value.
|
inlineoverrideprotected |
Whether this goal supports endpoint constraint mode.
|
inlineoverrideprotected |
Whether this goal supports endpoint constraint mode.
|
overrideprotected |
Initialize the goal with the model.
|
overrideprotected |
Initialize the goal with the model.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
Set whether to divide the sum of squared activations by displacement.
| tf | True to divide by displacement, false otherwise |

|
inline |
Set the target value for endpoint goal evaluation.
| end_point_goal | Target value when used as endpoint goal |
|
inline |
Set the target value when using this goal as an endpoint constraint.
| end_point_goal | The target value (default: 0) |
|
mutableprivate |
Indices of activation states in the model.
Indices of muscle activation states
|
mutableprivate |
Function to compute power of activation values.
Function to compute power of activation values