00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef ROBOT_MODEL_PARSER_H
00038 #define ROBOT_MODEL_PARSER_H
00039
00040 #include <string>
00041 #include <map>
00042 #include <tinyxml/tinyxml.h>
00043 #include <boost/function.hpp>
00044 #include "link.h"
00045
00046
00047 namespace urdf{
00048
00049
00050 class Model
00051 {
00052 public:
00053 Model();
00054
00056 bool initXml(TiXmlElement *xml);
00058 bool initXml(TiXmlDocument *xml);
00060 bool initFile(const std::string& filename);
00062 bool initParam(const std::string& param);
00064 bool initString(const std::string& xmlstring);
00065
00066 boost::shared_ptr<const Link> getRoot(void) const{return this->root_link_;};
00067 boost::shared_ptr<const Link> getLink(const std::string& name) const;
00068 boost::shared_ptr<const Joint> getJoint(const std::string& name) const;
00069 const std::string& getName() const {return name_;};
00070
00071 void getLinks(std::vector<boost::shared_ptr<Link> >& links) const;
00072
00074 boost::shared_ptr<const Link> getParentLink(const std::string& name) const;
00076 boost::shared_ptr<const Joint> getParentJoint(const std::string& name) const;
00078 boost::shared_ptr<const Link> getChildLink(const std::string& name) const;
00080 boost::shared_ptr<const Joint> getChildJoint(const std::string& name) const;
00081
00083 std::map<std::string, boost::shared_ptr<Link> > links_;
00085 std::map<std::string, boost::shared_ptr<Joint> > joints_;
00087 std::map<std::string, boost::shared_ptr<Material> > materials_;
00088
00089 private:
00090 void clear();
00091
00092 std::string name_;
00093
00095 void getLink(const std::string& name,boost::shared_ptr<Link> &link) const;
00096
00098 boost::shared_ptr<Material> getMaterial(const std::string& name) const;
00099
00102 bool initTree(std::map<std::string, std::string> &parent_link_tree);
00103
00106 bool initRoot(std::map<std::string, std::string> &parent_link_tree);
00107
00108
00113 boost::shared_ptr<Link> root_link_;
00114
00115 };
00116
00117 }
00118
00119 #endif