00001
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
00011 class PlanarThreeLinkArm : public IKSolver {
00012 public:
00013
00014 PlanarThreeLinkArm();
00015
00016
00017 PlanarThreeLinkArm(unsigned int offset);
00018
00019 using IKSolver::solve;
00020 using IKSolver::step;
00021
00022
00023
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;
00030
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
00048 float getL1() const;
00049 float getL2() const;
00050 float getL3() const;
00051
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
00058 static const std::string autoRegisterPlanarThreeLinkArm;
00059 float L1, L2, L3;
00060 float jointLimits[3][2];
00061 };
00062
00063 #endif