00001 /* 00002 * Stanford Whole-Body Control Framework http://stanford-wbc.sourceforge.net/ 00003 * 00004 * Copyright (C) 2009 The Board of Trustees of The Leland Stanford Junior University. All rights reserved. 00005 * 00006 * This program is free software: you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * as published by the Free Software Foundation, either version 3 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this program. If not, see 00018 * <http://www.gnu.org/licenses/> 00019 */ 00020 00026 #ifndef JSPACE_TAO_UTIL_H 00027 #define JSPACE_TAO_UTIL_H 00028 00029 #include <stdexcept> 00030 #include <string> 00031 #include <vector> 00032 #include <map> 00033 00034 00035 class taoNodeRoot; 00036 class taoDNode; 00037 class taoJoint; 00038 00039 00040 namespace jspace { 00041 00048 struct tao_node_info_s { 00049 tao_node_info_s(); 00050 tao_node_info_s(taoDNode * node, std::string const & link_name, 00051 std::string joint_name, double limit_lower, double limit_upper); 00052 tao_node_info_s(tao_node_info_s const & orig); 00053 00054 int id; 00055 taoDNode * node; 00056 taoJoint * joint; 00057 std::string link_name; 00058 std::string joint_name; 00059 double limit_lower; 00060 double limit_upper; 00061 }; 00062 00063 00064 struct tao_tree_info_s { 00065 tao_tree_info_s(); 00066 00068 virtual ~tao_tree_info_s(); 00069 00079 bool sort(); 00080 00081 taoNodeRoot * root; 00082 typedef std::vector<tao_node_info_s> node_info_t; 00083 node_info_t info; 00084 }; 00085 00086 00092 tao_tree_info_s * create_bare_tao_tree_info(taoNodeRoot * root); 00093 00094 00104 int tao_consistency_check( 00105 taoNodeRoot * root, 00109 std::ostream * msg); 00110 00111 00112 typedef std::map<int, taoDNode *> idToNodeMap_t; 00113 00121 void mapNodesToIDs(idToNodeMap_t & idToNodeMap, 00122 taoDNode * node) 00123 throw(std::runtime_error); 00124 00125 00133 int countNumberOfLinks(taoDNode * root); 00134 00135 00140 int countNumberOfJoints(taoDNode * node); 00141 00142 00147 int countDegreesOfFreedom(taoDNode * node); 00148 00149 00153 double computeTotalMass(taoDNode * node); 00154 00155 } 00156 00157 #endif // JSPACE_TAO_UTIL_H