00001 /*************************************************************************** 00002 Leg.h - description 00003 ------------------- 00004 begin : mer jun 08 2003 00005 copyright : (C) 2003 by Michel Dubois, Yann Le Guyadec 00006 email : Michel.Dubois@univ-ubs.fr, Yann.Le-Guyadec@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 // Modele statique 00019 /* 00020 * changes : 00021 * - 08/06/03 MD Creation ! 00022 */ 00023 00024 00025 #ifndef __LEG__ 00026 #define __LEG__ 00027 00028 00029 // Include files 00030 #include "nommgr.h" 00031 #include <string> 00032 #include "mmgr.h" 00033 00034 #include <SimLeg.h> 00035 #include <RigidBodyEntity.h> 00036 #include <Node.h> 00037 #include "Atom.h" 00038 #include "CartesianPosition.h" 00039 #include "ForceSensor.h" 00040 #include "IRReceiver.h" 00041 #include "IRSender.h" 00042 #include "ServoMotor.h" 00043 #include "SphericPosition.h" 00044 #include "TouchSensor.h" 00045 #include "Link.h" 00046 class SimLeg; 00047 00048 namespace API { 00049 00050 class ServoMotor; 00051 class Atom; 00052 class ForceSensor; 00053 class TouchSensor; 00054 class IRReceiver; 00062 class Leg 00063 { 00064 class Util; 00065 friend class Util; 00066 friend class Atom; 00067 friend class Link; 00068 private: 00069 //SimLeg * simleg; 00070 ServoMotor * lservo[2]; 00071 IRSender * lirsend; 00072 IRReceiver * lirreceiver; 00073 ForceSensor * lforce[3]; 00074 00075 TouchSensor * ltouch; 00076 int ID; 00077 Atom * atom; 00078 int MappedID; 00079 Link * linkOfLeg ; 00080 public: 00088 class Util { 00089 friend class Leg; 00090 friend class Atom; 00091 private: 00092 Leg * leg; 00093 SimLeg * simleg; 00094 Util(Leg * aLeg); 00095 ~Util(); 00096 public: 00097 00105 void setSphericPosition(SphericPosition aSphericPosition); 00106 00114 void link(Leg * aLeg); 00115 00120 SimLeg * getSimulatedObject() const; 00121 00127 bool isConnectable(Leg * aLeg) const; 00128 00133 bool isOnGround() const; 00134 00138 void print() const; 00139 00140 }; 00141 00146 Util * util; 00147 protected : 00148 00155 Leg(Atom * anAtom, int LegID); 00156 00161 virtual ~Leg(); 00162 public: 00163 00169 int getID() const; 00170 00176 int getMappedID() const; 00177 00183 Atom * getAtom() const; 00184 00190 SphericPosition& getSphericPosition() const; 00191 00197 CartesianPosition& getRelCartesianPosition() const; 00198 00204 Leg * getLinkedLeg(); 00205 00211 Link * getLink() const; 00212 00218 std::string getMessage(); 00225 ServoMotor * getServoMotor(unsigned int aServoMotorID) const; 00226 00233 ForceSensor * getForceSensor(unsigned int aForceSensorID) const; 00234 00240 TouchSensor * getTouchSensor() const; 00241 00247 IRReceiver * getIRReceiver() const; 00248 00254 IRSender * getIRSender() const; 00255 00261 bool isLinked() const; 00262 00268 void setLink(Leg * aLeg); 00269 00276 void sendMessage(std::string aMessage); 00277 00282 void unlink(); 00283 00287 void stop(); 00288 00294 unsigned int getServoMotorCount() const; 00295 00301 unsigned int getForceSensorCount() const; 00302 00303 protected: 00308 void setID(int aLegID); 00309 00314 void setMappedID(int aMappedID); 00315 00320 void setAtom(Atom * anAtom); 00321 00322 };// END CLASS DEFINITION Leg 00323 } 00324 #endif // __LEG__