00001 /* 00002 * kdl_wrapper.h 00003 * 00004 * Created on: Nov 8, 2013 00005 * Author: Francisco Vina 00006 */ 00007 00008 /* Copyright (c) 2013, 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 #ifndef KDL_WRAPPER_H_ 00035 #define KDL_WRAPPER_H_ 00036 00037 #include <ros/ros.h> 00038 #include <kdl/tree.hpp> 00039 #include <kdl/kdl.hpp> 00040 #include <kdl/tree.hpp> 00041 #include <kdl/chain.hpp> 00042 //#include <kdl/chainiksolvervel_pinv.hpp> 00043 #include <kdl/chainiksolvervel_wdls.hpp> 00044 #include <kdl/chainjnttojacsolver.hpp> 00045 #include <kdl/chainfksolverpos_recursive.hpp> 00046 #include <kdl/chainfksolvervel_recursive.hpp> 00047 #include <kdl/chainfksolveracc_recursive.hpp> 00048 00049 class KDLWrapper{ 00050 public: 00051 00052 ros::NodeHandle n; 00053 KDL::ChainIkSolverVel_wdls *ik_solver_vel; 00054 KDL::ChainJntToJacSolver *jnt_jac_solver; 00055 KDL::ChainFkSolverPos *fk_solver_pos; 00056 KDL::ChainFkSolverVel *fk_solver_vel; 00057 KDL::ChainFkSolverAcc *fk_solver_acc; 00058 00059 KDLWrapper(); 00060 virtual ~KDLWrapper(); 00061 00062 00063 // initialize the KDL chain and the kinematic solvers 00064 // chain_root: ID of the root link of the kinematic chain 00065 // chain_tip: ID of the tip link of the kinematic chain 00066 // returns true if initialized correctly 00067 bool init(const std::string &chain_root, const std::string &chain_tip); 00068 00069 // returns true if the object was initialized correctly 00070 bool isInitialized(); 00071 00072 // returns the KDL chain 00073 KDL::Chain getKDLChain(); 00074 00075 private: 00076 00077 bool m_initialized; 00078 KDL::Chain m_chain; 00079 00080 bool getTreeFromURDF(KDL::Tree &tree); 00081 00082 00083 }; 00084 00085 #endif /* KDL_WRAPPER_H_ */