00001 /*************************************************************************** 00002 * Copyright (C) 2008 by Neuronics AG * 00003 * support@neuronics.ch * 00004 ***************************************************************************/ 00005 00010 #ifndef _ANAGUESS_KINEMATICS_H_ 00011 #define _ANAGUESS_KINEMATICS_H_ 00012 00013 //std: 00014 #include <string> 00015 #include <queue> 00016 #include <vector> 00017 #include <map> 00018 #include <algorithm> 00019 00020 #include "exception.h" 00021 00022 namespace AnaGuess { 00023 00024 const double cTolerance = 0.0001; 00025 00028 class NoSolutionException : public Exception { 00029 public: 00030 NoSolutionException() throw(): 00031 Exception("No solution found", -10) {} 00032 00033 }; 00034 00035 00037 00042 class Kinematics { 00043 00044 private: 00046 int mNumberOfMotors; 00048 int mNumberOfSegments; 00050 std::vector<double> mSegmentLength; 00052 std::vector<double> mAngleOffset; 00054 std::vector<double> mAngleStop; 00056 std::vector<int> mEncodersPerCycle; 00058 std::vector<int> mEncoderOffset; 00060 std::vector<int> mRotationDirection; 00062 virtual bool initialize() = 0; 00063 00064 00065 public: 00067 virtual ~Kinematics(){} 00068 00070 virtual std::vector<double> getLinkLength() = 0; 00072 virtual std::vector<int> getEpc() = 0; 00074 virtual std::vector<int> getEncOff() = 0; 00076 virtual std::vector<int> getDir() = 0; 00078 virtual std::vector<double> getAngOff() = 0; 00080 virtual std::vector<double> getAngStop() = 0; 00082 virtual std::vector<double> getAngRange() = 0; 00084 virtual std::vector<double> getAngMin() = 0; 00086 virtual std::vector<double> getAngMax() = 0; 00088 virtual bool setLinkLength(const std::vector<double> aLengths) = 0; 00090 virtual bool setAngOff(const std::vector<double> aAngOff) = 0; 00092 virtual bool setAngStop(const std::vector<double> aAngStop) = 0; 00093 00098 virtual bool enc2rad(std::vector<double>& aAngles, const std::vector<int> aEncoders) = 0; 00099 00104 virtual bool rad2enc(std::vector<int>& aEncoders, const std::vector<double> aAngles) = 0; 00105 00110 virtual bool directKinematics(std::vector<double>& aPosition, const std::vector<double> aAngles) = 0; 00111 00118 virtual bool inverseKinematics(std::vector<double>& aAngles, const std::vector<double> aPosition, const std::vector<double> aStartingAngles) = 0; 00119 }; 00121 00122 } // namespace 00123 00124 #endif //_ANAGUESS_KINEMATICS_H_