class
#include <iDynTree/Traversal.h>
Traversal Class that represents a traversal of a set of links of a Model.
The traversal is represented by an ordered vector of links. For a given model, the traversal is always built in such a way that there exist a spanning tree that has as a root the first link (with traversal index 0) of the traversal, and such that every link comes after its spanning tree parent.
For every link in the traversal are provided:
- a pointer to the link itself
- a pointer to the parent link in the spanning tree
- a pointer to the joint connecting the link to the parent
For the first link of the traversal (i.e. base of the traversal) there is not spanning tree parent, so the point to the parent link/joint are NULL.
Constructors, destructors, conversion operators
- Traversal()
- ~Traversal()
Public functions
- auto getNrOfVisitedLinks() const -> unsigned int
- Get the number of visited links.
- auto getLink(const TraversalIndex traversalIndex) const -> const Link*
- Get the traversalIndex-th link of the traversal.
- auto getBaseLink() const -> const Link*
- Get the base link of the traversal.
- auto getParentLink(const TraversalIndex traversalIndex) const -> const Link*
- Get the parent link of the traversalIndex-th link of the traversal.
- auto getParentJoint(const TraversalIndex traversalIndex) const -> const IJoint*
- Get the joint connecting the traversalIndex-th link of the traversal to its parent.
- auto getParentLinkFromLinkIndex(const LinkIndex linkIndex) const -> const Link*
- Get the parent link of the link with index linkIndex of the traversal.
- auto getParentJointFromLinkIndex(const LinkIndex linkIndex) const -> const IJoint*
- Get the joint connecting the link with index linkIndex to its parent.
- auto getTraversalIndexFromLinkIndex(const LinkIndex linkIndex) const -> TraversalIndex
- Get the traversal index of the specified link.
- auto reset(const unsigned int nrOfLinksInModel) -> bool
- Reset the Traversal.
- auto reset(const Model& model) -> bool
- Reset the Traversal.
- auto addTraversalBase(const Link* link) -> bool
- Add a base to traversal.
- auto addTraversalElement(const Link* link, const IJoint* jointToParent, const Link* parentLink) -> bool
- Add an element to the traversal.
- auto isParentOf(const LinkIndex parentCandidate, const LinkIndex childCandidate) const -> bool
- Check if a link is the parent of another link for this traversal.
- auto getChildLinkIndexFromJointIndex(const Model& model, const JointIndex jntIdx) const -> LinkIndex
- Get the child link (according to the traversal) of a Joint.
- auto getParentLinkIndexFromJointIndex(const Model& model, const JointIndex jntIdx) const -> LinkIndex
- Get the parent link (according to the traversal) of a Joint.
- auto toString(const Model& model) const -> std::string
- Return a human-readable representation of the traversal.
Function documentation
unsigned int iDynTree:: Traversal:: getNrOfVisitedLinks() const
Get the number of visited links.
Returns | the number of links in the Traversal |
---|
const Link* iDynTree:: Traversal:: getBaseLink() const
Get the base link of the traversal.
Returns | a pointer to the base link of the traversal. |
---|
const Link* iDynTree:: Traversal:: getParentLink(const TraversalIndex traversalIndex) const
Get the parent link of the traversalIndex-th link of the traversal.
Returns | a pointer to the parent link of the traversalIndex-th link of the traversal. |
---|
const IJoint* iDynTree:: Traversal:: getParentJoint(const TraversalIndex traversalIndex) const
Get the joint connecting the traversalIndex-th link of the traversal to its parent.
Returns | a pointer to the joint connecting the link traversalIndex-th link of the traversal. |
---|
const Link* iDynTree:: Traversal:: getParentLinkFromLinkIndex(const LinkIndex linkIndex) const
Get the parent link of the link with index linkIndex of the traversal.
Returns | a pointer to the parent link of the traversalIndex-th link of the traversal. |
---|
const IJoint* iDynTree:: Traversal:: getParentJointFromLinkIndex(const LinkIndex linkIndex) const
Get the joint connecting the link with index linkIndex to its parent.
Returns | a pointer to the joint connecting the link traversalIndex-th link of the traversal. |
---|
TraversalIndex iDynTree:: Traversal:: getTraversalIndexFromLinkIndex(const LinkIndex linkIndex) const
Get the traversal index of the specified link.
Returns | the traversalIndex of the specified link, or TRAVERSAL_INDEX_INVALID if the link does not belong to the traversal. |
---|
bool iDynTree:: Traversal:: reset(const unsigned int nrOfLinksInModel)
Reset the Traversal.
Parameters | |
---|---|
nrOfLinksInModel in | total number of links in the model, not the number of visited links in the Traversal. |
Returns | true if all went well, false otherwise |
After a call to reset, the Traversal will contain no visited links, so it needs to be approprately populated with the addTraversalBase and addTraversalElement methods.
bool iDynTree:: Traversal:: reset(const Model& model)
Reset the Traversal.
Parameters | |
---|---|
model in | Model on which this traversal will be used, used to initialize the internal data structure using the getNrOfLinks() method. |
Returns | true if all went well, false otherwise |
After a call to reset, all the pointers in the Traversal are set to 0, and the Traversal should be approprialy populated with the setters before use.
bool iDynTree:: Traversal:: addTraversalBase(const Link* link)
Add a base to traversal.
Parameters | |
---|---|
link in | a pointer to the base link |
Returns | true if all went well, false otherwise |
Equivalent to addTraversalElement(link,NULL,NULL), but will print an error and return false if it is called with a traversal that already has a base, i.e. getNrOfVisitedLinks() > 0
bool iDynTree:: Traversal:: addTraversalElement(const Link* link,
const IJoint* jointToParent,
const Link* parentLink)
Add an element to the traversal.
Parameters | |
---|---|
link in | a pointer to the link to add to the traversal |
jointToParent in | a pointer to the joint that connects the added link to its parent in this traversal |
parentLink in | a pointer to the parent on this link in this traversal. It should be a link already contained in this traversal. |
Returns | true if all went well, false otherwise. |
After a call to this method, the getNrOfVisitedLinks() will be increased of 1 unit.
bool iDynTree:: Traversal:: isParentOf(const LinkIndex parentCandidate,
const LinkIndex childCandidate) const
Check if a link is the parent of another link for this traversal.
Parameters | |
---|---|
parentCandidate in | the link candidate to be the parent of childCandidate. |
childCandidate in | the link candidate to be a child of parentCandidate. |
Returns | true if parentCandidate is actually the parent of childCandidate, false otherwise. |
LinkIndex iDynTree:: Traversal:: getChildLinkIndexFromJointIndex(const Model& model,
const JointIndex jntIdx) const
Get the child link (according to the traversal) of a Joint.
Parameters | |
---|---|
model | |
jntIdx in | the index of the joint of which we want to get the child link. |
Returns | the index of the child link if all went well, LINK_INVALID_INDEX otherwise . |
LinkIndex iDynTree:: Traversal:: getParentLinkIndexFromJointIndex(const Model& model,
const JointIndex jntIdx) const
Get the parent link (according to the traversal) of a Joint.
Parameters | |
---|---|
model | |
jntIdx in | the index of the joint of which we want to get the parent link. |
Returns | the index of the parent link if all went well, LINK_INVALID_INDEX otherwise . |