DART  6.6.2
dart::dynamics::CompositeIK Class Reference

The CompositeIK class allows you to specify an arbitrary hierarchy of InverseKinematics modules for a single Skeleton. More...

#include <HierarchicalIK.hpp>

Inheritance diagram for dart::dynamics::CompositeIK:
dart::dynamics::HierarchicalIK dart::common::Subject

Public Types

typedef std::unordered_set< std::shared_ptr< InverseKinematics > > ModuleSet
 
typedef std::unordered_set< std::shared_ptr< const InverseKinematics > > ConstModuleSet
 

Public Member Functions

std::shared_ptr< HierarchicalIKclone (const SkeletonPtr &_newSkel) const override
 Clone this HierarchicalIK module. More...
 
virtual std::shared_ptr< CompositeIKcloneCompositeIK (const SkeletonPtr &_newSkel) const
 Same as clone(), but passes back a more complete type. More...
 
bool addModule (const std::shared_ptr< InverseKinematics > &_ik)
 Add an IK module to this CompositeIK. More...
 
const ModuleSetgetModuleSet ()
 Get the set of modules being used by this CompositeIK. More...
 
ConstModuleSet getModuleSet () const
 Get the set of modules being used by this CompositeIK. More...
 
void refreshIKHierarchy () override
 Refresh the IK hierarchy of this IK module. More...
 
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...
 
void setObjective (const std::shared_ptr< optimizer::Function > &_objective)
 Set the objective function for this HierarchicalIK. More...
 
const std::shared_ptr< optimizer::Function > & getObjective ()
 Get the objective function for this HierarchicalIK. More...
 
std::shared_ptr< const optimizer::FunctiongetObjective () const
 Get the objective function for this HierarchicalIK. More...
 
void setNullSpaceObjective (const std::shared_ptr< optimizer::Function > &_nsObjective)
 Set the null space objective for this HierarchicalIK. More...
 
const std::shared_ptr< optimizer::Function > & getNullSpaceObjective ()
 Get the null space objective for this HierarchicalIK. More...
 
std::shared_ptr< const optimizer::FunctiongetNullSpaceObjective () const
 Get the null space objective for this HierarchicalIK. More...
 
bool hasNullSpaceObjective () const
 Returns true if this HierarchicalIK has a null space objective. More...
 
const std::shared_ptr< optimizer::Problem > & getProblem ()
 Get the Problem that is being maintained by this HierarchicalIK module. More...
 
std::shared_ptr< const optimizer::ProblemgetProblem () const
 Get the Problem that is being maintained by this HierarchicalIK module. More...
 
void resetProblem (bool _clearSeeds=false)
 Reset the Problem that is being maintained by this HierarchicalIK module. More...
 
