chainfksolveracc_recursive.cpp
Go to the documentation of this file.
00001 /*
00002  * chainfksolveracc_recursive.cpp
00003  *
00004  *  Created on: Sep 14, 2012
00005  *      Author: Francisco Vina
00006  */
00007 
00008 /* Copyright (c) 2012, Francisco Vina, CVAP, KTH
00009    All rights reserved.
00010 
00011    Redistribution and use in source and binary forms, with or without
00012    modification, are permitted provided that the following conditions are met:
00013       * Redistributions of source code must retain the above copyright
00014         notice, this list of conditions and the following disclaimer.
00015       * Redistributions in binary form must reproduce the above copyright
00016         notice, this list of conditions and the following disclaimer in the
00017         documentation and/or other materials provided with the distribution.
00018       * Neither the name of KTH nor the
00019         names of its contributors may be used to endorse or promote products
00020         derived from this software without specific prior written permission.
00021 
00022    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00023    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00024    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00025    DISCLAIMED. IN NO EVENT SHALL KTH BE LIABLE FOR ANY
00026    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00027    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00029    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00030    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00031    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032 */
00033 
00034 #include <kdl/chainfksolveracc_recursive.hpp>
00035 
00036 namespace KDL {
00037 
00038 ChainFkSolverAcc_recursive::ChainFkSolverAcc_recursive(const Chain &_chain): chain(_chain)
00039 {
00040 
00041 }
00042 
00043 ChainFkSolverAcc_recursive::~ChainFkSolverAcc_recursive()
00044 {
00045 
00046 }
00047 
00048 ChainFkSolverAcc::~ChainFkSolverAcc()
00049 {
00050 }
00051 
00052 
00053 int ChainFkSolverAcc_recursive::JntToCart(const JntArrayAcc &in, FrameAcc &out, int segmentNr)
00054 {
00055 
00056         if(segmentNr<0)
00057                 segmentNr=chain.getNrOfSegments();
00058 
00059         out=FrameAcc::Identity();
00060 
00061         if(!(in.q.rows()==chain.getNrOfJoints()&&in.qdot.rows()==chain.getNrOfJoints()))
00062                 return -1;
00063         else if(segmentNr>chain.getNrOfSegments())
00064                 return -1;
00065         else
00066         {
00067                 int j=0;
00068                 for (unsigned int i=0;i<segmentNr;i++)
00069                 {
00070                         //Calculate new Frame_base_ee
00071                         if(chain.getSegment(i).getJoint().getType()!=Joint::None){
00072                                 out=out*FrameAcc(chain.getSegment(i).pose(in.q(j)),
00073                                                 chain.getSegment(i).twist(in.q(j),in.qdot(j)),
00074                                                 SegmentGetTwistAcc(chain.getSegment(i), in.q(j), in.qdot(j), in.qdotdot(j)));
00075                                 j++;//Only increase jointnr if the segment has a joint
00076                         }else{
00077                                 out=out*FrameAcc(chain.getSegment(i).pose(0.0),
00078                                                 chain.getSegment(i).twist(0.0,0.0),
00079                                                 Twist::Zero());
00080                         }
00081                 }
00082                 return 0;
00083         }
00084 }
00085 
00086 
00087 Twist ChainFkSolverAcc_recursive::SegmentGetTwistAcc(const Segment &s, const double &q,const double &qdot, const double &qdotdot) const
00088 {
00089         Twist out;
00090         Joint joint = s.getJoint();
00091         Frame f_tip = s.getFrameToTip();
00092         Twist t1 = (joint.twist(qdotdot).RefPoint(joint.pose(q).M * f_tip.p));
00093         Twist t2 = (joint.twist(qdot).RefPoint(joint.pose(q).M * f_tip.p));
00094         Twist t3 = (joint.twist(qdot).RefPoint(t2.vel));
00095 
00096         out.rot = t1.rot;
00097         out.vel = t1.vel+t3.vel;
00098 
00099         return out;
00100 }
00101 
00102 
00103 } /* namespace KDL */


kdl_acc_solver
Author(s): Francisco Vina
autogenerated on Wed Aug 26 2015 12:11:50