UrdfTraverser.h
Go to the documentation of this file.
00001 
00031 #ifndef URDF_TRAVERSER_URDFTRAVERSER_H
00032 #define URDF_TRAVERSER_URDFTRAVERSER_H
00033 // Copyright Jennifer Buehler
00034 
00035 //-----------------------------------------------------
00036 
00037 
00038 #include <urdf_traverser/Types.h>
00039 #include <urdf_traverser/RecursionParams.h>
00040 
00041 #include <iostream>
00042 #include <string>
00043 #include <map>
00044 #include <vector>
00045 
00046 #define BOOST_NO_CXX11_SCOPED_ENUMS
00047 #include <boost/filesystem.hpp>
00048 #undef BOOST_NO_CXX11_SCOPED_ENUMS
00049 
00050 
00051 namespace urdf_traverser
00052 {
00053 
00066 class UrdfTraverser
00067 {
00068 public:
00069 
00072     explicit UrdfTraverser():
00073         model(new urdf::Model())
00074     {}
00075 
00076     ~UrdfTraverser()
00077     {
00078     }
00079 
00084     bool getModelFromFile(const std::string& urdfFilename, std::string& xml_string) const;
00085 
00089     bool loadModelFromFile(const std::string& urdfFilename);
00090 
00094     bool loadModelFromXMLString(const std::string& xmlString);
00095 
00104     inline void setModelDirectory(const std::string& dir)
00105     {
00106         // make sure this is an absolute canonical path
00107         boost::filesystem::path _dir(dir);
00108         boost::filesystem::path _absDir = boost::filesystem::canonical(_dir);
00109         modelDir = _absDir.string();
00110     }
00111     inline std::string getModelDirectory() const
00112     {
00113         return modelDir;
00114     }
00115 
00121     //bool loadModelFromParameterServer();
00122 
00128     void printJointNames(const std::string& fromLink);
00129 
00130     std::string getRootLinkName() const;
00131 
00132     std::string getModelName() const
00133     {
00134         return this->model->getName();
00135     }
00136 
00137     bool printModel(const std::string& fromLink, bool verbose);
00138 
00139     bool printModel(bool verbose);
00140 
00141 
00150     int traverseTreeTopDown(const std::string& linkName, boost::function< int(RecursionParamsPtr&)> link_cb,
00151                             RecursionParamsPtr& params, bool includeLink = true);
00163     int traverseTreeBottomUp(const std::string& linkName,
00164                              boost::function< int(RecursionParamsPtr&)> link_cb,
00165                              RecursionParamsPtr& params, bool includeLink = true);
00166 
00167 
00168     JointPtr getJoint(const std::string& name);
00169     JointConstPtr readJoint(const std::string& name) const;
00170     LinkPtr getLink(const std::string& name);
00171     LinkConstPtr readLink(const std::string& name) const;
00172 
00173     LinkPtr getChildLink(const JointConstPtr& joint);
00174     LinkConstPtr readChildLink(const JointConstPtr& joint) const;
00175 
00176     JointPtr getParentJoint(const JointConstPtr& joint);
00177     JointConstPtr readParentJoint(const JointConstPtr& joint) const;
00178 
00179 
00180     ModelPtr getModel()
00181     {
00182         return model;
00183     }
00184     ModelConstPtr readModel() const
00185     {
00186         return model;
00187     }
00188 
00193     bool getJointNames(const std::string& fromLink,
00194                        const bool skipFixed, std::vector<std::string>& result);
00195 
00196 
00197 protected:
00198 
00203     bool getDependencyOrderedJoints(std::vector<JointPtr>& result, const JointPtr& from_joint,
00204                                     bool allowSplits = true, bool onlyActive = true);
00205 
00210     bool getDependencyOrderedJoints(std::vector<JointPtr>& result, const LinkPtr& from_link,
00211                                     bool allowSplits = true, bool onlyActive = true);
00212 
00219     int getChildJoint(const JointPtr& joint, JointPtr& child);
00220 
00224     int traverseTreeTopDown(const LinkPtr& link, boost::function< int(RecursionParamsPtr&)> link_cb,
00225                             RecursionParamsPtr& params, bool includeLink = true, unsigned int level = 0);
00226 
00230     int traverseTreeBottomUp(const LinkPtr& link, boost::function<int(RecursionParamsPtr&)> link_cb,
00231                              RecursionParamsPtr& params, bool includeLink = true, unsigned int level = 0);
00232 
00233     bool hasChildLink(const LinkConstPtr& link, const std::string& childName) const;
00234 
00235 
00236     EigenTransform getTransform(const LinkPtr& from_link,  const JointPtr& to_joint);
00237 
00238 private:
00239 
00244     int printLink(RecursionParamsPtr& p);
00245 
00246     ModelPtr model;
00247 
00252     std::string modelDir;
00253 };
00254 
00255 }  //  namespace urdf_traverser
00256 #endif   // URDF_TRAVERSER_URDFTRAVERSER_H


urdf_traverser
Author(s): Jennifer Buehler
autogenerated on Fri Mar 1 2019 03:38:07