Blender V2.61 - r43446
|
00001 00004 // Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be> 00005 // Copyright (C) 2008 Julia Jesse 00006 00007 // Version: 1.0 00008 // Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be> 00009 // Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be> 00010 // URL: http://www.orocos.org/kdl 00011 00012 // This library is free software; you can redistribute it and/or 00013 // modify it under the terms of the GNU Lesser General Public 00014 // License as published by the Free Software Foundation; either 00015 // version 2.1 of the License, or (at your option) any later version. 00016 00017 // This library is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 // Lesser General Public License for more details. 00021 00022 // You should have received a copy of the GNU Lesser General Public 00023 // License along with this library; if not, write to the Free Software 00024 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00025 00026 #include "treefksolverpos_recursive.hpp" 00027 #include <iostream> 00028 00029 namespace KDL { 00030 00031 TreeFkSolverPos_recursive::TreeFkSolverPos_recursive(const Tree& _tree): 00032 tree(_tree) 00033 { 00034 } 00035 00036 int TreeFkSolverPos_recursive::JntToCart(const JntArray& q_in, Frame& p_out, const std::string& segmentName, const std::string& baseName) 00037 { 00038 SegmentMap::const_iterator it = tree.getSegment(segmentName); 00039 SegmentMap::const_iterator baseit = tree.getSegment(baseName); 00040 00041 if(q_in.rows() != tree.getNrOfJoints()) 00042 return -1; 00043 else if(it == tree.getSegments().end()) //if the segment name is not found 00044 return -2; 00045 else if(baseit == tree.getSegments().end()) //if the base segment name is not found 00046 return -3; 00047 else{ 00048 p_out = recursiveFk(q_in, it, baseit); 00049 return 0; 00050 } 00051 } 00052 00053 Frame TreeFkSolverPos_recursive::recursiveFk(const JntArray& q_in, const SegmentMap::const_iterator& it, const SegmentMap::const_iterator& baseit) 00054 { 00055 //gets the frame for the current element (segment) 00056 const TreeElement& currentElement = it->second; 00057 00058 if(it == baseit){ 00059 return KDL::Frame::Identity(); 00060 } 00061 else{ 00062 Frame currentFrame = currentElement.segment.pose(((JntArray&)q_in)(currentElement.q_nr)); 00063 SegmentMap::const_iterator parentIt = currentElement.parent; 00064 return recursiveFk(q_in, parentIt, baseit) * currentFrame; 00065 } 00066 } 00067 00068 TreeFkSolverPos_recursive::~TreeFkSolverPos_recursive() 00069 { 00070 } 00071 00072 00073 }