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

The HierarchicalIK class provides a convenient way of setting up a hierarchical inverse kinematics optimization problem which combines several InverseKinematics problems into one. More...

#include <HierarchicalIK.hpp>

Inheritance diagram for dart::dynamics::HierarchicalIK:
Inheritance graph
[legend]
Collaboration diagram for dart::dynamics::HierarchicalIK:
Collaboration graph
[legend]

Classes

class  Constraint
 The HierarchicalIK::Constraint Function is simply used to merge the constraints of the InverseKinematics modules that belong to the hierarchy of this HierarchicalIK module. More...
 
class  Function
 This class should be inherited by optimization::Function classes that have a dependency on the HierarchicalIK module that they belong to. More...
 
class  Objective
 The HierarchicalIK::Objective Function is simply used to merge the objective and null space objective functions that are being held by this HierarchicalIK module. More...
 

Public Member Functions

virtual ~HierarchicalIK ()=default
 Virtual destructor.
 
bool solve (bool applySolution=true)
 Solve the IK Problem. More...
 
bool solve (Eigen::VectorXd &positions, bool applySolution=true)
 Same as solve(bool), but the positions vector will be filled with the solved positions. More...
 
bool findSolution (Eigen::VectorXd &positions)
 Finds a solution of the IK problem without applying the solution. More...
 
bool solveAndApply (bool allowIncompleteResult=true)
 Identical to findSolution(), but this function applies the solution when the solver successfully found a solution or allowIncompleteResult is set to true. More...
 
bool solveAndApply (Eigen::VectorXd &positions, bool allowIncompleteResult=true)
 Identical to solveAndApply(bool), but position will be filled with the solved positions. More...
 
virtual std::shared_ptr< HierarchicalIKclone (const SkeletonPtr &_newSkel) const =0
 Clone this HierarchicalIK module.
 
void setObjective (const std::shared_ptr< optimization::Function > &_objective)
 Set the objective function for this HierarchicalIK.
 
const std::shared_ptr< optimization::Function > & getObjective ()
 Get the objective function for this HierarchicalIK.
 
std::shared_ptr< const optimization::FunctiongetObjective () const
 Get the objective function for this HierarchicalIK.
 
void setNullSpaceObjective (const std::shared_ptr< optimization::Function > &_nsObjective)
 Set the null space objective for this HierarchicalIK.
 
const std::shared_ptr< optimization::Function > & getNullSpaceObjective ()
 Get the null space objective for this HierarchicalIK.
 
std::shared_ptr< const optimization::FunctiongetNullSpaceObjective () const
 Get the null space objective for this HierarchicalIK.
 
bool hasNullSpaceObjective () const
 Returns true if this HierarchicalIK has a null space objective.
 
const std::shared_ptr< optimization::Problem > & getProblem ()
 Get the Problem that is being maintained by this HierarchicalIK module.
 
std::shared_ptr< const optimization::ProblemgetProblem () const
 Get the Problem that is being maintained by this HierarchicalIK module.
 
void resetProblem (bool _clearSeeds=false)
 Reset the Problem that is being maintained by this HierarchicalIK module. More...
 
void setSolver (const std::shared_ptr< optimization::Solver > &_newSolver)
 Set the Solver that should be used by this IK module, and set it up with the Problem that is configured by this IK module.
 
const std::shared_ptr< optimization::Solver > & getSolver ()
 Get the Solver that is being used by this IK module.
 
std::shared_ptr< const optimization::SolvergetSolver () const
 Get the Solver that is being used by this IK module.
 
virtual void refreshIKHierarchy ()=0
 Refresh the IK hierarchy of this IK module.
 
const IKHierarchy & getIKHierarchy () const
 Get the IK hierarchy of this IK module.
 
const std::vector< Eigen::MatrixXd > & computeNullSpaces () const
 Compute the null spaces of each level of the hierarchy.
 
Eigen::VectorXd getPositions () const
 Get the current joint positions of the Skeleton associated with this IK module. More...
 
void setPositions (const Eigen::VectorXd &_q)
 Set the current joint positions of the Skeleton associated with this IK module. More...
 
SkeletonPtr getSkeleton ()
 Get the Skeleton that this IK module is associated with.
 
ConstSkeletonPtr getSkeleton () const
 Get the Skeleton that this IK module is associated with.
 
SkeletonPtr getAffiliation ()
 This is the same as getSkeleton(). More...
 
ConstSkeletonPtr getAffiliation () const
 This is the same as getSkeleton(). More...
 
void clearCaches ()
 Clear the caches of this IK module. More...
 
- Public Member Functions inherited from dart::common::Subject
virtual ~Subject ()
 Destructor will notify all Observers that it is destructing.
 

Protected Member Functions

 HierarchicalIK (const SkeletonPtr &_skeleton)
 Constructor.
 
void initialize (const std::shared_ptr< HierarchicalIK > &my_ptr)
 Setup the module.
 
void copyOverSetup (const std::shared_ptr< HierarchicalIK > &_otherIK) const
 Copy the setup of this HierarchicalIK module into another HierarchicalIK module.
 
- 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

WeakSkeletonPtr mSkeleton
 Pointer to the Skeleton that this IK is tied to.
 
IKHierarchy mHierarchy
 Cache for the IK hierarcy.
 
std::shared_ptr< optimization::ProblemmProblem
 The Problem that this IK module is maintaining.
 
