chainjnttojacsolver.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 "chainjnttojacsolver.hpp"
00023 
00024 namespace KDL
00025 {
00026     ChainJntToJacSolver::ChainJntToJacSolver(const Chain& _chain):
00027         chain(_chain),locked_joints_(chain.getNrOfJoints(),false)
00028     {
00029     }
00030 
00031     ChainJntToJacSolver::~ChainJntToJacSolver()
00032     {
00033     }
00034 
00035     int ChainJntToJacSolver::setLockedJoints(const std::vector<bool> locked_joints)
00036     {
00037         if(locked_joints.size()!=locked_joints_.size())
00038             return (error = E_SIZE_MISMATCH);
00039         locked_joints_=locked_joints;
00040         return (error = E_NOERROR);
00041     }
00042 
00043     int ChainJntToJacSolver::JntToJac(const JntArray& q_in, Jacobian& jac, int seg_nr)
00044     {
00045         unsigned int segmentNr;
00046         if(seg_nr<0)
00047             segmentNr=chain.getNrOfSegments();
00048         else
00049             segmentNr = seg_nr;
00050 
00051         //Initialize Jacobian to zero since only segmentNr colunns are computed
00052         SetToZero(jac) ;
00053 
00054         if( q_in.rows()!=chain.getNrOfJoints() || jac.columns() != chain.getNrOfJoints())
00055             return (error = E_SIZE_MISMATCH);
00056         else if(segmentNr>chain.getNrOfSegments())
00057             return (error = E_OUT_OF_RANGE);
00058 
00059         T_tmp = Frame::Identity();
00060         SetToZero(t_tmp);
00061         int j=0;
00062         int k=0;
00063         Frame total;
00064         for (unsigned int i=0;i<segmentNr;i++) {
00065             //Calculate new Frame_base_ee
00066             if(chain.getSegment(i).getJoint().getType()!=Joint::None){
00067                 //pose of the new end-point expressed in the base
00068                 total = T_tmp*chain.getSegment(i).pose(q_in(j));
00069                 //changing base of new segment's twist to base frame if it is not locked
00070                 //t_tmp = T_tmp.M*chain.getSegment(i).twist(1.0);
00071                 if(!locked_joints_[j])
00072                     t_tmp = T_tmp.M*chain.getSegment(i).twist(q_in(j),1.0);
00073             }else{
00074                 total = T_tmp*chain.getSegment(i).pose(0.0);
00075 
00076             }
00077 
00078             //Changing Refpoint of all columns to new ee
00079             changeRefPoint(jac,total.p-T_tmp.p,jac);
00080 
00081             //Only increase jointnr if the segment has a joint
00082             if(chain.getSegment(i).getJoint().getType()!=Joint::None){
00083                 //Only put the twist inside if it is not locked
00084                 if(!locked_joints_[j])
00085                     jac.setColumn(k++,t_tmp);
00086                 j++;
00087             }
00088 
00089             T_tmp = total;
00090         }
00091         return (error = E_NOERROR);
00092     }
00093 }
00094 


orocos_kdl
Author(s):
autogenerated on Sat Oct 7 2017 03:04:28