dart
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dart::dynamics::InverseKinematics::Analytical Class Referenceabstract

Analytical is a base class that should be inherited by methods that are made to solve the IK analytically instead of iteratively. More...

#include <InverseKinematics.hpp>

Inheritance diagram for dart::dynamics::InverseKinematics::Analytical:
Inheritance graph
[legend]
Collaboration diagram for dart::dynamics::InverseKinematics::Analytical:
Collaboration graph
[legend]

Classes

struct  Properties
 
struct  Solution
 
struct  UniqueProperties
 

Public Types

enum  Validity_t { VALID = 0, OUT_OF_REACH = 1 << 0, LIMIT_VIOLATED = 1 << 1 }
 Bitwise enumerations that are used to describe some properties of each solution produced by the analytical IK. More...
 
enum  ExtraDofUtilization { UNUSED = 0, PRE_ANALYTICAL, POST_ANALYTICAL, PRE_AND_POST_ANALYTICAL }
 If there are extra DOFs in the IK module which your Analytical solver implementation does not make use of, those DOFs can be used to supplement the analytical solver using Jacobian transpose iteration. More...
 
typedef std::function< bool(const Eigen::VectorXd &_better, const Eigen::VectorXd &_worse, const InverseKinematics *_ik)> QualityComparison
 

Public Member Functions

 Analytical (InverseKinematics *_ik, const std::string &_methodName, const Properties &_properties)
 Constructor.
 
virtual ~Analytical ()=default
 Virtual destructor.
 
const std::vector< Solution > & getSolutions ()
 Get the solutions for this IK module, along with a tag indicating whether each solution is valid. More...
 
const std::vector< Solution > & getSolutions (const Eigen::Isometry3d &_desiredTf)
 Get the solutions for this IK module, along with a tag indicating whether each solution is valid. More...
 
void computeGradient (const Eigen::Vector6d &_error, Eigen::VectorXd &_grad) override
 You should not need to override this function. More...
 
virtual const std::vector< Solution > & computeSolutions (const Eigen::Isometry3d &_desiredBodyTf)=0
 Use this function to fill the entries of the mSolutions variable. More...
 
virtual const std::vector< std::size_t > & getDofs () const =0
 Get a list of the DOFs that will be included in the entries of the solutions returned by getSolutions(). More...
 
void setPositions (const Eigen::VectorXd &_config)
 Set the configuration of the DOFs. More...
 
Eigen::VectorXd getPositions () const
 Get the configuration of the DOFs. More...
 
void setExtraDofUtilization (ExtraDofUtilization _utilization)
 Set how you want extra DOFs to be utilized by the IK module.
 
ExtraDofUtilization getExtraDofUtilization () const
 Get how extra DOFs are being utilized by the IK module.
 
void setExtraErrorLengthClamp (double _clamp)
 Set how much to clamp the error vector that gets applied to extra DOFs.
 
double getExtraErrorLengthClamp () const
 Get how much we will clamp the error vector that gets applied to extra DOFs.
 
void setQualityComparisonFunction (const QualityComparison &_func)
 Set the function that will be used to compare the qualities of two solutions. More...
 
void resetQualityComparisonFunction ()
 Reset the quality comparison function to the default method.
 
Properties getAnalyticalProperties () const
 Get the Properties for this Analytical class.
 
void constructDofMap ()
 Construct a mapping from the DOFs of getDofs() to their indices within the Node's list of dependent DOFs. More...
 
- Public Member Functions inherited from dart::dynamics::InverseKinematics::GradientMethod
 GradientMethod (InverseKinematics *_ik, const std::string &_methodName, const Properties &_properties)
 Constructor.
 
virtual ~GradientMethod ()=default
 Virtual destructor.
 
virtual std::unique_ptr< GradientMethodclone (InverseKinematics *_newIK) const =0
 Enable this GradientMethod to be cloned to a new IK module.
 
void 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. More...
 
const std::string & getMethodName () const
 Get the name of this GradientMethod.
 
void clampGradient (Eigen::VectorXd &_grad) const
 Clamp the gradient based on the clamp settings of this GradientMethod.
 
void setComponentWiseClamp (double _clamp=DefaultIKGradientComponentClamp)
 Set the component-wise clamp for this GradientMethod. More...
 
double getComponentWiseClamp () const
 Get the component-wise clamp for this GradientMethod.
 
void applyWeights (Eigen::VectorXd &_grad) const
 Apply weights to the gradient based on the weight settings of this GradientMethod. More...
 
