constrained_ik.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 CONSTRAINED_IK_H
00021 #define CONSTRAINED_IK_H
00022 
00023 #include "constrained_ik/basic_kin.h"
00024 #include "constraint_group.h"
00025 #include "solver_state.h"
00026 #include <string>
00027 #include <Eigen/Core>
00028 #include <Eigen/Geometry>
00029 #include <urdf/model.h>
00030 
00031 namespace constrained_ik
00032 {
00033 
00038 class Constrained_IK
00039 {
00040 
00041 public:
00042   Constrained_IK();
00043   virtual ~Constrained_IK() { }
00044 
00045   //TODO document
00046   bool linkTransforms(const Eigen::VectorXd &joints,
00047                       std::vector<KDL::Frame> &poses,
00048                       const std::vector<std::string> link_names = std::vector<std::string>()) const
00049   {return kin_.linkTransforms(joints, poses, link_names);};
00050 
00054   virtual void addConstraint(Constraint* constraint) { constraints_.add(constraint); }
00055 
00056   //TODO document
00057   virtual void calcInvKin(const Eigen::Affine3d &pose, const Eigen::VectorXd &joint_seed, Eigen::VectorXd &joint_angles);
00058 
00062   bool checkInitialized() const { return initialized_ && !constraints_.empty(); }
00063 
00066   void clearConstraintList();
00067 
00072   bool getJointNames(std::vector<std::string> &names) const {return kin_.getJointNames(names);};
00073 
00077   inline double getJointUpdateGain() const {return joint_update_gain_;};
00078 
00083   inline double getJtCnvTolerance() const {return joint_convergence_tol_;};
00084 
00088   inline const basic_kin::BasicKin& getKin() const {return kin_;}
00089 
00094   bool getLinkNames(std::vector<std::string> &names) const {return kin_.getLinkNames(names);};
00095 
00099   inline unsigned int getMaxIter() const {return max_iter_;};
00100 
00104   inline const SolverState& getState() const { return state_; }
00105 
00111   void init(const urdf::Model &robot, const std::string &base_name, const std::string &tip_name);
00112 
00116   virtual void init(const basic_kin::BasicKin &kin);
00117 
00121   unsigned int numJoints() const {return kin_.numJoints();};
00122 
00127   static double rangedAngle(double angle);
00128 
00132   inline void setJointUpdateGain(const double gain) {joint_update_gain_ = gain;};
00133 
00137   inline void setJtCnvTolerance(const double jt_cnv_tol) {joint_convergence_tol_ = jt_cnv_tol;};
00138 
00142   inline void setMaxIter(const unsigned int max_iter) {max_iter_ = max_iter;};
00143 
00144 protected:
00145   // gains and scaling factors
00146   double joint_update_gain_;
00147 
00148   // termination-criteria limits / tolerances
00149   unsigned int max_iter_;
00150   double joint_convergence_tol_;
00151 
00152   // constraints
00153   ConstraintGroup constraints_;
00154 
00155   // state/counter data
00156   bool initialized_;
00157   SolverState state_;
00158   basic_kin::BasicKin kin_;
00159 
00160   bool debug_;
00161   std::vector<Eigen::VectorXd> iteration_path_;
00162 
00166   virtual Eigen::VectorXd calcConstraintError();
00167 
00171   virtual Eigen::MatrixXd calcConstraintJacobian();
00172 
00173   //TODO document
00174   void clipToJointLimits(Eigen::VectorXd &joints);
00175 
00176   //TODO document
00177   virtual bool checkStatus() const;
00178 
00179   //TODO document
00180   virtual void reset(const Eigen::Affine3d &goal, const Eigen::VectorXd &joint_seed);
00181 
00182   //TODO document
00183   virtual void update(const Eigen::VectorXd &joints);
00184 
00185 }; // class Constrained_IK
00186 
00187 } // namespace constrained_ik
00188 
00189 #endif // CONSTRAINED_IK_H
00190 


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