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 #ifndef __SERVOMOTOR__
00027 #define __SERVOMOTOR__
00028
00029
00030
00031 #include "Leg.h"
00032 #include "SimServoMotor.h"
00033
00034 #define KEEP 0
00035 #define REPLACE 1
00036
00037 class SimServoMotor;
00038
00039 namespace API {
00040
00041 class Leg;
00049 class ServoMotor
00050 {
00051 friend class Leg;
00052 friend class Atom;
00053 class Util;
00054 friend class Util;
00055
00056 public:
00065 class Util {
00066 friend class ServoMotor;
00067 friend class Leg;
00068 friend class Atom;
00069 private:
00070 SimServoMotor * simservo;
00071 ServoMotor * servo;
00072 Util(ServoMotor * servo);
00073 ~Util();
00074 public:
00078 void print() const;
00079
00084 SimServoMotor * getSimulatedObject() const;
00085
00086 protected:
00092 void setSimulatedObject(SimServoMotor * aSimServoMotor );
00093 };
00094
00099 Util * util;
00100 private:
00101 Leg * leg;
00102 int servoID;
00103 int targetPos;
00104 int targetVelocity;
00105
00106 public:
00112 int getID() const;
00113
00119 Leg * getLeg() const;
00120
00126 int getTargetPosition() const;
00127
00133 double getTargetAngle() const;
00134
00140 double getTargetVelocity() const;
00141
00147 double getTargetForce() const;
00148
00154 int getCurrentPosition() const;
00155
00161 double getCurrentVelocity() const;
00162
00168 double getCurrentForce() const;
00169
00175 double getCurrentAngle() const;
00176
00182 double getHighStopAngle() const;
00183
00189 double getLowStopAngle() const;
00190
00196 int getMinPosition() const;
00197
00203 int getMaxPosition() const;
00204
00213 void setToHalfPosition(int mode=KEEP, Real deltaTime=0,unsigned int index=0);
00214
00223 void setTargetAngle(double aTargetAngle, int mode=KEEP, Real deltaTime=0,unsigned int index=0);
00224
00233 void setTargetPosition(int aTargetPosition, int mode=KEEP, Real deltaTime=0,unsigned int index=0);
00234
00243 void setTargetVelocity(int aTargetVelocity, int mode=KEEP, Real deltaTime=0,unsigned int index=0);
00244
00253 void setTargetForce(double aTargetForce, int mode=KEEP, Real deltaTime=0,unsigned int index=0);
00254
00258 void stop();
00259
00260 protected:
00265 ServoMotor();
00270 ~ServoMotor();
00271
00276 void setID(int aServoMotorID);
00277
00282 void setLeg(Leg * aLeg);
00283
00284 };
00285 }
00286 #endif // __SERVOMOTOR__