std::shared_ptr< optimization::SolvermSolver
 The Solver that this IK module will use.
 
optimization::FunctionPtr mObjective
 The Objective of this IK module.
 
optimization::FunctionPtr mNullSpaceObjective
 The null space Objective of this IK module.
 
std::weak_ptr< HierarchicalIKmPtr
 Weak pointer to self.
 
Eigen::VectorXd mLastPositions
 Cache for the last positions.
 
std::vector< Eigen::MatrixXd > mNullSpaceCache
 Cache for null space computations.
 
Eigen::MatrixXd mPartialNullspaceCache
 Cache for a partial null space computation.
 
Eigen::JacobiSVD< math::Jacobian > mSVDCache
 Cache for the null space SVD.
 
math::Jacobian mJacCache
 Cache for Jacobians.
 
- Protected Attributes inherited from dart::common::Subject
std::set< Observer * > mObservers
 List of current Observers.
 

Detailed Description

The HierarchicalIK class provides a convenient way of setting up a hierarchical inverse kinematics optimization problem which combines several InverseKinematics problems into one.

InverseKinematics problems with a larger hierarchy level will be projected into null spaces of the problems that have a smaller hierarchy number.

Note that the HierarchicalIK will only account for the InverseKinematics::ErrorMethod and InverseKinematics::GradientMethod that the IK modules specify; it will ignore any other constraints or objectives put into the IK modules' Problems. Any additional constraints or objectives that you want the HierarchicalIK to solve should be put directly into the HierarchicalIK's Problem.

Member Function Documentation

◆ clearCaches()

void dart::dynamics::HierarchicalIK::clearCaches ( )

Clear the caches of this IK module.

It should generally not be necessary to call this function.

◆ findSolution()

bool dart::dynamics::HierarchicalIK::findSolution ( Eigen::VectorXd &  positions)

Finds a solution of the IK problem without applying the solution.

Parameters
[out]positionsThe solution of the IK problem. If the solver failed to find a solution then it will still set the position with the best guess. For example, iterative solvers will fill position with the last result of the iterations.
Returns
True if a solution is successfully found.
See also
solveAndApply()

◆ getAffiliation() [1/2]

SkeletonPtr dart::dynamics::HierarchicalIK::getAffiliation ( )

This is the same as getSkeleton().

It is used by the HierarchicalIKPtr to provide a common interface for the various IK smart pointer types.

◆ getAffiliation() [2/2]

ConstSkeletonPtr dart::dynamics::HierarchicalIK::getAffiliation ( ) const

This is the same as getSkeleton().

It is used by the HierarchicalIKPtr to provide a common interface for the various IK smart pointer types.

◆ getPositions()

Eigen::VectorXd dart::dynamics::HierarchicalIK::getPositions ( ) const

Get the current joint positions of the Skeleton associated with this IK module.

◆ resetProblem()

void dart::dynamics::HierarchicalIK::resetProblem ( bool  _clearSeeds = false)

Reset the Problem that is being maintained by this HierarchicalIK module.

This will clear out all Functions from the Problem and then configure the Problem to use this IK module's Objective and Constraint functions.

Setting _clearSeeds to true will clear out any seeds that have been loaded into the Problem.

◆ setPositions()

void dart::dynamics::HierarchicalIK::setPositions ( const Eigen::VectorXd &  _q)

Set the current joint positions of the Skeleton associated with this IK module.

The vector must include all DOFs in the Skeleton.

◆ solve() [1/2]

bool dart::dynamics::HierarchicalIK::solve ( bool  applySolution = true)

Solve the IK Problem.

By default, the Skeleton itself will retain the solved joint positions. If you pass in false for applySolution, then the joint positions will be return to their original positions after the problem is solved.

Deprecated:
Deprecated in DART 6.8. Please use solveAndApply() instead.

◆ solve() [2/2]

bool dart::dynamics::HierarchicalIK::solve ( Eigen::VectorXd &  positions,
bool  applySolution = true 
)

Same as solve(bool), but the positions vector will be filled with the solved positions.

Deprecated:
Deprecated in DART 6.8. Please use solveAndApply() or findSolution() instead.

◆ solveAndApply() [1/2]

bool dart::dynamics::HierarchicalIK::solveAndApply ( bool  allowIncompleteResult = true)

Identical to findSolution(), but this function applies the solution when the solver successfully found a solution or allowIncompleteResult is set to true.

Parameters
[in]allowIncompleteResultAllow to apply the solution even when the solver failed to find solution. This option would be useful when an iterative solver is used because they will often do a decent job of getting a result close to a solution even if it failed to find the solution.
Returns
True if a solution is successfully found

◆ solveAndApply() [2/2]

bool dart::dynamics::HierarchicalIK::solveAndApply ( Eigen::VectorXd &  positions,
bool  allowIncompleteResult = true 
)

Identical to solveAndApply(bool), but position will be filled with the solved positions.

Parameters
[out]positionsThe solution of the IK problem. If the solver failed to find a solution then it will still set the position with the best guess. For example, iterative solvers will fill positions with the last result of the iterations.
[in]allowIncompleteResultAllow to apply the solution even when the solver failed to find solution. This option would be useful when an iterative solver is used because they will often do a decent job of getting a result close to a solution even if it failed to find the solution.
Returns
True if a solution is successfully found

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