void setSolver (const std::shared_ptr< optimizer::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. More...
 
const std::shared_ptr< optimizer::Solver > & getSolver ()
 Get the Solver that is being used by this IK module. More...
 
std::shared_ptr< const optimizer::SolvergetSolver () const
 Get the Solver that is being used by this IK module. More...
 
const IKHierarchygetIKHierarchy () const
 Get the IK hierarchy of this IK module. More...
 
const std::vector< Eigen::MatrixXd > & computeNullSpaces () const
 Compute the null spaces of each level of the hierarchy. More...
 
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. More...
 
ConstSkeletonPtr getSkeleton () const
 Get the Skeleton that this IK module is associated with. More...
 
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...
 

Static Public Member Functions

static std::shared_ptr< CompositeIKcreate (const SkeletonPtr &_skel)
 Create a CompositeIK module. More...
 

Protected Member Functions

 CompositeIK (const SkeletonPtr &_skel)
 Constructor. More...
 
void initialize (const std::shared_ptr< HierarchicalIK > &my_ptr)
 Setup the module. More...
 
void copyOverSetup (const std::shared_ptr< HierarchicalIK > &_otherIK) const
 Copy the setup of this HierarchicalIK module into another HierarchicalIK module. More...
 
void sendDestructionNotification () const
 Send a destruction notification to all Observers. More...
 
void addObserver (Observer *_observer) const
 Add an Observer to the list of Observers. More...
 
void removeObserver (Observer *_observer) const
 Remove an Observer from the list of Observers. More...
 

Protected Attributes

std::unordered_set< std::shared_ptr< InverseKinematics > > mModuleSet
 The set of modules being used by this CompositeIK. More...
 
WeakSkeletonPtr mSkeleton
 Pointer to the Skeleton that this IK is tied to. More...
 
IKHierarchy mHierarchy
 Cache for the IK hierarcy. More...
 
std::shared_ptr< optimizer::ProblemmProblem
 The Problem that this IK module is maintaining. More...
 
std::shared_ptr< optimizer::SolvermSolver
 The Solver that this IK module will use. More...
 
optimizer::FunctionPtr mObjective
 The Objective of this IK module. More...
 
optimizer::FunctionPtr mNullSpaceObjective
 The null space Objective of this IK module. More...
 
std::weak_ptr< HierarchicalIKmPtr
 Weak pointer to self. More...
 
Eigen::VectorXd mLastPositions
 Cache for the last positions. More...
 
std::vector< Eigen::MatrixXd > mNullSpaceCache
 Cache for null space computations. More...
 
Eigen::MatrixXd mPartialNullspaceCache
 Cache for a partial null space computation. More...
 
Eigen::JacobiSVD< math::JacobianmSVDCache
 Cache for the null space SVD. More...
 
math::Jacobian mJacCache
 Cache for Jacobians. More...
 
std::set< Observer * > mObservers
 List of current Observers. More...
 

Detailed Description

The CompositeIK class allows you to specify an arbitrary hierarchy of InverseKinematics modules for a single Skeleton.

Simply add in each IK module that should be used.

Member Typedef Documentation

◆ ConstModuleSet

typedef std::unordered_set< std::shared_ptr<const InverseKinematics> > dart::dynamics::CompositeIK::ConstModuleSet

◆ ModuleSet

typedef std::unordered_set< std::shared_ptr<InverseKinematics> > dart::dynamics::CompositeIK::ModuleSet

Constructor & Destructor Documentation

◆ CompositeIK()

dart::dynamics::CompositeIK::CompositeIK ( const SkeletonPtr _skel)
protected

Constructor.

Member Function Documentation

◆ addModule()

bool dart::dynamics::CompositeIK::addModule ( const std::shared_ptr< InverseKinematics > &  _ik)

Add an IK module to this CompositeIK.

This function will return true if the module belongs to the Skeleton that this CompositeIK is associated with, otherwise it will return false.

◆ addObserver()

void dart::common::Subject::addObserver ( Observer _observer) const
protectedinherited

Add an Observer to the list of Observers.

◆ clearCaches()

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

Clear the caches of this IK module.

It should generally not be necessary to call this function.

◆ clone()

std::shared_ptr< HierarchicalIK > dart::dynamics::CompositeIK::clone ( const SkeletonPtr _newSkel) const
overridevirtual

Clone this HierarchicalIK module.

Implements dart::dynamics::HierarchicalIK.

◆ cloneCompositeIK()

std::shared_ptr< CompositeIK > dart::dynamics::CompositeIK::cloneCompositeIK ( const SkeletonPtr _newSkel) const
virtual

Same as clone(), but passes back a more complete type.

◆ computeNullSpaces()

const std::vector< Eigen::MatrixXd > & dart::dynamics::HierarchicalIK::computeNullSpaces ( ) const
inherited

Compute the null spaces of each level of the hierarchy.

◆ copyOverSetup()

void dart::dynamics::HierarchicalIK::copyOverSetup ( const std::shared_ptr< HierarchicalIK > &  _otherIK) const
protectedinherited

Copy the setup of this HierarchicalIK module into another HierarchicalIK module.

◆ create()

std::shared_ptr< CompositeIK > dart::dynamics::CompositeIK::create ( const SkeletonPtr _skel)
static

Create a CompositeIK module.

◆ getAffiliation() [1/2]

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

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
inherited

This is the same as getSkeleton().

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

◆ getIKHierarchy()

const IKHierarchy & dart::dynamics::HierarchicalIK::getIKHierarchy ( ) const
inherited

Get the IK hierarchy of this IK module.

◆ getModuleSet() [1/2]

const CompositeIK::ModuleSet & dart::dynamics::CompositeIK::getModuleSet ( )

Get the set of modules being used by this CompositeIK.

◆ getModuleSet() [2/2]

CompositeIK::ConstModuleSet dart::dynamics::CompositeIK::getModuleSet ( ) const

Get the set of modules being used by this CompositeIK.

◆ getNullSpaceObjective() [1/2]

const std::shared_ptr< optimizer::Function > & dart::dynamics::HierarchicalIK::getNullSpaceObjective ( )
inherited

Get the null space objective for this HierarchicalIK.

◆ getNullSpaceObjective() [2/2]

std::shared_ptr< const optimizer::Function > dart::dynamics::HierarchicalIK::getNullSpaceObjective ( ) const
inherited

Get the null space objective for this HierarchicalIK.

◆ getObjective() [1/2]

const std::shared_ptr< optimizer::Function > & dart::dynamics::HierarchicalIK::getObjective ( )
inherited

Get the objective function for this HierarchicalIK.

◆ getObjective() [2/2]

std::shared_ptr< const optimizer::Function > dart::dynamics::HierarchicalIK::getObjective ( ) const
inherited

Get the objective function for this HierarchicalIK.

◆ getPositions()

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

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

◆ getProblem() [1/2]

const std::shared_ptr< optimizer::Problem > & dart::dynamics::HierarchicalIK::getProblem ( )
inherited

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

◆ getProblem() [2/2]

std::shared_ptr< const optimizer::Problem > dart::dynamics::HierarchicalIK::getProblem ( ) const
inherited

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

◆ getSkeleton() [1/2]

SkeletonPtr dart::dynamics::HierarchicalIK::getSkeleton ( )
inherited

Get the Skeleton that this IK module is associated with.

◆ getSkeleton() [2/2]

ConstSkeletonPtr dart::dynamics::HierarchicalIK::getSkeleton ( ) const
inherited

Get the Skeleton that this IK module is associated with.

◆ getSolver() [1/2]

const std::shared_ptr< optimizer::Solver > & dart::dynamics::HierarchicalIK::getSolver ( )
inherited

Get the Solver that is being used by this IK module.

◆ getSolver() [2/2]

std::shared_ptr< const optimizer::Solver > dart::dynamics::HierarchicalIK::getSolver ( ) const
inherited

Get the Solver that is being used by this IK module.

◆ hasNullSpaceObjective()

bool dart::dynamics::HierarchicalIK::hasNullSpaceObjective ( ) const
inherited

Returns true if this HierarchicalIK has a null space objective.

◆ initialize()

void dart::dynamics::HierarchicalIK::initialize ( const std::shared_ptr< HierarchicalIK > &  my_ptr)
protectedinherited

Setup the module.

◆ refreshIKHierarchy()

void dart::dynamics::CompositeIK::refreshIKHierarchy ( )
overridevirtual

Refresh the IK hierarchy of this IK module.

Implements dart::dynamics::HierarchicalIK.

◆ removeObserver()

void dart::common::Subject::removeObserver ( Observer _observer) const
protectedinherited

Remove an Observer from the list of Observers.

◆ resetProblem()

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

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.

◆ 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.

◆ setNullSpaceObjective()

void dart::dynamics::HierarchicalIK::setNullSpaceObjective ( const std::shared_ptr< optimizer::Function > &  _nsObjective)
inherited

Set the null space objective for this HierarchicalIK.

◆ setObjective()

void dart::dynamics::HierarchicalIK::setObjective ( const std::shared_ptr< optimizer::Function > &  _objective)
inherited

Set the objective function for this HierarchicalIK.

◆ setPositions()

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

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

The vector must include all DOFs in the Skeleton.

◆ setSolver()

void dart::dynamics::HierarchicalIK::setSolver ( const std::shared_ptr< optimizer::Solver > &  _newSolver)
inherited

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.

◆ solve() [1/2]

bool dart::dynamics::HierarchicalIK::solve ( bool  _applySolution = true)
inherited

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.

◆ solve() [2/2]

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

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

Member Data Documentation

◆ mHierarchy

IKHierarchy dart::dynamics::HierarchicalIK::mHierarchy
protectedinherited

Cache for the IK hierarcy.

◆ mJacCache

math::Jacobian dart::dynamics::HierarchicalIK::mJacCache
mutableprotectedinherited

Cache for Jacobians.

◆ mLastPositions

Eigen::VectorXd dart::dynamics::HierarchicalIK::mLastPositions
mutableprotectedinherited

Cache for the last positions.

◆ mModuleSet

std::unordered_set< std::shared_ptr<InverseKinematics> > dart::dynamics::CompositeIK::mModuleSet
protected

The set of modules being used by this CompositeIK.

◆ mNullSpaceCache

std::vector<Eigen::MatrixXd> dart::dynamics::HierarchicalIK::mNullSpaceCache
mutableprotectedinherited

Cache for null space computations.

◆ mNullSpaceObjective

optimizer::FunctionPtr dart::dynamics::HierarchicalIK::mNullSpaceObjective
protectedinherited

The null space Objective of this IK module.

◆ mObjective

optimizer::FunctionPtr dart::dynamics::HierarchicalIK::mObjective
protectedinherited

The Objective of this IK module.

◆ mObservers

std::set<Observer*> dart::common::Subject::mObservers
mutableprotectedinherited

List of current Observers.

◆ mPartialNullspaceCache

Eigen::MatrixXd dart::dynamics::HierarchicalIK::mPartialNullspaceCache
mutableprotectedinherited

Cache for a partial null space computation.

◆ mProblem

std::shared_ptr<optimizer::Problem> dart::dynamics::HierarchicalIK::mProblem
protectedinherited

The Problem that this IK module is maintaining.

◆ mPtr

std::weak_ptr<HierarchicalIK> dart::dynamics::HierarchicalIK::mPtr
protectedinherited

Weak pointer to self.

◆ mSkeleton

WeakSkeletonPtr dart::dynamics::HierarchicalIK::mSkeleton
protectedinherited

Pointer to the Skeleton that this IK is tied to.

◆ mSolver

std::shared_ptr<optimizer::Solver> dart::dynamics::HierarchicalIK::mSolver
protectedinherited

The Solver that this IK module will use.

◆ mSVDCache

Eigen::JacobiSVD<math::Jacobian> dart::dynamics::HierarchicalIK::mSVDCache
mutableprotectedinherited

Cache for the null space SVD.