Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

PlanarThreeLinkArm.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_PlanarThreeLinkArm_h_
00003 #define INCLUDED_PlanarThreeLinkArm_h_
00004 
00005 #include "Motion/IKSolver.h"
00006 #include "Shared/fmatCore.h"
00007 #include "Motion/Kinematics.h"
00008 #include "Shared/RobotInfo.h"
00009 
00010 //! Kinematics solver for an arm composed of three consecutive joints in the same plane
00011 class PlanarThreeLinkArm : public IKSolver {
00012 public:
00013   //! Constructor: use the last three links in the chain
00014   PlanarThreeLinkArm();
00015   
00016   //! Constructor: @offset specifies the first joint in the chain
00017   PlanarThreeLinkArm(unsigned int offset);
00018   
00019   using IKSolver::solve;
00020   using IKSolver::step;
00021   
00022   //! Solve to get an 'effector' (@a pEff, @a oriEff, relative to link following @a j) to a solution of @a pTgt, @a oriTgt (or at least a local minimum)
00023   /*! @a posPri and @a oriPri specify relative weighting of each solution in case they are mutually exclusive */
00024   virtual bool solve(const Point& pEff, const Rotation& oriEff, KinematicJoint& j, const Position& pTgt, float posPri, const Orientation& oriTgt, float oriPri) const;
00025   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; 
00026   
00027   struct Solutions {
00028     Solutions() : angles(),noSols(),valid() {}
00029     fmat::Matrix<2,3> angles; // double check all references to Solutions.angles
00030     //fmat::Matrix<3,2> angles;  // This is what is should be!
00031     int noSols;
00032     bool valid;
00033   };
00034   
00035   void PrintVariables() const;
00036   PlanarThreeLinkArm::Solutions solveWithOffset(float x, float y, float pref_phi, fmat::Column<3> baseOffset = fmat::pack(0.0f, 0.0f,1.0f)) const;
00037   PlanarThreeLinkArm::Solutions invKin3LinkRelaxPhi(float x, float y, float pref_phi) const;
00038   PlanarThreeLinkArm::Solutions nearConfig(PlanarThreeLinkArm::Solutions sol, float elbow, bool valid) const;
00039   PlanarThreeLinkArm::Solutions punt(float x, float y) const;
00040   PlanarThreeLinkArm::Solutions validAngles(PlanarThreeLinkArm::Solutions solutions) const;
00041   PlanarThreeLinkArm::Solutions invKin3Link(float x,float y,float phi) const;
00042   fmat::Matrix<2,2> invKin2Link(float x,float y,float link1,float link2) const;
00043   PlanarThreeLinkArm::Solutions invKin2Link(float x,float y) const;
00044   float angDist(float a1,float a2) const;
00045   float angNorm(float a) const;
00046   fmat::Matrix<2,2> rot(float t) const;
00047   //get Joint lengths 
00048   float getL1() const;
00049   float getL2() const;
00050   float getL3() const;
00051   //set Joint lengths
00052   void setL1(float length1, float jointMax, float jointMin);
00053   void setL2(float length2, float jointMax, float jointMin);
00054   void setL3(float length3, float jointMax, float jointMin);
00055   
00056 private:
00057   //! holds the class name, set via registration with the DeviceDriver registry
00058   static const std::string autoRegisterPlanarThreeLinkArm;
00059   float L1, L2, L3;
00060   float jointLimits[3][2];
00061 };
00062 
00063 #endif

Tekkotsu v5.1CVS
Generated Fri Mar 16 05:26:46 2012 by Doxygen 1.6.3