|
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 distance between the body's center of mass projection and the center of the base of support defined by the foot frames. More...
#include <MocoBOSGoal.h>

Public Member Functions | |
| MocoBOSGoal () | |
| Default constructor. | |
| MocoBOSGoal (std::string name) | |
| Constructor with name. | |
| MocoBOSGoal (std::string name, double weight) | |
| Constructor with name and weight. | |
| void | setExponent (int ex) |
| Set the exponent applied to the distance measure. | |
| bool | getExponent () const |
| Get the current exponent value. | |
| void | setLeftFootFrame (std::string left_foot) |
| Set the frame associated with the left foot. | |
| std::string | getLeftFootFrame () const |
| Get the name of the left foot frame. | |
| void | setRightFootFrame (std::string right_foot) |
| Set the frame associated with the right foot. | |
| std::string | getRightFootFrame () const |
| Get the name of the right foot frame. | |
| void | setExponent (int ex) |
| Set the exponent for the deviation term. | |
| bool | getExponent () const |
| Get the current exponent value. | |
| void | setDivideByDisplacement (bool tf) |
| Set whether to divide by displacement. | |
| bool | getDivideByDisplacement () const |
| Get whether the goal is divided by displacement. | |
| void | setLeftFootFrame (std::string left_foot) |
| Set the body frame for the left foot. | |
| std::string | getLeftFootFrame () const |
| Get the name of the left foot frame. | |
| void | setRightFootFrame (std::string right_foot) |
| Set the body frame for the right foot. | |
| std::string | getRightFootFrame () const |
| Get the name of the right foot frame. | |
Constructors | |
| MocoBOSGoal () | |
| Default constructor. | |
| MocoBOSGoal (std::string name) | |
| Constructor with name. | |
| MocoBOSGoal (std::string name, double weight) | |
| Constructor with name and weight. | |
Protected Member Functions | |
| SimTK::Vec3 | avg (const SimTK::Vec3 &a, const SimTK::Vec3 &b) const |
| Calculate the average of two 3D vectors. | |
| SimTK::Matrix | FlattenSpatialVec (const SimTK::SpatialVec &S) const |
| Convert a spatial vector to a matrix representation. | |
Required implementations of virtual methods | |
| 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 |
| 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. | |
| SimTK::Vec3 | avg (const SimTK::Vec3 &a, const SimTK::Vec3 &b) const |
| Calculate the average of two 3D vectors. | |
| SimTK::Matrix | FlattenSpatialVec (const SimTK::SpatialVec &S) const |
| Convert a spatial vector to a matrix representation. | |
Private Member Functions | |
| OpenSim_DECLARE_CONCRETE_OBJECT (MocoBOSGoal, 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 (left_foot_frame, std::string, "The model frame associated with the left foot.") | |
| OpenSim_DECLARE_PROPERTY (right_foot_frame, std::string, "The model frame associated with the right foot.") | |
| void | constructProperties () |
| OpenSim_DECLARE_CONCRETE_OBJECT (MocoBOSGoal, 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 (left_foot_frame, std::string, "The model frame associated with the left foot.") | |
| OpenSim_DECLARE_PROPERTY (right_foot_frame, std::string, "The model frame associated with the right foot.") | |
Private Attributes | |
Internal working variables | |
| std::vector< std::string > | m_force_names |
| SimTK::ReferencePtr< const Body > | m_left_foot_frame |
| Reference to the left foot frame. | |
| SimTK::ReferencePtr< const Body > | m_right_foot_frame |
| Reference to the right foot frame. | |
| std::function< double(const double &)> | m_power_function |
| Function to compute power of values. | |
This goal minimizes the distance between the body's center of mass projection and the center of the base of support defined by the foot frames.
Goal that minimizes the deviation of the base of support (BOS) from a target.
The goal helps maintain balance during movement optimization.
The base of support is calculated using the specified left and right foot frames. The goal can be weighted and the distance measure can be modified using an exponent parameter.
This goal minimizes the deviation of the model's base of support from a desired target location, integrated over the phase. The base of support is calculated using the contact forces and center of pressure between the feet and the ground.
This goal can be useful for:
The goal requires specification of frames for both feet to properly calculate the base of support. The deviation 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 |
|
protected |
Calculate the average of two 3D vectors.
| a | First vector |
| b | Second vector |

|
protected |
Calculate the average of two 3D vectors.
| a | First vector |
| b | Second vector |
|
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.
|
protected |
Convert a spatial vector to a matrix representation.
| S | Spatial vector to flatten |
|
protected |
Convert a spatial vector to a matrix representation.
| S | Spatial vector to flatten |
|
inlineoverrideprotected |
|
inlineoverrideprotected |
Get the default mode for this goal.
|
inline |
Get whether the goal is divided by displacement.
|
inline |
Get the current exponent value.
|
inline |
Get the current exponent value.
|
inline |
Get the name of the left foot frame.
|
inline |
Get the name of the left foot frame.
|
inline |
Get the name of the right foot frame.
|
inline |
Get the name of the right foot frame.
|
inlineoverrideprotected |
|
inlineoverrideprotected |
Whether this goal supports endpoint constraint mode.
|
overrideprotected |
|
overrideprotected |
Initialize the goal with the model.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
Set whether to divide by displacement.
| tf | True to divide by displacement, false otherwise |

|
inline |
Set the exponent applied to the distance measure.
| ex | The exponent value. For ex > 1, absolute value is applied first |
|
inline |
Set the exponent for the deviation term.
| ex | The exponent value |
|
inline |
Set the frame associated with the left foot.
| left_foot | Name of the left foot frame in the model |
|
inline |
Set the body frame for the left foot.
| left_foot | Name of the left foot frame |
|
inline |
Set the frame associated with the right foot.
| right_foot | Name of the right foot frame in the model |
|
inline |
Set the body frame for the right foot.
| right_foot | Name of the right foot frame |
|
mutableprivate |
Names of forces used in calculations
|
mutableprivate |
Reference to the left foot frame.
|
mutableprivate |
Function to compute power of values.
|
mutableprivate |
Reference to the right foot frame.