kdl_tl.hpp
Go to the documentation of this file.
00001 /********************************************************************************
00002 Copyright (c) 2015, TRACLabs, Inc.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without modification,
00006  are permitted provided that the following conditions are met:
00007 
00008     1. Redistributions of source code must retain the above copyright notice, 
00009        this list of conditions and the following disclaimer.
00010 
00011     2. Redistributions in binary form must reproduce the above copyright notice,
00012        this list of conditions and the following disclaimer in the documentation 
00013        and/or other materials provided with the distribution.
00014 
00015     3. Neither the name of the copyright holder nor the names of its contributors
00016        may be used to endorse or promote products derived from this software 
00017        without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
00021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00022 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
00023 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
00024 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00025 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00026 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
00027 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00028 OF THE POSSIBILITY OF SUCH DAMAGE.
00029 ********************************************************************************/
00030 
00031 
00032 #ifndef KDLCHAINIKSOLVERPOS_TL_HPP
00033 #define KDLCHAINIKSOLVERPOS_TL_HPP
00034 
00035 #include <kdl/chainfksolverpos_recursive.hpp>
00036 #include <kdl/chainiksolvervel_pinv.hpp>
00037 
00038 namespace TRAC_IK {
00039   class TRAC_IK;
00040 }
00041 
00042 namespace KDL {
00043 
00044   enum BasicJointType { RotJoint, TransJoint, Continuous };
00045 
00046   class ChainIkSolverPos_TL 
00047   {
00048     friend class TRAC_IK::TRAC_IK;
00049 
00050   public:
00051     ChainIkSolverPos_TL(const Chain& chain,const JntArray& q_min, const JntArray& q_max, double maxtime=0.005, double eps=1e-3, bool random_restart=false, bool try_jl_wrap=false);
00052 
00053     ~ChainIkSolverPos_TL();
00054 
00055     int CartToJnt(const KDL::JntArray& q_init, const KDL::Frame& p_in, KDL::JntArray& q_out, const KDL::Twist bounds=KDL::Twist::Zero());
00056 
00057     inline void setMaxtime(double t) { maxtime = t; }
00058       
00059   private:
00060     const Chain chain;
00061     JntArray q_min;
00062     JntArray q_max;
00063 
00064     KDL::Twist bounds;
00065 
00066     KDL::ChainIkSolverVel_pinv vik_solver;
00067     KDL::ChainFkSolverPos_recursive fksolver;
00068     JntArray delta_q;
00069     double maxtime;
00070 
00071     double eps;
00072     
00073     bool rr;
00074     bool wrap;
00075 
00076     std::vector<KDL::BasicJointType> types;
00077 
00078     inline void abort() {
00079       aborted = true;
00080     }
00081 
00082     inline void reset() {
00083       aborted = false;
00084     }
00085 
00086     bool aborted;
00087 
00088     Frame f;
00089     Twist delta_twist;
00090 
00091     inline static double fRand(double min, double max)
00092     {
00093       double f = (double)rand() / RAND_MAX;
00094       return min + f * (max - min);
00095     }
00096 
00097 
00098   };
00099 
00111   IMETHOD Twist diffRelative(const Frame & F_a_b1, const Frame & F_a_b2, double dt = 1)
00112   {
00113       return Twist(F_a_b1.M.Inverse() * diff(F_a_b1.p, F_a_b2.p, dt),
00114                    F_a_b1.M.Inverse() * diff(F_a_b1.M, F_a_b2.M, dt));
00115   }
00116 
00117 }
00118 
00119 #endif


trac_ik_lib
Author(s): Patrick Beeson, Barrett Ames
autogenerated on Thu Sep 21 2017 02:53:02