00001 /* 00002 * Stanford Whole-Body Control Framework http://stanford-wbc.sourceforge.net/ 00003 * 00004 * Copyright (C) 2010 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 #include "Controller.hpp" 00027 #include "Model.hpp" 00028 #include <tao/dynamics/taoDNode.h> 00029 #include <tao/dynamics/taoJoint.h> 00030 00031 namespace jspace { 00032 00033 00034 void jspace_controller_info_getter_s:: 00035 getDOFNames(Model const & model, std::vector<std::string> & names) const 00036 { 00037 int const njoints(model.getNJoints()); 00038 names.resize(njoints); 00039 for (int ii(0); ii < njoints; ++ii) { 00040 names[ii] = model.getJointName(ii); 00041 } 00042 } 00043 00044 00048 void jspace_controller_info_getter_s:: 00049 getDOFUnits(Model const & model, std::vector<std::string> & names) const 00050 { 00051 int const njoints(model.getNJoints()); 00052 names.resize(njoints); 00053 for (int ii(0); ii < njoints; ++ii) { 00054 taoDNode const * node(model.getNode(ii)); 00055 taoJoint const * joint(node->getJointList()); 00056 if (0 != dynamic_cast<taoJointRevolute const *>(joint)) { 00057 names[ii] = "rad"; 00058 } 00059 else if (0 != dynamic_cast<taoJointPrismatic const *>(joint)) { 00060 names[ii] = "m"; 00061 } 00062 else { 00063 names[ii] = "void"; 00064 } 00065 } 00066 } 00067 00068 00069 void jspace_controller_info_getter_s:: 00070 getGainNames(Model const & model, std::vector<std::string> & names) const 00071 { 00072 getDOFNames(model, names); 00073 } 00074 00075 00076 void jspace_controller_info_getter_s:: 00077 getLimits(Model const & model, Vector & limits_lower, Vector & limits_upper) const 00078 { 00079 model.getJointLimits(limits_lower, limits_upper); 00080 } 00081 00082 00083 Controller:: 00084 Controller() 00085 : info_getter_(0) 00086 { 00087 } 00088 00089 00090 Controller:: 00091 ~Controller() 00092 { 00093 delete info_getter_; 00094 } 00095 00096 00097 controller_info_getter_s const * Controller:: 00098 getInfo() const 00099 { 00100 if ( ! info_getter_) { 00101 info_getter_ = new jspace_controller_info_getter_s(); 00102 } 00103 return info_getter_; 00104 }; 00105 00106 }