Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00017 #ifndef HRPMODEL_LINK_TRAVERSE_H_INCLUDED
00018 #define HRPMODEL_LINK_TRAVERSE_H_INCLUDED
00019
00020 #include <vector>
00021 #include <ostream>
00022 #include <hrpUtil/config.h>
00023 #include "Config.h"
00024
00025 namespace hrp {
00026
00027 class Link;
00028
00029 class HRPMODEL_API LinkTraverse
00030 {
00031 public:
00032 LinkTraverse();
00033 LinkTraverse(int size);
00034 LinkTraverse(Link* root, bool doUpward = false, bool doDownward = true);
00035
00036 virtual ~LinkTraverse();
00037
00038 virtual void find(Link* root, bool doUpward = false, bool doDownward = true);
00039
00040 inline unsigned int numLinks() const {
00041 return links.size();
00042 }
00043
00044 inline bool empty() const {
00045 return links.empty();
00046 }
00047
00048 inline size_t size() const {
00049 return links.size();
00050 }
00051
00052 inline Link* rootLink() const {
00053 return (links.empty() ? 0 : links.front());
00054 }
00055
00056 inline Link* link(int index) const {
00057 return links[index];
00058 }
00059
00060 inline Link* operator[] (int index) const {
00061 return links[index];
00062 }
00063
00064 inline std::vector<Link*>::const_iterator begin() const {
00065 return links.begin();
00066 }
00067
00068 inline std::vector<Link*>::const_iterator end() const {
00069 return links.end();
00070 }
00071
00077 inline bool isDownward(int index) const {
00078 return (index >= numUpwardConnections);
00079 }
00080
00081 void calcForwardKinematics(bool calcVelocity = false, bool calcAcceleration = false) const;
00082
00083 double calcTotalMass();
00084
00085 inline double totalMass() const {
00086 return totalMass_;
00087 }
00088
00089 protected:
00090
00091 std::vector<Link*> links;
00092 int numUpwardConnections;
00093 double totalMass_;
00094
00095 private:
00096
00097 void traverse(Link* link, bool doUpward, bool doDownward, bool isUpward, Link* prev);
00098
00099 };
00100
00101 };
00102
00103 HRPMODEL_API std::ostream& operator<<(std::ostream& os, hrp::LinkTraverse& traverse);
00104
00105 #endif