|
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
|
This goal minimizes the sum of muscle activations to a specified power, optionally allowing custom weights for specific muscles. More...
#include <MocoActivationGoal.h>

Public Member Functions | |
| MocoActivationGoal () | |
| Default constructor. | |
| MocoActivationGoal (std::string name) | |
| Constructor with name. | |
| MocoActivationGoal (std::string name, double weight) | |
| Constructor with name and weight. | |
| 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. | |
| void | setExponent (int ex) |
| Set the exponent applied to activation values. | |
| bool | getExponent () const |
| Get the current exponent value. | |
| void | setCustomWeightNames (const std::vector< std::string > refCoordNames) |
| Set the names of states to apply custom weights to. | |
| void | setCustomWeightValues (const std::vector< double > refWeights) |
| Set the custom weight values corresponding to the custom state names. | |
| void | setDivideByDisplacement (bool tf) |
| Set whether to divide the sum of 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 | |
| MocoActivationGoal () | |
| Default constructor. | |
| MocoActivationGoal (std::string name) | |
| Constructor with name. | |
| MocoActivationGoal (std::string name, double weight) | |
| Constructor with name and weight. | |
Protected Member Functions | |
| Mode | getDefaultModeImpl () const override |
| bool | getSupportsEndpointConstraintImpl () const override |
| void | initializeOnModelImpl (const Model &) const override |
| void | calcIntegrandImpl (const IntegrandInput &input, double &integrand) const override |
| void | calcGoalImpl (const GoalInput &input, SimTK::Vector &cost) const override |
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. | |
Private Member Functions | |
| OpenSim_DECLARE_CONCRETE_OBJECT (MocoActivationGoal, MocoGoal) | |
| 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)") | |
| void | constructProperties () |
| OpenSim_DECLARE_CONCRETE_OBJECT (MocoActivationGoal, MocoGoal) | |
| void | constructProperties () |
| Initialize the goal's properties. | |
Properties | |
| 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 | |
| std::vector< std::string > | m_state_names |
| std::vector< double > | m_custom_weights |
| std::vector< double > | m_custom_weights_input |
| std::vector< std::string > | m_custom_state_names |
| std::vector< int > | m_custom_act_indices |
Internal working variables | |
| std::vector< int > | m_act_indices |
| Indices of activation states in the model. | |
| std::function< double(const double &)> | m_power_function |
This goal minimizes the sum of muscle activations to a specified power, optionally allowing custom weights for specific muscles.
Goal that minimizes muscle activation effort in a Moco optimization problem.
The integrand is:
![\[
\sum_i w_i |a_i|^p
\]](form_0.png)
where 


This goal minimizes the sum of muscle activation values raised to a power, integrated over the phase. The integrand is:
![\[
\sum_i |a_i|^p
\]](form_15.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 |
|
overrideprotected |
Calculate the goal value.
| input | Input data containing the integral |
| cost | Vector to store the calculated cost |
|
overrideprotected |
|
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 |
|
private |
Initialize the goal's properties.
|
inlineoverrideprotected |
|
inlineoverrideprotected |
Get the default mode for this goal.
|
inline |
Get whether the sum is divided by displacement.
|
inline |
Get the endpoint constraint target value.
|
inline |
Get the endpoint constraint target value.
|
inline |
Get the current exponent value.
|
inlineoverrideprotected |
|
inlineoverrideprotected |
Whether this goal supports endpoint constraint mode.
|
overrideprotected |
|
overrideprotected |
Initialize the goal with the model.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
Set the names of states to apply custom weights to.
| refCoordNames | Vector of state names |
|
inline |
Set the custom weight values corresponding to the custom state names.
| refWeights | Vector of weights matching the order of custom state names |
|
inline |
Set whether to divide the sum of activations by displacement.
| tf | True to divide by displacement, false otherwise |

|
inline |
Set the target value when using this goal as an endpoint constraint.
| end_point_goal | The target value (default: 0) |
|
inline |
Set the target value when using this goal as an endpoint constraint.
| end_point_goal | The target value (default: 0) |
|
inline |
Set the exponent applied to activation values.
| ex | The exponent value. For ex > 1, absolute value is applied first |
|
mutableprivate |
Indices of activation states in the model.
|
mutableprivate |
|
mutableprivate |
|
mutableprivate |
|
mutableprivate |
|
mutableprivate |
Function to compute power of activation values
|
mutableprivate |