basic_kin.h
Go to the documentation of this file.
00001 
00028 #ifndef BASIC_KIN_H
00029 #define BASIC_KIN_H
00030 
00031 #include <vector>
00032 #include <string>
00033 #include <boost/scoped_ptr.hpp>
00034 #include <Eigen/Core>
00035 #include <Eigen/Geometry>
00036 #include <kdl/tree.hpp>
00037 #include <kdl/chain.hpp>
00038 #include <kdl/chainfksolverpos_recursive.hpp>
00039 #include <kdl/chainjnttojacsolver.hpp>
00040 #include <moveit/robot_model/joint_model_group.h>
00041 
00042 namespace constrained_ik
00043 {
00044 namespace basic_kin
00045 {
00046 
00053 class BasicKin
00054 {
00055 public:
00056   EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00057 
00058   BasicKin() :
00059     initialized_(false),
00060     group_(NULL)
00061   {
00062 
00063   }
00064 
00071   bool calcFwdKin(const Eigen::VectorXd &joint_angles, Eigen::Affine3d &pose) const;
00072 
00073   //TODO test
00083   bool calcFwdKin(const Eigen::VectorXd &joint_angles,
00084                   const std::string &base,
00085                   const std::string &tip,
00086                   KDL::Frame &pose) const;
00087 
00094   bool calcJacobian(const Eigen::VectorXd &joint_angles, Eigen::MatrixXd &jacobian) const;
00095 
00100   bool checkInitialized() const { return initialized_; }
00101 
00102   //TODO test
00108   bool checkJoints(const Eigen::VectorXd &vec) const;
00109 
00110   //TODO test
00116   bool getJointNames(std::vector<std::string> &names) const;
00117 
00122   Eigen::MatrixXd getLimits() const { return joint_limits_; }
00123 
00124   //TODO test
00130   bool getLinkNames(std::vector<std::string> &names) const;
00131 
00138   bool init(const moveit::core::JointModelGroup* group);
00139 
00144   const moveit::core::JointModelGroup* getJointModelGroup() const {return group_;}
00145 
00150   unsigned int numJoints() const { return robot_chain_.getNrOfJoints(); }
00151 
00158   bool getSubChain(const std::string link_name, KDL::Chain &chain) const;
00159 
00168   bool linkTransforms(const Eigen::VectorXd &joint_angles,
00169                       std::vector<KDL::Frame> &poses,
00170                       const std::vector<std::string> &link_names = std::vector<std::string>()) const;
00171 
00176   std::string getRobotBaseLinkName() const { return base_name_; }
00177 
00182   std::string getRobotTipLinkName() const { return tip_name_; }
00183 
00189   BasicKin& operator=(const BasicKin& rhs);
00190 
00199   bool solvePInv(const Eigen::MatrixXd &A, const Eigen::VectorXd &b, Eigen::VectorXd &x) const;
00200 
00210 static  bool dampedPInv(const Eigen::MatrixXd &A, Eigen::MatrixXd &P, const double eps = 0.011, const double lambda = 0.01);
00211 
00217 static void KDLToEigen(const KDL::Frame &frame, Eigen::Affine3d &transform);
00218 
00224 static void KDLToEigen(const KDL::Jacobian &jacobian, Eigen::MatrixXd &matrix);
00225 
00231 static void EigenToKDL(const Eigen::VectorXd &vec, KDL::JntArray &joints) {joints.data = vec;}
00232 
00233 private:
00234   bool initialized_;                                             
00235   const moveit::core::JointModelGroup* group_;                   
00236   KDL::Chain  robot_chain_;                                      
00237   KDL::Tree   kdl_tree_;                                         
00238   std::string base_name_;                                        
00239   std::string tip_name_;                                         
00240   std::vector<std::string> joint_list_;                          
00241   std::vector<std::string> link_list_;                           
00242   Eigen::Matrix<double, Eigen::Dynamic, 2> joint_limits_;        
00243   boost::scoped_ptr<KDL::ChainFkSolverPos_recursive> fk_solver_; 
00244   boost::scoped_ptr<KDL::ChainJntToJacSolver> jac_solver_;       
00251   int getJointNum(const std::string &joint_name) const;
00252 
00258   int getLinkNum(const std::string &link_name) const;
00259 
00260 }; // class BasicKin
00261 
00262 } // namespace basic_kin
00263 } // namespace constrained_ik
00264 
00265 
00266 #endif // BASIC_KIN_H
00267 


constrained_ik
Author(s): Chris Lewis , Jeremy Zoss , Dan Solomon
autogenerated on Sat Jun 8 2019 19:23:45