This class provides functions to traverse the URDF and provides convenience functions to access the URDF model. More...
#include <UrdfTraverser.h>
Public Member Functions | |
LinkPtr | getChildLink (const JointConstPtr &joint) |
JointPtr | getJoint (const std::string &name) |
bool | getJointNames (const std::string &fromLink, const bool skipFixed, std::vector< std::string > &result) |
LinkPtr | getLink (const std::string &name) |
ModelPtr | getModel () |
std::string | getModelDirectory () const |
bool | getModelFromFile (const std::string &urdfFilename, std::string &xml_string) const |
std::string | getModelName () const |
JointPtr | getParentJoint (const JointConstPtr &joint) |
std::string | getRootLinkName () const |
bool | loadModelFromFile (const std::string &urdfFilename) |
bool | loadModelFromXMLString (const std::string &xmlString) |
void | printJointNames (const std::string &fromLink) |
bool | printModel (const std::string &fromLink, bool verbose) |
bool | printModel (bool verbose) |
LinkConstPtr | readChildLink (const JointConstPtr &joint) const |
JointConstPtr | readJoint (const std::string &name) const |
LinkConstPtr | readLink (const std::string &name) const |
ModelConstPtr | readModel () const |
JointConstPtr | readParentJoint (const JointConstPtr &joint) const |
void | setModelDirectory (const std::string &dir) |
int | traverseTreeBottomUp (const std::string &linkName, boost::function< int(RecursionParamsPtr &)> link_cb, RecursionParamsPtr ¶ms, bool includeLink=true) |
int | traverseTreeTopDown (const std::string &linkName, boost::function< int(RecursionParamsPtr &)> link_cb, RecursionParamsPtr ¶ms, bool includeLink=true) |
UrdfTraverser () | |
~UrdfTraverser () | |
Protected Member Functions | |
int | getChildJoint (const JointPtr &joint, JointPtr &child) |
bool | getDependencyOrderedJoints (std::vector< JointPtr > &result, const JointPtr &from_joint, bool allowSplits=true, bool onlyActive=true) |
bool | getDependencyOrderedJoints (std::vector< JointPtr > &result, const LinkPtr &from_link, bool allowSplits=true, bool onlyActive=true) |
EigenTransform | getTransform (const LinkPtr &from_link, const JointPtr &to_joint) |
bool | hasChildLink (const LinkConstPtr &link, const std::string &childName) const |
int | traverseTreeBottomUp (const LinkPtr &link, boost::function< int(RecursionParamsPtr &)> link_cb, RecursionParamsPtr ¶ms, bool includeLink=true, unsigned int level=0) |
int | traverseTreeTopDown (const LinkPtr &link, boost::function< int(RecursionParamsPtr &)> link_cb, RecursionParamsPtr ¶ms, bool includeLink=true, unsigned int level=0) |
Private Member Functions | |
int | printLink (RecursionParamsPtr &p) |
Private Attributes | |
ModelPtr | model |
std::string | modelDir |
This class provides functions to traverse the URDF and provides convenience functions to access the URDF model.
Traversal through a model is always done on links. This is because the root of a model is always a link. Traversal through joint space is also possible by using the link's parent joint as reference.
Methods int traverseTreeTopDown() and traverseTreeBottomUp() can be used and will require a callback function for the traversal. An example of how to use the functions can for example be found in PrintModel.h or JointNames.h.
Definition at line 66 of file UrdfTraverser.h.
urdf_traverser::UrdfTraverser::UrdfTraverser | ( | ) | [inline, explicit] |
Definition at line 72 of file UrdfTraverser.h.
urdf_traverser::UrdfTraverser::~UrdfTraverser | ( | ) | [inline] |
Definition at line 76 of file UrdfTraverser.h.
int UrdfTraverser::getChildJoint | ( | const JointPtr & | joint, |
JointPtr & | child | ||
) | [protected] |
-2 | on error |
-1 | if the joint has multiple children |
0 | if the joint has no child joints (it's an end effector joint), |
1 | if a child joint is returned in parameter "child" |
Definition at line 108 of file UrdfTraverser.cpp.
urdf_traverser::LinkPtr UrdfTraverser::getChildLink | ( | const JointConstPtr & | joint | ) |
Definition at line 132 of file UrdfTraverser.cpp.
bool UrdfTraverser::getDependencyOrderedJoints | ( | std::vector< JointPtr > & | result, |
const JointPtr & | from_joint, | ||
bool | allowSplits = true , |
||
bool | onlyActive = true |
||
) | [protected] |
Returns all joints starting from from_joint (including from_joint) within the tree. This is obtained by depth-first traversal, so all joints in the result won't depend on any joints further back in the result set.
Definition at line 74 of file UrdfTraverser.cpp.
bool UrdfTraverser::getDependencyOrderedJoints | ( | std::vector< JointPtr > & | result, |
const LinkPtr & | from_link, | ||
bool | allowSplits = true , |
||
bool | onlyActive = true |
||
) | [protected] |
Returns all joints down from from_link within the tree. This is obtained by depth-first traversal, so all joints in the result won't depend on any joints further back in the result set.
Definition at line 80 of file UrdfTraverser.cpp.
urdf_traverser::JointPtr UrdfTraverser::getJoint | ( | const std::string & | name | ) |
Definition at line 320 of file UrdfTraverser.cpp.
bool UrdfTraverser::getJointNames | ( | const std::string & | fromLink, |
const bool | skipFixed, | ||
std::vector< std::string > & | result | ||
) |
Returns all joint names in depth-frist search order starting from fromLink (or from root if fromLink is empty). Only joints *after* the given link are returned.
Definition at line 87 of file UrdfTraverser.cpp.
urdf_traverser::LinkPtr UrdfTraverser::getLink | ( | const std::string & | name | ) |
Definition at line 306 of file UrdfTraverser.cpp.
ModelPtr urdf_traverser::UrdfTraverser::getModel | ( | ) | [inline] |
Definition at line 180 of file UrdfTraverser.h.
std::string urdf_traverser::UrdfTraverser::getModelDirectory | ( | ) | const [inline] |
Definition at line 111 of file UrdfTraverser.h.
bool UrdfTraverser::getModelFromFile | ( | const std::string & | urdfFilename, |
std::string & | xml_string | ||
) | const |
Reads the URDF file from the filename into xml_string. Does not change anything in the UrdfTraverser object. Result can be used with loadModelFromXMLString().
Definition at line 394 of file UrdfTraverser.cpp.
std::string urdf_traverser::UrdfTraverser::getModelName | ( | ) | const [inline] |
Definition at line 132 of file UrdfTraverser.h.
urdf_traverser::JointPtr UrdfTraverser::getParentJoint | ( | const JointConstPtr & | joint | ) |
Definition at line 146 of file UrdfTraverser.cpp.
std::string UrdfTraverser::getRootLinkName | ( | ) | const |
Definition at line 52 of file UrdfTraverser.cpp.
urdf_traverser::EigenTransform UrdfTraverser::getTransform | ( | const LinkPtr & | from_link, |
const JointPtr & | to_joint | ||
) | [protected] |
Definition at line 413 of file UrdfTraverser.cpp.
bool UrdfTraverser::hasChildLink | ( | const LinkConstPtr & | link, |
const std::string & | childName | ||
) | const [protected] |
Definition at line 162 of file UrdfTraverser.cpp.
bool UrdfTraverser::loadModelFromFile | ( | const std::string & | urdfFilename | ) |
Loads the URDF model from file
Definition at line 352 of file UrdfTraverser.cpp.
bool UrdfTraverser::loadModelFromXMLString | ( | const std::string & | xmlString | ) |
Loads the URDF from a file
Definition at line 375 of file UrdfTraverser.cpp.
void UrdfTraverser::printJointNames | ( | const std::string & | fromLink | ) |
Loads the URDF from parameter server TODO: still need to re-activate this by also reading the urdf into field robot_urdf Prints the joint names. Can't be const in this version because of the use of a recursive method. Only joints *after* the given link are printed.
Definition at line 337 of file UrdfTraverser.cpp.
int urdf_traverser::UrdfTraverser::printLink | ( | RecursionParamsPtr & | p | ) | [private] |
printing a link, used by recursive printModel(). Supports FlagRecursionParamsPtr, if the flag is true it prints verbose.
bool UrdfTraverser::printModel | ( | const std::string & | fromLink, |
bool | verbose | ||
) |
Definition at line 63 of file UrdfTraverser.cpp.
bool UrdfTraverser::printModel | ( | bool | verbose | ) |
Definition at line 68 of file UrdfTraverser.cpp.
urdf_traverser::LinkConstPtr UrdfTraverser::readChildLink | ( | const JointConstPtr & | joint | ) | const |
Definition at line 139 of file UrdfTraverser.cpp.
urdf_traverser::JointConstPtr UrdfTraverser::readJoint | ( | const std::string & | name | ) | const |
Definition at line 328 of file UrdfTraverser.cpp.
urdf_traverser::LinkConstPtr UrdfTraverser::readLink | ( | const std::string & | name | ) | const |
Definition at line 313 of file UrdfTraverser.cpp.
ModelConstPtr urdf_traverser::UrdfTraverser::readModel | ( | ) | const [inline] |
Definition at line 184 of file UrdfTraverser.h.
urdf_traverser::JointConstPtr UrdfTraverser::readParentJoint | ( | const JointConstPtr & | joint | ) | const |
Definition at line 153 of file UrdfTraverser.cpp.
void urdf_traverser::UrdfTraverser::setModelDirectory | ( | const std::string & | dir | ) | [inline] |
Set the directory which is considered the base of all mesh and texture files. When loading the model URDF from file, this directory is automatically set to the directory in which the URDF file resides. However if other files referenced from the URDF don't share this same base directory, use this function to override this.
Definition at line 104 of file UrdfTraverser.h.
int UrdfTraverser::traverseTreeBottomUp | ( | const std::string & | linkName, |
boost::function< int(RecursionParamsPtr &)> | link_cb, | ||
RecursionParamsPtr & | params, | ||
bool | includeLink = true |
||
) |
Similar to traverseTreeTopDown(), but traverses bottom-up and is allows to re-link tree (by traversing it safely such that changes in structure won't matter).
includeLink | include the link itself. If false, will start to traverse starting from the link's children. |
link_cb | Callback to be called when traversing a link. returns -1 or 0 if traversal is to be stopped, otherwise 1. -1 is for stop because of an error, while 0 is stop because an expected condition found and traversal has been stopped with no error. |
Definition at line 231 of file UrdfTraverser.cpp.
int UrdfTraverser::traverseTreeBottomUp | ( | const LinkPtr & | link, |
boost::function< int(RecursionParamsPtr &)> | link_cb, | ||
RecursionParamsPtr & | params, | ||
bool | includeLink = true , |
||
unsigned int | level = 0 |
||
) | [protected] |
Main recursive bottom-up traversal method, called from other traverseTreeBottomUp().
Definition at line 245 of file UrdfTraverser.cpp.
int UrdfTraverser::traverseTreeTopDown | ( | const std::string & | linkName, |
boost::function< int(RecursionParamsPtr &)> | link_cb, | ||
RecursionParamsPtr & | params, | ||
bool | includeLink = true |
||
) |
Traverses the tree starting from link (depth first) and calls link_cb on each link.
includeLink | include the link itself. If false, will start to traverse starting from the link's children. |
link_cb | Callback to be called when traversing a link. returns -1 or 0 if traversal is to be stopped, otherwise 1. -1 is for stop because of an error, while 0 is stop because an expected condition found and traversal has been stopped with no error. |
Definition at line 173 of file UrdfTraverser.cpp.
int UrdfTraverser::traverseTreeTopDown | ( | const LinkPtr & | link, |
boost::function< int(RecursionParamsPtr &)> | link_cb, | ||
RecursionParamsPtr & | params, | ||
bool | includeLink = true , |
||
unsigned int | level = 0 |
||
) | [protected] |
Main recursive top-down traversal method, called from other traverseTreeTopDown().
Definition at line 185 of file UrdfTraverser.cpp.
ModelPtr urdf_traverser::UrdfTraverser::model [private] |
Definition at line 246 of file UrdfTraverser.h.
std::string urdf_traverser::UrdfTraverser::modelDir [private] |
The directory which is considered the base of all mesh and texture files of the model
Definition at line 252 of file UrdfTraverser.h.