00001 /*************************************************************************** 00002 SimServoMotor.h - description 00003 ------------------- 00004 begin : mar jui 15 2003 00005 copyright : (C) 2003 by Yann Le Guyadec, Michel DUBOIS 00006 email : Yann.Le-Guyadec@univ-ubs.fr, Michel.Dubois@univ-ubs.fr 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef SIMSERVOMOTOR_H 00019 #define SIMSERVOMOTOR_H 00020 #include "nommgr.h" 00021 #include <ode/ode.h> 00022 #include "mmgr.h" 00023 #include "HingeJoint.h" 00024 #include "AMotorJoint.h" 00025 #include "Entity.h" 00026 #include "Event.h" 00027 #include "SimLeg.h" 00028 00033 class SimServoMotor : public Entity 00034 { 00035 friend class SimLeg; 00036 friend class SimLinkedLeg; 00037 00038 public: 00039 SimServoMotor(); 00040 SimServoMotor(HingeJoint * aHingeJoint, AMotorJoint * anAMotor); 00041 // SimServoMotor(HingeJoint * aHingeJoint, AMotor * anAMotor); 00042 // SimServoMotor(OldHingeJoint * aHingeJoint, AMotor * anAMotor); 00043 00044 SimServoMotor(SimRigidBody * body1, SimRigidBody * body2); 00045 ~SimServoMotor(); 00046 // OldHingeJoint * getHingeJoint() const; 00047 HingeJoint * getHingeJoint() const; 00048 00049 AMotorJoint * getAMotorJoint() const; 00050 // AMotor * getAMotor() const; 00051 00052 double getParam(int odeparameter) const; 00053 void setParam(int odeparameter, double value); 00054 /* commenter le codage */ 00055 void setAxis(Vector3 anAxis); 00056 Real getAngle(); 00057 void handleEvent (Event* event); 00058 int getMinPosition() const; 00059 int getMaxPosition() const; 00060 double getLowStopAngle() const; 00061 double getHighStopAngle() const; 00062 int Angle2Position(double anAngle) const; 00063 double Position2Angle(int aPosition) const; 00064 int getHalfPosition() const; 00065 SimServoMotor * getCoupledSimServoMotor() const; 00066 double getTargetVelocity() const; 00067 double getCurrentVelocity() const; 00068 virtual void print(); 00069 00070 protected: 00071 SimLeg * sleg; 00072 unsigned int ID; 00073 HingeJoint * hinge; 00074 00075 // OldHingeJoint * hinge; 00076 AMotorJoint * amotor; 00077 // AMotor * amotor; 00078 int direction; // 0 or 1 00079 double targetSpeed; 00080 SimServoMotor * coupledSSMotor; 00081 void setCoupledServoMotor(SimServoMotor * aCoupledSimServoMotor); 00082 void setHingeJoint(HingeJoint * aHingeJoint); 00083 // void setHingeJoint(OldHingeJoint * aHingeJoint); 00084 00085 void setAMotorJoint(AMotorJoint * anAMotor); 00086 // void setAMotorJoint(AMotor * anAMotor); 00087 void checkConfig(); 00088 static double servoMotorLowStopAngle; 00089 static double servoMotorHighStopAngle; 00090 static int servoMotorMinPos; 00091 static int servoMotorMaxPos; 00092 static double servoMotorRatioPos2Angle; 00093 static double servoMotorRatioAngle2Pos; 00094 static double servoMotorMaxAmplitudePos; 00095 static double servoMotorMaxAmplitudeAngle; 00096 00097 00098 }; 00099 00100 #endif