chainiksolverpos_nr.cpp
Go to the documentation of this file.
00001 // Copyright  (C)  2007  Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
00002 
00003 // Version: 1.0
00004 // Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
00005 // Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
00006 // URL: http://www.orocos.org/kdl
00007 
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU Lesser General Public
00010 // License as published by the Free Software Foundation; either
00011 // version 2.1 of the License, or (at your option) any later version.
00012 
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 // Lesser General Public License for more details.
00017 
00018 // You should have received a copy of the GNU Lesser General Public
00019 // License along with this library; if not, write to the Free Software
00020 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00021 
00022 #include "chainiksolverpos_nr.hpp"
00023 
00024 namespace KDL
00025 {
00026     ChainIkSolverPos_NR::ChainIkSolverPos_NR(const Chain& _chain,ChainFkSolverPos& _fksolver,ChainIkSolverVel& _iksolver,
00027                                              unsigned int _maxiter, double _eps):
00028         chain(_chain),fksolver(_fksolver),iksolver(_iksolver),delta_q(_chain.getNrOfJoints()),
00029         maxiter(_maxiter),eps(_eps)
00030     {
00031     }
00032 
00033     int ChainIkSolverPos_NR::CartToJnt(const JntArray& q_init, const Frame& p_in, JntArray& q_out)
00034     {
00035             q_out = q_init;
00036 
00037             unsigned int i;
00038             for(i=0;i<maxiter;i++){
00039                 fksolver.JntToCart(q_out,f);
00040                 delta_twist = diff(f,p_in);
00041                 iksolver.CartToJnt(q_out,delta_twist,delta_q);
00042                 Add(q_out,delta_q,q_out);
00043                 if(Equal(delta_twist,Twist::Zero(),eps))
00044                     break;
00045             }
00046             if(i!=maxiter)
00047                 return 0;
00048             else
00049                 return -3;
00050     }
00051 
00052     ChainIkSolverPos_NR::~ChainIkSolverPos_NR()
00053     {
00054     }
00055 
00056 }
00057 


orocos_kdl
Author(s): Ruben Smits, Erwin Aertbelien, Orocos Developers
autogenerated on Sat Dec 28 2013 17:17:25