GradientMethod is a base class for different ways of computing the gradient of an InverseKinematics module.
More...
#include <InverseKinematics.hpp>
|
Eigen::VectorXd | mInitialPositionsCache |
| Cache used by convertJacobianMethodOutputToGradient to avoid reallocating this vector on each iteration. More...
|
|
GradientMethod is a base class for different ways of computing the gradient of an InverseKinematics module.
◆ GradientMethod()
dart::dynamics::InverseKinematics::GradientMethod::GradientMethod |
( |
InverseKinematics * |
_ik, |
|
|
const std::string & |
_methodName, |
|
|
const Properties & |
_properties |
|
) |
| |
◆ ~GradientMethod()
virtual dart::dynamics::InverseKinematics::GradientMethod::~GradientMethod |
( |
| ) |
|
|
virtualdefault |
◆ addObserver()
void dart::common::Subject::addObserver |
( |
Observer * |
_observer | ) |
const |
|
protectedinherited |
Add an Observer to the list of Observers.
◆ applyWeights()
void dart::dynamics::InverseKinematics::GradientMethod::applyWeights |
( |
Eigen::VectorXd & |
_grad | ) |
const |
Apply weights to the gradient based on the weight settings of this GradientMethod.
◆ clampGradient()
void dart::dynamics::InverseKinematics::GradientMethod::clampGradient |
( |
Eigen::VectorXd & |
_grad | ) |
const |
Clamp the gradient based on the clamp settings of this GradientMethod.
◆ clearCache()
void dart::dynamics::InverseKinematics::GradientMethod::clearCache |
( |
| ) |
|
Clear the cache to force the gradient to be recomputed.
It should generally not be necessary to call this function.
◆ clone()
◆ computeGradient()
virtual void dart::dynamics::InverseKinematics::GradientMethod::computeGradient |
( |
const Eigen::Vector6d & |
_error, |
|
|
Eigen::VectorXd & |
_grad |
|
) |
| |
|
pure virtual |
Override this function with your implementation of the gradient computation.
The direction that this gradient points in should make the error worse if applied to the joint positions, because the Problem is configured as a gradient descent error minimization Problem.
The error vector that is passed in will be determined by the IK module's ErrorMethod. The expectation is that the first three components of the vector correspond to orientation error (in an angle-axis format) while the last three components correspond to translational error.
When implementing this function, you should assume that the Skeleton's current joint positions corresponds to the positions that you must use to compute the error. This function will only get called when an update is needed.
Implemented in dart::dynamics::InverseKinematics::Analytical, dart::dynamics::InverseKinematics::JacobianTranspose, and dart::dynamics::InverseKinematics::JacobianDLS.
◆ convertJacobianMethodOutputToGradient()
void dart::dynamics::InverseKinematics::GradientMethod::convertJacobianMethodOutputToGradient |
( |
Eigen::VectorXd & |
grad, |
|
|
const std::vector< std::size_t > & |
dofs |
|
) |
| |
Convert the gradient that gets generated by Jacobian methods into a gradient that can be used by a GradientDescentSolver.
Not all Joint types can be integrated using standard addition (e.g. FreeJoint and BallJoint), therefore Jacobian-based differential methods will tend to generate gradients that cannot be correctly used by a simple addition-based GradientDescentSolver. Running your gradient through this function before returning it will make the gradient suitable for a standard solver.
◆ evalGradient()
void dart::dynamics::InverseKinematics::GradientMethod::evalGradient |
( |
const Eigen::VectorXd & |
_q, |
|
|
Eigen::Map< Eigen::VectorXd > |
_grad |
|
) |
| |
This function is used to handle caching the gradient vector and interfacing with the solver.
◆ getComponentWeights()
const Eigen::VectorXd & dart::dynamics::InverseKinematics::GradientMethod::getComponentWeights |
( |
| ) |
const |
◆ getComponentWiseClamp()
double dart::dynamics::InverseKinematics::GradientMethod::getComponentWiseClamp |
( |
| ) |
const |
◆ getGradientMethodProperties()
◆ getIK() [1/2]
◆ getIK() [2/2]
const InverseKinematics * dart::dynamics::InverseKinematics::GradientMethod::getIK |
( |
| ) |
const |
◆ getMethodName()
const std::string & dart::dynamics::InverseKinematics::GradientMethod::getMethodName |
( |
| ) |
const |
◆ removeObserver()
void dart::common::Subject::removeObserver |
( |
Observer * |
_observer | ) |
const |
|
protectedinherited |
Remove an Observer from the list of Observers.
◆ sendDestructionNotification()
void dart::common::Subject::sendDestructionNotification |
( |
| ) |
const |
|
protectedinherited |
Send a destruction notification to all Observers.
This will cause all Observers to behave as if this Subject has been permanently deleted, so it should only be called when that behavior is desired.
◆ setComponentWeights()
void dart::dynamics::InverseKinematics::GradientMethod::setComponentWeights |
( |
const Eigen::VectorXd & |
_weights | ) |
|
Set the weights that will be applied to each component of the gradient.
If the number of components in _weights is smaller than the number of components in the gradient, then a weight of 1.0 will be applied to all components that are out of the range of _weights. Passing in an empty vector for _weights will effectively make all the gradient components unweighted.
◆ setComponentWiseClamp()
Set the component-wise clamp for this GradientMethod.
Each component of the gradient will be individually clamped to this size.
◆ mGradientP
Properties dart::dynamics::InverseKinematics::GradientMethod::mGradientP |
|
protected |
◆ mIK
◆ mInitialPositionsCache
Eigen::VectorXd dart::dynamics::InverseKinematics::GradientMethod::mInitialPositionsCache |
|
private |
Cache used by convertJacobianMethodOutputToGradient to avoid reallocating this vector on each iteration.
◆ mLastGradient
Eigen::VectorXd dart::dynamics::InverseKinematics::GradientMethod::mLastGradient |
|
protected |
◆ mLastPositions
Eigen::VectorXd dart::dynamics::InverseKinematics::GradientMethod::mLastPositions |
|
protected |
◆ mMethodName
std::string dart::dynamics::InverseKinematics::GradientMethod::mMethodName |
|
protected |
◆ mObservers
std::set<Observer*> dart::common::Subject::mObservers |
|
mutableprotectedinherited |
List of current Observers.