33 #ifndef DART_CONSTRAINT_BALANCECONSTRAINT_HPP_
34 #define DART_CONSTRAINT_BALANCECONSTRAINT_HPP_
39 namespace constraint {
97 const std::shared_ptr<dynamics::HierarchicalIK>& _newIK)
const override;
100 double eval(
const Eigen::VectorXd& _x)
override;
104 Eigen::Map<Eigen::VectorXd> _grad)
override;
147 Eigen::Map<Eigen::VectorXd>& grad);
151 std::weak_ptr<dynamics::HierarchicalIK>
mIK;
BalanceConstraint is a kinematic constraint function designed to be passed into a HierarchicalIK modu...
Definition: BalanceConstraint.hpp:47
BalanceMethod_t mBalanceMethod
The method that will be used for balance.
Definition: BalanceConstraint.hpp:157
Eigen::Vector3d mLastError
The error vector points away from the direction that the center of mass should move in order to reduc...
Definition: BalanceConstraint.hpp:171
void setOptimizationTolerance(double _tol)
Set the tolerance for how far the center of mass can be from the support polygon centroid before the ...
Definition: BalanceConstraint.cpp:357
virtual ~BalanceConstraint()=default
Virtual destructor.
void evalGradient(const Eigen::VectorXd &_x, Eigen::Map< Eigen::VectorXd > _grad) override
Evaluates and returns the objective function at the point x.
Definition: BalanceConstraint.cpp:180
BalanceMethod_t getBalanceMethod() const
Get the method that this constraint function will use to achieve balance.
Definition: BalanceConstraint.cpp:351
BalanceConstraint(const std::shared_ptr< dynamics::HierarchicalIK > &_ik, BalanceMethod_t _balanceMethod=SHIFT_SUPPORT, ErrorMethod_t _errorMethod=FROM_CENTROID)
Constructor.
Definition: BalanceConstraint.cpp:42
std::size_t mClosestEndEffector[2]
The indices of the supporting end effectors that are closest to the center of mass.
Definition: BalanceConstraint.hpp:167
ErrorMethod_t getErrorMethod() const
Get the method that this constraint function will use to compute the error.
Definition: BalanceConstraint.cpp:335
Eigen::MatrixXd mPartialNullSpaceCache
Cache for an individual null space.
Definition: BalanceConstraint.hpp:194
void convertJacobianMethodOutputToGradient(Eigen::Map< Eigen::VectorXd > &grad)
Convert the gradient that gets generated via Jacobian methods into a gradient that can be used by a G...
Definition: BalanceConstraint.cpp:402
double mOptimizationTolerance
The tolerance allowed before optimization is considered successful.
Definition: BalanceConstraint.hpp:160
std::weak_ptr< dynamics::HierarchicalIK > mIK
Pointer to the hierarchical IK that owns this Function.
Definition: BalanceConstraint.hpp:151
BalanceMethod_t
The BalanceMethod_t determines whether balancing should be achieved by shifting the locations of the ...
Definition: BalanceConstraint.hpp:82
@ SHIFT_COM
Definition: BalanceConstraint.hpp:84
@ SHIFT_SUPPORT
Definition: BalanceConstraint.hpp:83
Eigen::JacobiSVD< math::LinearJacobian > mSVDCache
Cache for the SVD.
Definition: BalanceConstraint.hpp:188
void setPseudoInverseDamping(double _damping)
Set the damping factor that will be used when computing the pseudoinverse.
Definition: BalanceConstraint.cpp:373
double mDamping
The damping factor for the pseudoinverse.
Definition: BalanceConstraint.hpp:163
ErrorMethod_t
The ErrorMethod_t determines whether the error should be computed based on the center of mass's dista...
Definition: BalanceConstraint.hpp:65
@ OPTIMIZE_BALANCE
Definition: BalanceConstraint.hpp:68
@ FROM_EDGE
Definition: BalanceConstraint.hpp:67
@ FROM_CENTROID
Definition: BalanceConstraint.hpp:66
optimizer::FunctionPtr clone(const std::shared_ptr< dynamics::HierarchicalIK > &_newIK) const override
Definition: BalanceConstraint.cpp:58
double eval(const Eigen::VectorXd &_x) override
Evaluates and returns the objective function at the point x.
Definition: BalanceConstraint.cpp:65
double getOptimizationTolerance() const
Get the tolerance for how far the center of mass can be from the support polygon centroid before the ...
Definition: BalanceConstraint.cpp:367
std::size_t mLastSupportVersion
The last version of the support polygon that was computed.
Definition: BalanceConstraint.hpp:177
void clearCaches()
Clear the caches to force the error computation to update.
Definition: BalanceConstraint.cpp:395
Eigen::Vector3d mLastCOM
The last computed location of the center of mass.
Definition: BalanceConstraint.hpp:174
const Eigen::Vector3d & getLastError() const
Get the last error vector that was computed by this BalanceConstraint.
Definition: BalanceConstraint.cpp:389
double getPseudoInverseDamping() const
Get the damping factor that will be used when computing the pseudoinverse.
Definition: BalanceConstraint.cpp:383
math::LinearJacobian mComJacCache
Cache for the center of mass Jacobian so that the memory space does not need to be reallocated each l...
Definition: BalanceConstraint.hpp:181
Eigen::MatrixXd mNullSpaceCache
Cache for the full null space.
Definition: BalanceConstraint.hpp:191
void setBalanceMethod(BalanceMethod_t _method)
Set the method that this constraint function will use to achieve balance.
Definition: BalanceConstraint.cpp:341
ErrorMethod_t mErrorMethod
The method that will be used to compute error.
Definition: BalanceConstraint.hpp:154
Eigen::VectorXd mInitialPositionsCache
Cache used by convertJacobianMethodOutputToGradient to avoid reallocating this vector on each iterati...
Definition: BalanceConstraint.hpp:198
void setErrorMethod(ErrorMethod_t _method)
Set the method that this constraint function will use to compute the error.
Definition: BalanceConstraint.cpp:325
math::LinearJacobian mEEJacCache
Cache for the end effector Jacobians so the space does not need to be reallocated each loop.
Definition: BalanceConstraint.hpp:185
This class should be inherited by optimizer::Function classes that have a dependency on the Hierarchi...
Definition: HierarchicalIK.hpp:91
Definition: Function.hpp:46
Eigen::Matrix< double, 3, Eigen::Dynamic > LinearJacobian
Definition: MathTypes.hpp:106
std::shared_ptr< Function > FunctionPtr
Definition: Function.hpp:84
Definition: BulletCollisionDetector.cpp:63