void setComponentWeights (const Eigen::VectorXd &_weights)
 Set the weights that will be applied to each component of the gradient. More...
 
const Eigen::VectorXd & getComponentWeights () const
 Get the weights of this GradientMethod.
 
void 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. More...
 
Properties getGradientMethodProperties () const
 Get the Properties of this GradientMethod.
 
void clearCache ()
 Clear the cache to force the gradient to be recomputed. More...
 
InverseKinematicsgetIK ()
 Returns the IK module that this GradientMethod belongs to.
 
const InverseKinematicsgetIK () const
 Returns the IK module that this GradientMethod belongs to.
 
- Public Member Functions inherited from dart::common::Subject
virtual ~Subject ()
 Destructor will notify all Observers that it is destructing.
 

Protected Member Functions

virtual void addExtraDofGradient (Eigen::VectorXd &grad, const Eigen::Vector6d &error, ExtraDofUtilization utilization)
 This function will compute a gradient which utilizes the extra DOFs that go unused by the Analytical solution and then it will add the components of that gradient to the output parameter: grad. More...
 
void checkSolutionJointLimits ()
 Go through the mSolutions vector and tag entries with LIMIT_VIOLATED if any components of their configuration are outside of their position limits. More...
 
- Protected Member Functions inherited from dart::common::Subject
void sendDestructionNotification () const
 Send a destruction notification to all Observers. More...
 
void addObserver (Observer *_observer) const
 Add an Observer to the list of Observers.
 
void removeObserver (Observer *_observer) const
 Remove an Observer from the list of Observers.
 

Protected Attributes

std::vector< SolutionmSolutions
 Vector of solutions.
 
UniqueProperties mAnalyticalP
 Properties for this Analytical IK solver.
 
- Protected Attributes inherited from dart::dynamics::InverseKinematics::GradientMethod
common::sub_ptr< InverseKinematicsmIK
 The IK module that this GradientMethod belongs to.
 
std::string mMethodName
 The name of this method.
 
Eigen::VectorXd mLastPositions
 The last positions that was passed to this GradientMethod.
 
Eigen::VectorXd mLastGradient
 The last gradient that was computed by this GradientMethod.
 
Properties mGradientP
 Properties for this GradientMethod.
 
- Protected Attributes inherited from dart::common::Subject
std::set< Observer * > mObservers
 List of current Observers.
 

Detailed Description

Analytical is a base class that should be inherited by methods that are made to solve the IK analytically instead of iteratively.

This provides an extended API that is relevant to Analytical solvers but not iterative solvers.

Creating an Analytical solver will have the side effect of removing the error clamp and error weights from your ErrorMethod. If you still want your error computations to be clamped and weighted, you should set it again after creating the Analytical solver. Clamping and weighting the error vector often helps iterative methods to converge smoothly, but it is counter-productive for analytical methods which do not typically rely on convergence; analytical methods can usually solve the entire error vector directly.

Member Enumeration Documentation

◆ ExtraDofUtilization

If there are extra DOFs in the IK module which your Analytical solver implementation does not make use of, those DOFs can be used to supplement the analytical solver using Jacobian transpose iteration.

This enumeration is used to indicate whether you want those DOFs to be used before applying the analytical solution, after applying the analytical solution, or not be used at all.

Jacobian transpose is used for the extra DOFs because it is inexpensive and robust to degenerate Jacobians which are common in low dimensional joint spaces. The primary advantage of pseudoinverse methods over Jacobian transpose methods is their precision, but analytical methods are even more precise than pseudoinverse methods, so that precision is not needed in this case.

If you want the extra DOFs to use a different method than Jacobian transpose, you can create two seperate IK modules (one which is analytical and one with the iterative method of your choice) and combine them in a HierarchicalIK.

◆ Validity_t

Bitwise enumerations that are used to describe some properties of each solution produced by the analytical IK.

Enumerator
VALID 

The solution is completely valid and reaches the target.

OUT_OF_REACH 

The solution does not reach the target.

LIMIT_VIOLATED 

The solution has one or more joint positions that violate the joint limits.

Member Function Documentation

◆ addExtraDofGradient()

void dart::dynamics::InverseKinematics::Analytical::addExtraDofGradient ( Eigen::VectorXd &  grad,
const Eigen::Vector6d &  error,
ExtraDofUtilization  utilization 
)
protectedvirtual

This function will compute a gradient which utilizes the extra DOFs that go unused by the Analytical solution and then it will add the components of that gradient to the output parameter: grad.

