00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00067
00068 #define IKJacobian_hpp
00069
00070 #include "Math/HandPose.h"
00071 #include "Math/EqnSolver.h"
00072 #include "ForwardKinematics/FKJacobian.h"
00073 #include "InverseKinematics/IKVelocity.h"
00074
00076 namespace OSCAR {
00077
00078 class DHData;
00079
00093 template <class JacobianType=FKJacobian>
00094 class IKJacobian : public IKVelocity, IKPosition
00095 {
00096
00097 public:
00098
00121 IKJacobian(const JointVector& initialJointPosition,
00122 JacobianType* fkJacobian,
00123 OSCARError& err = DUMMY_ERROR(noError),
00124 EqnSolver* solver = 0, double maxError = 0.1,
00125 double rtScale = 1000.0);
00126
00133 IKJacobian(const IKJacobian& rhs);
00134
00142 IKJacobian& operator=(const IKJacobian& rhs);
00143
00149 virtual ~IKJacobian();
00150
00165 virtual bool GetJointPosition(const Xform& desiredHandMatrix, JointVector& jointPosition);
00166
00181 virtual bool GetJointPosition(const HandPose& desiredHand, JointVector& jointPosition);
00182
00195 virtual bool GetJointVelocity(const HandPose& handVelocity, JointVector& jointVelocitySolution);
00196
00206 virtual bool GetJointPosition(JointVector& jointPosition) const;
00207
00218 virtual bool SetJointPosition(const JointVector& jointPosition);
00219
00229 void SetMinimumMOT(double minMOT);
00230
00238 double GetMinimumMOT() const;
00239
00248 void SetMaximumIterations(unsigned int noIterations);
00249
00258 unsigned int GetMaximumIterations(void) const;
00259
00273 bool SetErrorTolerance(double maxErrorVal, double rotScale);
00274
00284 bool GetErrorTolerance(double& maxErrorVal, double& rotScale) const;
00285
00294 double GetSolutionProperties(void) const;
00295
00307 double GetSolutionProperties(unsigned int& iterationCount) const;
00308
00320 double GetSolutionProperties(double& errorMagnitude) const;
00321
00334 double GetSolutionProperties(Matrix& jacobian) const;
00335
00347 double GetSolutionProperties(Xform& currentHandPos) const;
00348
00349 protected:
00350
00351 unsigned int DOF;
00352 unsigned int maxIterations;
00353 unsigned int currentIteration;
00354 double maxError;
00355 double rotationScale;
00356 double minimumMOT;
00357 double MOT;
00358 double errorMag;
00359 Xform desiredXform;
00360
00361 JointVector *currentJointVector;
00362 JointVector *previousJointVector;
00363 JointVector *initialJointVector;
00364 JointVector *differentialJointVector;
00365 JointVector *jointVelocity;
00366
00367 HandPose errorHandVector;
00368 const Xform *currentHand;
00369 const Matrix *currentJacobian;
00370 JacobianType *fowkin;
00371 EqnSolver *solver;
00372
00373 virtual bool converge(const Xform& desiredHandMatrix);
00374
00375 virtual double calculateErrorMagnitude(const Xform& desired,
00376 const Xform* current,
00377 HandPose& error);
00378 virtual void updateKinematicState(JointVector& jointPosition);
00379 virtual bool inverse();
00380
00381
00382 bool internalSolverFlag;
00383 };
00384
00385 #include "InverseKinematics/IKJacobian.ipp"
00386
00387 }
00388 #endif // IKJacobian_hpp