constrained_ik.h
Go to the documentation of this file.
00001 
00026 #ifndef CONSTRAINED_IK_H
00027 #define CONSTRAINED_IK_H
00028 
00029 #include "constrained_ik/basic_kin.h"
00030 #include "constraint_group.h"
00031 #include "solver_state.h"
00032 #include "constrained_ik/constrained_ik_utils.h"
00033 #include <string>
00034 #include <Eigen/Core>
00035 #include <Eigen/Geometry>
00036 #include <urdf/model.h>
00037 #include <constrained_ik/enum_types.h>
00038 #include <moveit/planning_scene/planning_scene.h>
00039 #include <constrained_ik/constraint_results.h>
00040 #include <pluginlib/class_loader.h>
00041 
00042 namespace constrained_ik
00043 {
00044 
00046 enum SolverStatus
00047 {
00048   Converged, 
00049   NotConverged, 
00050   Failed, 
00051 };
00052 
00057 class Constrained_IK
00058 {
00059 
00060 public:
00061   EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00062 
00063   Constrained_IK();
00064 
00072   virtual bool linkTransforms(const Eigen::VectorXd &joints,
00073                       std::vector<KDL::Frame> &poses,
00074                       const std::vector<std::string> link_names = std::vector<std::string>()) const
00075   {return kin_.linkTransforms(joints, poses, link_names);}
00076 
00082   virtual void addConstraint(Constraint* constraint, ConstraintTypes constraint_type)
00083   {
00084     switch(constraint_type)
00085     {
00086       case constraint_types::Primary:
00087         primary_constraints_.add(constraint);
00088         break;
00089       case constraint_types::Auxiliary:
00090         auxiliary_constraints_.add(constraint);
00091         break;
00092     }
00093   }
00094 
00102   virtual void addConstraintsFromParamServer(const std::string &parameter_name);
00103 
00111   virtual bool calcInvKin(const Eigen::Affine3d &goal,
00112                           const Eigen::VectorXd &joint_seed,
00113                           Eigen::VectorXd &joint_angles) const;
00114 
00115 
00125   virtual bool calcInvKin(const Eigen::Affine3d &goal,
00126                           const Eigen::VectorXd &joint_seed,
00127                           const planning_scene::PlanningSceneConstPtr planning_scene,
00128                           Eigen::VectorXd &joint_angles) const;
00129 
00134   virtual initialization_state::InitializationState checkInitialized() const
00135   {
00136     if (initialized_)
00137     {
00138       if (!primary_constraints_.empty() && !auxiliary_constraints_.empty())
00139       {
00140         return initialization_state::PrimaryAndAuxiliary;
00141       }
00142       else if (!primary_constraints_.empty() && auxiliary_constraints_.empty())
00143       {
00144         return initialization_state::PrimaryOnly;
00145       }
00146       else if (primary_constraints_.empty() && !auxiliary_constraints_.empty())
00147       {
00148         return initialization_state::AuxiliaryOnly;
00149       }
00150     }
00151     else
00152     {
00153       return initialization_state::NothingInitialized;
00154     }
00155   }
00156 
00158   virtual void clearConstraintList();
00159 
00165   virtual bool getJointNames(std::vector<std::string> &names) const {return kin_.getJointNames(names);}
00166 
00171   virtual inline const basic_kin::BasicKin& getKin() const {return kin_;}
00172 
00178   virtual bool getLinkNames(std::vector<std::string> &names) const {return kin_.getLinkNames(names);}
00179 
00184   virtual ConstrainedIKConfiguration getSolverConfiguration() const {return config_;}
00185 
00190   virtual void setSolverConfiguration(const ConstrainedIKConfiguration &config);
00191 
00193   virtual void loadDefaultSolverConfiguration();
00194 
00199   virtual void init(const basic_kin::BasicKin &kin);
00200 
00205   virtual unsigned int numJoints() const {return kin_.numJoints();}
00206 
00213   static double rangedAngle(double angle);
00214 
00220   virtual Eigen::MatrixXd calcNullspaceProjection(const Eigen::MatrixXd &J) const;
00221 
00227   virtual Eigen::MatrixXd calcNullspaceProjectionTheRightWay(const Eigen::MatrixXd &A) const;
00228 
00234   virtual Eigen::MatrixXd calcDampedPseudoinverse(const Eigen::MatrixXd &J) const;
00235 
00240   bool isInitialized() const { return initialized_; }
00241 
00242  protected:
00243   // solver configuration parameters
00244   ros::NodeHandle nh_;                
00245   ConstrainedIKConfiguration config_; 
00247   // constraints
00248   ConstraintGroup primary_constraints_;   
00249   ConstraintGroup auxiliary_constraints_; 
00251   // state/counter data
00252   bool initialized_;        
00253   basic_kin::BasicKin kin_; 
00261   virtual constrained_ik::ConstraintResults evalConstraint(constraint_types::ConstraintTypes constraint_type, const constrained_ik::SolverState &state) const;
00262 
00267   virtual void clipToJointLimits(Eigen::VectorXd &joints) const;
00268 
00277   virtual SolverStatus checkStatus(const constrained_ik::SolverState &state, const constrained_ik::ConstraintResults &primary, const constrained_ik::ConstraintResults &auxiliary) const;
00278 
00285   virtual constrained_ik::SolverState getState(const Eigen::Affine3d &goal, const Eigen::VectorXd &joint_seed) const;
00286 
00293   virtual void updateState(constrained_ik::SolverState &state, const Eigen::VectorXd &joints) const;
00294 
00295 }; // class Constrained_IK
00296 
00297 } // namespace constrained_ik
00298 
00299 typedef constrained_ik::SolverStatus SolverStatus; 
00300 #endif // CONSTRAINED_IK_H
00301 


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