Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

IKCalliope.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_IKCalliope_h_
00003 #define INCLUDED_IKCalliope_h_
00004 
00005 #include "Motion/IKSolver.h"
00006 
00007 #if defined(TGT_IS_CALLIOPE3) && defined(TGT_HAS_ARMS)
00008 
00009 class IKCalliope : public IKSolver {
00010 public:
00011   static const float EPSILON;
00012   //! constructor
00013   IKCalliope();
00014 
00015   using IKSolver::solve;
00016   using IKSolver::step;
00017 
00018   virtual bool solve(const Point& pEff, const Rotation& oriEff, KinematicJoint& j,
00019                      const Position& pTgt, float posPri, 
00020                      const Orientation& oriTgt, float oriPri) const;
00021 
00022   virtual StepResult_t step(const Point& pEff, const Rotation& oriEff, KinematicJoint& j,
00023                             const Position& pTgt, float pDist, float posPri, 
00024                             const Orientation& oriTgt, float oriDist, float oriPri) const;
00025   
00026   //! holds the class name, set via registration with the DeviceDriver registry
00027   static const std::string autoRegisterIKCalliope;
00028 
00029 };
00030 
00031 #elif defined(TGT_IS_CALLIOPE5) && defined(TGT_HAS_ARMS)
00032 
00033 //! Kinematics solver for the 5-DOF Calliope Arm
00034 class IKCalliope : public IKSolver {
00035 public:
00036   static const float EPSILON;
00037   //! constructor
00038   IKCalliope();
00039   
00040   using IKSolver::solve;
00041   using IKSolver::step;
00042   
00043   //! Perform IK
00044   virtual bool solve(const Point& pEff, const Rotation& oriEff, KinematicJoint& j, const Position& pTgt, float posPri, const Orientation& oriTgt, float oriPri) const;
00045   
00046   //! Carried over from other implementations
00047   virtual StepResult_t step(const Point& pEff, const Rotation& oriEff, KinematicJoint& j, const Position& pTgt, float pDist, float posPri, const Orientation& oriTgt, float oriDist, float oriPri) const;
00048   
00049 protected:
00050   //! Test if a side grasp is being requested
00051   static bool isSideGrasp(const Rotation &oriEff, const Orientation &oriTgt);
00052 
00053   //! Test if an overhead grasp is being requested
00054   static bool isOverheadGrasp(const Rotation &oriEff, const Orientation &oriTgt);
00055 
00056   //! Test if constraints are simple enough to solve analytically
00057   static bool analyticallySolvable(const Rotation &oriEff,
00058                                    const Position &pTgt, const Orientation &oriTgt);
00059 
00060   //! Provides fall back to the gradient solver if we can't solve analytically
00061   static bool gradientSolve(const Point& pEff, const Rotation& oriEff, KinematicJoint& j, 
00062                             const Position& pTgt, float posPri, const Orientation& oriTgt, float oriPri);
00063 
00064   //! Struct to enclose joint angles for 5-dof solution
00065   struct Solutions {
00066     Solutions() : angles(),noSols(),valid() {}
00067     fmat::Matrix<2,3> angles;
00068     int noSols;
00069     bool valid;
00070   };
00071   
00072   //! Attempt to find 3-link IK solution, for target point @a t, effector offset @a pEff, and preferred tool angle @a prefPhi
00073   /*! If a solution cannot be found, try ±1°, ±2°, ±3°, etc, until a valid solution is found.
00074    *  If no valid solution can be found for any angle, just point the effector toward the target. */
00075   Solutions closestThreeLinkIK(const fmat::Column<2>& t, bool posPri, float prefPhi, const fmat::Column<2>& delta) const;
00076   
00077   //! Reaches the arm straight out in the direction of the target.
00078   /*! For use in case we cannot reach the target point with any tool angle phi */
00079   Solutions pointToward(const fmat::Column<2>& target, bool posPri, float prefPhi) const;
00080   
00081   //! Determines whether the angles that we've solved for are valid
00082   /*! Basically, we're checking to see if any angles in either solution
00083    *  are outside of Calliope's joint limits. */
00084   Solutions validAngles(Solutions solutions) const;
00085   
00086   //! Performs 3-link IK.
00087   /*! Calls twoLinkIK, then populates solution struct with tool angle @a phi. */
00088   Solutions threeLinkIK(fmat::Column<2> t, float phi) const;
00089   
00090   //! Performs 2-link IK
00091   /*! Brings the base of the wrist to the target point @a t */
00092 
00093   fmat::Matrix<2,2> twoLinkIK(fmat::Column<2> t) const;
00094   
00095   //! Returns the index of the closest solution (0 or 1).
00096   /*! If there's only one solution, returns 0. */
00097   int closestSolution(KinematicJoint& j, Solutions s) const;
00098   
00099   //! Assures that the arm is in the given orientation
00100   /*! For use when we need to constrain orientation,
00101    *  and aren't concerned with position as much. */
00102   void assureOrientation(Solutions& s, float phi) const;
00103   
00104   //! holds the class name, set via registration with the DeviceDriver registry
00105   static const std::string autoRegisterIKCalliope;
00106   
00107   //! Length of backarm and forearm
00108   float L1, L2;
00109   
00110   //! Limits of rotation of Calliope's Arm Joints
00111   float jointLimits[3][2];
00112   
00113   //! Extra angle between the base and the gripper to be taken into account
00114   float qGripper;
00115   
00116   //! Extra angle between the base and the wrist rotate to be taken into account
00117   float qWristRot;
00118   
00119   //! qOffset of the ArmBaseOffset
00120   float qOffset;
00121   
00122   //! Transforms from the BaseFrame to the ArmBase
00123   fmat::Transform baseToArm;
00124   
00125   //! Rotation from BaseFrame to the ArmBase
00126   fmat::Quaternion baseToArmRot;
00127   
00128   //! Distance from the arm base to the shoulder position.
00129   float shoulderOffset;
00130 };
00131 
00132 #elif defined(TGT_IS_CALLIOPE2) && defined(TGT_HAS_ARMS)
00133 
00134 //! Kinematics solver for the 2-DOF Calliope Arm
00135 class IKCalliope : public IKSolver {
00136 public:
00137   static const float EPSILON;
00138   //! constructor
00139   IKCalliope();
00140   
00141   using IKSolver::solve;
00142   using IKSolver::step;
00143   
00144   virtual bool solve(const Point& pEff, const Rotation& oriEff, KinematicJoint& j,
00145                      const Position& pTgt, float posPri, 
00146                      const Orientation& oriTgt, float oriPri) const;
00147 
00148   virtual StepResult_t step(const Point& pEff, const Rotation& oriEff, KinematicJoint& j,
00149                             const Position& pTgt, float pDist, float posPri, 
00150                             const Orientation& oriTgt, float oriDist, float oriPri) const;
00151   
00152 private:
00153   //! holds the class name, set via registration with the DeviceDriver registry
00154   static const std::string autoRegisterIKCalliope;
00155   
00156   //! cached transformation that converts points from the robot's base to the arm's base.
00157   fmat::Transform baseToArm;
00158   
00159   //! cached angle offset for arm base
00160   plist::Angle qOffset;
00161   
00162   //! cached offset for gripper
00163   plist::Angle gripperOffset;
00164   
00165   //! length of the forearm
00166   fmat::fmatReal forearmLength;
00167 };
00168 
00169 #  endif
00170 
00171 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:42 2016 by Doxygen 1.6.3