You can override this function to customize how the extra DOFs are used. The default behavior is to use a simple Jacobian Transpose method.

The utilization flag will be PRE_ANALYTICAL if the function is being called before the Analytical solution is computed; it will be POST_ANALYTICAL if the function is being called after the Analytical solution is computed.

◆ checkSolutionJointLimits()

void dart::dynamics::InverseKinematics::Analytical::checkSolutionJointLimits ( )
protected

Go through the mSolutions vector and tag entries with LIMIT_VIOLATED if any components of their configuration are outside of their position limits.

This will NOT clear the LIMIT_VIOLATED flag from entries of mSolutions which are already tagged with it, even if they do not violate any limits.

◆ computeGradient()

void dart::dynamics::InverseKinematics::Analytical::computeGradient ( const Eigen::Vector6d &  _error,
Eigen::VectorXd &  _grad 
)
overridevirtual

You should not need to override this function.

Instead, you should override computeSolutions.

Implements dart::dynamics::InverseKinematics::GradientMethod.

◆ computeSolutions()

virtual const std::vector<Solution>& dart::dynamics::InverseKinematics::Analytical::computeSolutions ( const Eigen::Isometry3d &  _desiredBodyTf)
pure virtual

Use this function to fill the entries of the mSolutions variable.

Be sure to clear the mSolutions vector at the start, and to also return the mSolutions vector at the end. Note that you are not expected to evaluate any of the solutions for their quality. However, you should set the Solution::mValidity flag to OUT_OF_REACH for each solution that does not actually reach the desired transform, and you should call checkSolutionJointLimits() and the end of the function, which will set the LIMIT_VIOLATED flags of any configurations that are outside of the position limits.

Implemented in HuboLegIK, HuboArmIK, and dart::dynamics::IkFast.

◆ constructDofMap()

void dart::dynamics::InverseKinematics::Analytical::constructDofMap ( )

Construct a mapping from the DOFs of getDofs() to their indices within the Node's list of dependent DOFs.

This will be called immediately after the Analytical is constructed; this one call is sufficient as long as the DOFs of Analytical::getDofs() is not changed. However, if your Analytical is able to change the DOFs that it operates on, then you will need to call this function each time the DOFs have changed.

◆ getDofs()

virtual const std::vector<std::size_t>& dart::dynamics::InverseKinematics::Analytical::getDofs ( ) const
pure virtual

Get a list of the DOFs that will be included in the entries of the solutions returned by getSolutions().

Ideally, this should match up with the DOFs being used by the InverseKinematics module, but this might not always be possible, so this function ensures that solutions can be interpreted correctly.

Implemented in HuboLegIK, HuboArmIK, and dart::dynamics::IkFast.

◆ getPositions()

Eigen::VectorXd dart::dynamics::InverseKinematics::Analytical::getPositions ( ) const

Get the configuration of the DOFs.

The components of this vector will correspond to the DOFs provided by getDofs().

◆ getSolutions() [1/2]

const std::vector< IK::Analytical::Solution > & dart::dynamics::IK::Analytical::getSolutions ( )

Get the solutions for this IK module, along with a tag indicating whether each solution is valid.

This function will assume that you want to use the desired transform given by the IK module's current ErrorMethod.

◆ getSolutions() [2/2]

const std::vector< IK::Analytical::Solution > & dart::dynamics::IK::Analytical::getSolutions ( const Eigen::Isometry3d &  _desiredTf)

Get the solutions for this IK module, along with a tag indicating whether each solution is valid.

This function will compute the configurations using the given desired transform instead of using the IK module's current ErrorMethod.

◆ setPositions()

void dart::dynamics::InverseKinematics::Analytical::setPositions ( const Eigen::VectorXd &  _config)

Set the configuration of the DOFs.

The components of _config must correspond to the DOFs provided by getDofs().

◆ setQualityComparisonFunction()

void dart::dynamics::InverseKinematics::Analytical::setQualityComparisonFunction ( const QualityComparison &  _func)

Set the function that will be used to compare the qualities of two solutions.

This function should return true if the first argument is a better solution than the second argument.

By default, it will prefer the solution which has the smallest size for its largest change in joint angle. In other words, for each configuration that it is given, it will compare the largest change in joint angle for each configuration and pick the one that is smallest.

Note that outside of this comparison function, the Solutions will be split between which are valid, which are out-of-reach, and which are in violation of joint limits. Valid solutions will always be ranked above invalid solutions, and joint limit violations will always be ranked last.


The documentation for this class was generated from the following files: