Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef BASIC_KIN_H
00021 #define BASIC_KIN_H
00022
00023 #include <vector>
00024 #include <string>
00025 #include <boost/scoped_ptr.hpp>
00026 #include <Eigen/Core>
00027 #include <Eigen/Geometry>
00028 #include <kdl/tree.hpp>
00029 #include <kdl/chain.hpp>
00030 #include <kdl/chainfksolverpos_recursive.hpp>
00031 #include <kdl/chainjnttojacsolver.hpp>
00032 #include <urdf/model.h>
00033
00034 namespace constrained_ik
00035 {
00036 namespace basic_kin
00037 {
00038
00044 class BasicKin
00045 {
00046 public:
00047 BasicKin() : initialized_(false) {};
00048 ~BasicKin() {};
00049
00055 bool calcFwdKin(const Eigen::VectorXd &joint_angles, Eigen::Affine3d &pose) const;
00056
00057
00066 bool calcFwdKin(const Eigen::VectorXd &joint_angles,
00067 const std::string &base,
00068 const std::string &tip,
00069 KDL::Frame &pose);
00070
00076 bool calcJacobian(const Eigen::VectorXd &joint_angles, Eigen::MatrixXd &jacobian) const;
00077
00081 bool checkInitialized() const { return initialized_; }
00082
00083
00088 bool checkJoints(const Eigen::VectorXd &vec) const;
00089
00090
00095 bool getJointNames(std::vector<std::string> &names) const;
00096
00097
00104
00105
00109 Eigen::MatrixXd getLimits() const { return joint_limits_; }
00110
00111
00116 bool getLinkNames(std::vector<std::string> &names) const;
00117
00118
00125
00126
00134 bool init(const urdf::Model &robot, const std::string &base_name, const std::string &tip_name);
00135
00139 unsigned int numJoints() const { return robot_chain_.getNrOfJoints(); }
00140
00148 bool linkTransforms(const Eigen::VectorXd &joint_angles,
00149 std::vector<KDL::Frame> &poses,
00150 const std::vector<std::string> &link_names = std::vector<std::string>()) const;
00151
00152
00157 BasicKin& operator=(const BasicKin& rhs);
00158
00166 bool solvePInv(const Eigen::MatrixXd &A, const Eigen::VectorXd &b, Eigen::VectorXd &x) const;
00167
00168 private:
00169 bool initialized_;
00170 KDL::Chain robot_chain_;
00171 KDL::Tree kdl_tree_;
00172 std::vector<std::string> joint_list_, link_list_;
00173 Eigen::Matrix<double, Eigen::Dynamic, 2> joint_limits_;
00174 boost::scoped_ptr<KDL::ChainFkSolverPos_recursive> fk_solver_, subchain_fk_solver_;
00175 boost::scoped_ptr<KDL::ChainJntToJacSolver> jac_solver_;
00176
00181 static void EigenToKDL(const Eigen::VectorXd &vec, KDL::JntArray &joints) {joints.data = vec;};
00182
00187 int getJointNum(const std::string &joint_name) const;
00188
00193 int getLinkNum(const std::string &link_name) const;
00194
00199 static void KDLToEigen(const KDL::Frame &frame, Eigen::Affine3d &transform);
00200
00205 static void KDLToEigen(const KDL::Jacobian &jacobian, Eigen::MatrixXd &matrix);
00206
00207 };
00208
00209 }
00210 }
00211
00212
00213 #endif // BASIC_KIN_H
00214