basic_kin.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (Apache License)
00003  *
00004  * Copyright (c) 2013, Southwest Research Institute
00005  *
00006  * Licensed under the Apache License, Version 2.0 (the "License");
00007  * you may not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  *
00010  *   http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
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   //TODO test
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   //TODO test
00088   bool checkJoints(const Eigen::VectorXd &vec) const;
00089 
00090   //TODO test
00095   bool getJointNames(std::vector<std::string> &names) const;
00096 
00097   //TODO test
00104 //  bool getJointNames(const KDL::Chain &chain, std::vector<std::string> &names) const;
00105 
00109   Eigen::MatrixXd getLimits() const { return joint_limits_; }
00110 
00111   //TODO test
00116   bool getLinkNames(std::vector<std::string> &names) const;
00117 
00118   //TODO test
00125 //  bool getLinkNames(const KDL::Chain &chain, std::vector<std::string> &names) const;
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   //TODO test
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 }; // class BasicKin
00208 
00209 } // namespace basic_kin
00210 } // namespace constrained_ik
00211 
00212 
00213 #endif // BASIC_KIN_H
00214 


constrained_ik
Author(s): Chris Lewis , Jeremy Zoss , Dan Solomon
autogenerated on Mon Oct 6 2014 00:52:26