Blender V2.61 - r43446

chainfksolverpos_recursive.cpp

Go to the documentation of this file.
00001 
00004 // Copyright  (C)  2007  Francois Cauwe <francois at cauwe dot org>
00005 // Copyright  (C)  2007  Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
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 "chainfksolverpos_recursive.hpp"
00027 #include <iostream>
00028 
00029 namespace KDL {
00030 
00031     ChainFkSolverPos_recursive::ChainFkSolverPos_recursive(const Chain& _chain):
00032         chain(_chain)
00033     {
00034     }
00035 
00036     int ChainFkSolverPos_recursive::JntToCart(const JntArray& q_in, Frame& p_out, int segmentNr)
00037     {
00038         unsigned int segNr = (unsigned int)segmentNr;
00039         if(segmentNr<0)
00040              segNr=chain.getNrOfSegments();
00041 
00042         p_out = Frame::Identity();
00043 
00044         if(q_in.rows()!=chain.getNrOfJoints())
00045             return -1;
00046         else if(segNr>chain.getNrOfSegments())
00047             return -1;
00048         else{
00049             int j=0;
00050             for(unsigned int i=0;i<segNr;i++){
00051                 p_out = p_out*chain.getSegment(i).pose(((JntArray&)q_in)(j));
00052                 j+=chain.getSegment(i).getJoint().getNDof();
00053             }
00054             return 0;
00055         }
00056     }
00057 
00058 
00059     ChainFkSolverPos_recursive::~ChainFkSolverPos_recursive()
00060     {
00061     }
00062 
00063 
00064 }