chainfksolverpos_recursive.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /** \file itasc/kdl/chainfksolverpos_recursive.cpp
  2. * \ingroup itasc
  3. */
  4. // Copyright (C) 2007 Francois Cauwe <francois at cauwe dot org>
  5. // Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
  6. // Version: 1.0
  7. // Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
  8. // Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
  9. // URL: http://www.orocos.org/kdl
  10. // This library is free software; you can redistribute it and/or
  11. // modify it under the terms of the GNU Lesser General Public
  12. // License as published by the Free Software Foundation; either
  13. // version 2.1 of the License, or (at your option) any later version.
  14. // This library is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. // Lesser General Public License for more details.
  18. // You should have received a copy of the GNU Lesser General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. #include "chainfksolverpos_recursive.hpp"
  22. #include <iostream>
  23. namespace KDL {
  24. ChainFkSolverPos_recursive::ChainFkSolverPos_recursive(const Chain& _chain):
  25. chain(_chain)
  26. {
  27. }
  28. int ChainFkSolverPos_recursive::JntToCart(const JntArray& q_in, Frame& p_out, int segmentNr)
  29. {
  30. unsigned int segNr = (unsigned int)segmentNr;
  31. if(segmentNr<0)
  32. segNr=chain.getNrOfSegments();
  33. p_out = Frame::Identity();
  34. if(q_in.rows()!=chain.getNrOfJoints())
  35. return -1;
  36. else if(segNr>chain.getNrOfSegments())
  37. return -1;
  38. else{
  39. int j=0;
  40. for(unsigned int i=0;i<segNr;i++){
  41. p_out = p_out*chain.getSegment(i).pose(((JntArray&)q_in)(j));
  42. j+=chain.getSegment(i).getJoint().getNDof();
  43. }
  44. return 0;
  45. }
  46. }
  47. ChainFkSolverPos_recursive::~ChainFkSolverPos_recursive()
  48. {
  49. }
  50. }