LinkTraverse.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * National Institute of Advanced Industrial Science and Technology (AIST)
00008  * General Robotix Inc. 
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


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:17