Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Representations/Cognition/RobotState.h

Go to the documentation of this file.

    00001 /**
    00002  * @file RobotState.h
    00003  *
    00004  * Declaration of class RobotState
    00005  */
    00006
    00007 #ifndef __RobotState_h_
    00008 #define __RobotState_h_
    00009
    00010
    00011 #include "Tools/Streams/InOut.h"
    00012 #include "Tools/Math/Vector3.h"
    00013 #include "Representations/Perception/BodyPercept.h"
    00014
    00015 /**
    00016  * A class describing detected button messages and whether robot is crashed
    00017  */
    00018 class RobotState
    00019 {
    00020 public:
    00021   enum States { undefined, standing, crashed, rollLeft, rollRight, pickedUp };
    00022   enum MouthStates { mouthOpen, mouthClosed };
    00023
    00024   Vector3<double> acceleration;
    00025
    00026   RobotState();
    00027   ~RobotState();
    00028
    00029   unsigned long frameNumber;
    00030   void setFrameNumber(unsigned long frameNumber) {this->frameNumber = frameNumber;}
    00031
    00032   void setState(const States s) {state = s;}
    00033   States getState() const {return state;}
    00034
    00035   void setMouthState(const MouthStates t) {mouthState = t;}
    00036   MouthStates getMouthState() const {return mouthState;}
    00037
    00038   void setSomethingInFrontOfChest(bool value) {somethingInFrontOfChest = value;}
    00039   bool getSomethingInFrontOfChest() const {return somethingInFrontOfChest;}
    00040
    00041   void setDistanceToSIFOC(double value) {distanceToSIFOC = value;}
    00042   double getDistanceToSIFOC() const {return distanceToSIFOC;}
    00043
    00044   void setTimeWhenSomethingWasInFrontOfChestLast(unsigned long int time) {timeWhenSomethingWasInFrontOfChestLast = time;}
    00045   unsigned long int getTimeWhenSomethingWasInFrontOfChestLast() const {return timeWhenSomethingWasInFrontOfChestLast;}
    00046
    00047   void setButtonPressed(bool* buttonPressed)
    00048   {
    00049     for(int i = 0; i < BodyPercept::numOfSwitches; i++)
    00050     {
    00051       this->buttonPressed[i] = buttonPressed[i];
    00052     }
    00053   }
    00054   bool getButtonPressed(BodyPercept::Switches button) const
    00055   {
    00056     return buttonPressed[button];
    00057   }
    00058
    00059   void setButtonTime(long* buttonTime)
    00060   {
    00061     for(int i = 0; i < BodyPercept::numOfSwitches; i++)
    00062     {
    00063       this->buttonTime[i] = buttonTime[i];
    00064     }
    00065   }
    00066   long getButtonTime(BodyPercept::Switches button) const
    00067   {
    00068     return buttonTime[button];
    00069   }
    00070
    00071   void setButtonPressedTime(long* buttonPressedTime)
    00072   {
    00073     for(int i = 0; i < BodyPercept::numOfSwitches; i++)
    00074     {
    00075       this->buttonPressedTime[i] = buttonPressedTime[i];
    00076     }
    00077   }
    00078   long getButtonPressedTime(BodyPercept::Switches button) const
    00079   {
    00080     return buttonPressedTime[button];
    00081   }
    00082
    00083   void setButtonDuration(long* buttonDuration)
    00084   {
    00085     for(int i = 0; i < BodyPercept::numOfSwitches; i++)
    00086     {
    00087       this->buttonDuration[i] = buttonDuration[i];
    00088     }
    00089   }
    00090   long getButtonDuration(BodyPercept::Switches button) const
    00091   {
    00092     return buttonDuration[button];
    00093   }
    00094
    00095   void setAnyBackButtonPressed(bool anyBackButtonPressed)
    00096   {
    00097     this->anyBackButtonPressed = anyBackButtonPressed;
    00098   }
    00099   bool getAnyBackButtonPressed() const
    00100   {
    00101     return anyBackButtonPressed;
    00102   }
    00103
    00104   void setAnyBackButtonTime(long anyBackButtonTime)
    00105   {
    00106     this->anyBackButtonTime = anyBackButtonTime;
    00107   }
    00108   long getAnyBackButtonTime() const
    00109   {
    00110     return anyBackButtonTime;
    00111   }
    00112
    00113   void setAnyBackButtonPressedTime(long anyBackButtonPressedTime)
    00114   {
    00115     this->anyBackButtonPressedTime = anyBackButtonPressedTime;
    00116   }
    00117   long getAnyBackButtonPressedTime() const
    00118   {
    00119     return anyBackButtonPressedTime;
    00120   }
    00121
    00122   void setAnyBackButtonDuration(long anyBackButtonDuration)
    00123   {
    00124     this->anyBackButtonDuration = anyBackButtonDuration;
    00125   }
    00126   long getAnyBackButtonDuration() const
    00127   {
    00128     return anyBackButtonDuration;
    00129   }
    00130
    00131   /** copies another RobotState to this one */
    00132   void operator = (const RobotState& other);
    00133
    00134   static const char* getStateName(States s)
    00135   {
    00136     switch(s)
    00137     {
    00138       case undefined: return "undefined";
    00139       case standing: return "standing";
    00140       case crashed: return "crashed";
    00141       case rollLeft: return "rollLeft";
    00142       case rollRight: return "rollRight";
    00143       case pickedUp: return "pickedUp";
    00144       default: return "please edit RobotState::getStateName";
    00145     }
    00146   }
    00147
    00148   void setCollisionFrontLeft(bool c) {collisionFrontLeft = c;}
    00149   bool getCollisionFrontLeft() const {return collisionFrontLeft;}
    00150
    00151   void setCollisionFrontRight(bool c) {collisionFrontRight = c;}
    00152   bool getCollisionFrontRight() const {return collisionFrontRight;}
    00153
    00154   void setCollisionHindLeft(bool c) {collisionHindLeft = c;}
    00155   bool getCollisionHindLeft() const {return collisionHindLeft;}
    00156
    00157   void setCollisionHindRight(bool c) {collisionHindRight = c;}
    00158   bool getCollisionHindRight() const {return collisionHindRight;}
    00159
    00160   void setCollisionHead(bool c) {collisionHead = c;}
    00161   bool getCollisionHead() const {return collisionHead;}
    00162
    00163   void setCollisionAggregate(bool c) {collisionAggregate = c;}
    00164   bool getCollisionAggregate() const {return collisionAggregate;}
    00165
    00166   void setOdometryDisturbance(double c) {odometryDisturbance = c;}
    00167   double getOdometryDisturbance() const {return odometryDisturbance;}
    00168
    00169   void setConsecutiveCollisionTimeFrontLeft(long c) {consecutiveCollisionTimeFrontLeft = c;}
    00170   long getConsecutiveCollisionTimeFrontLeft() const {return consecutiveCollisionTimeFrontLeft;}
    00171
    00172   void setConsecutiveCollisionTimeFrontRight(long c) {consecutiveCollisionTimeFrontRight = c;}
    00173   long getConsecutiveCollisionTimeFrontRight() const {return consecutiveCollisionTimeFrontRight;}
    00174
    00175   void setConsecutiveCollisionTimeHindLeft(long c) {consecutiveCollisionTimeHindLeft = c;}
    00176   long getConsecutiveCollisionTimeHindLeft() const {return consecutiveCollisionTimeHindLeft;}
    00177
    00178   void setConsecutiveCollisionTimeHindRight(long c) {consecutiveCollisionTimeHindRight = c;}
    00179   long getConsecutiveCollisionTimeHindRight() const {return consecutiveCollisionTimeHindRight;}
    00180
    00181   void setConsecutiveCollisionTimeHead(long c) {consecutiveCollisionTimeHead = c;}
    00182   long getConsecutiveCollisionTimeHead() const {return consecutiveCollisionTimeHead;}
    00183
    00184   void setConsecutiveCollisionTimeAggregate(long c) {consecutiveCollisionTimeAggregate = c;}
    00185   long getConsecutiveCollisionTimeAggregate() const {return consecutiveCollisionTimeAggregate;}
    00186
    00187   void setCollisionSide(int s) {collisionSide = s;}
    00188   long getCollisionSide() const {return collisionSide;}
    00189
    00190
    00191 private:
    00192
    00193   /**
    00194    * current state of robot position
    00195    * if crashed or standing
    00196    */
    00197   States state;
    00198
    00199   /**
    00200    * current state of the mouth
    00201    */
    00202   MouthStates mouthState;
    00203
    00204    /**
    00205    * collision indicator of front left leg
    00206    */
    00207   bool collisionFrontLeft;
    00208
    00209   /**
    00210    * collision indicator of front right leg
    00211    */
    00212   bool collisionFrontRight;
    00213
    00214   /**
    00215    * collision indicator of hind left leg
    00216    */
    00217   bool collisionHindLeft;
    00218
    00219   /**
    00220    * collision indicator of hind right leg
    00221    */
    00222   bool collisionHindRight;
    00223
    00224   /**
    00225    * collision indicator of head
    00226    */
    00227   bool collisionHead;
    00228
    00229    /**
    00230    * collision indicator of collision occurrence
    00231    */
    00232   bool collisionAggregate;
    00233
    00234    /**
    00235    * indicator of odometry disturbance
    00236    */
    00237   double odometryDisturbance;
    00238
    00239    /**
    00240    * Time for last consecutive collision on front left leg
    00241    */
    00242   long consecutiveCollisionTimeFrontLeft;
    00243
    00244   /**
    00245    * Time for last consecutive collision on front right leg
    00246    */
    00247   long consecutiveCollisionTimeFrontRight;
    00248
    00249    /**
    00250    * Time for last consecutive collision on hind left leg
    00251    */
    00252   long consecutiveCollisionTimeHindLeft;
    00253
    00254   /**
    00255    * Time for last consecutive collision on hind right leg
    00256    */
    00257   long consecutiveCollisionTimeHindRight;
    00258
    00259    /**
    00260    * Time for last consecutive collision on head
    00261    */
    00262   long consecutiveCollisionTimeHead;
    00263
    00264    /**
    00265    * Time for last consecutive collision aggregate
    00266    */
    00267   long consecutiveCollisionTimeAggregate;
    00268
    00269    /**
    00270    * collision occured on side
    00271    */
    00272   long collisionSide;
    00273
    00274
    00275   /***/
    00276   bool buttonPressed[BodyPercept::numOfSwitches]; //0 Button not pressed, 1 Button pressed
    00277   unsigned long buttonTime[BodyPercept::numOfSwitches]; // The time as the button was pressed/released
    00278   unsigned long buttonPressedTime[BodyPercept::numOfSwitches]; // How long the last button was pressed (after releasing it)
    00279   unsigned long buttonDuration[BodyPercept::numOfSwitches]; // How long the button is pressed/released
    00280   bool anyBackButtonPressed;  // The same information for any backbutton
    00281   unsigned long anyBackButtonTime;
    00282   unsigned long anyBackButtonPressedTime;
    00283   unsigned long anyBackButtonDuration;
    00284   /***/
    00285
    00286   /** Indicates whether something has been measured by the body PSD or not*/
    00287   bool somethingInFrontOfChest;
    00288
    00289   /** The distance of objects in front of the body PSD*/
    00290   double distanceToSIFOC;
    00291
    00292   /** The last time when something has been measured by the body PSD */
    00293   unsigned long int timeWhenSomethingWasInFrontOfChestLast;
    00294 };
    00295
    00296 /**
    00297  * Streaming operator that reads a RobotState from a stream.
    00298  * @param stream The stream from which is read.
    00299  * @param robotState The RobotState object.
    00300  * @return The stream.
    00301  */
    00302 In& operator>>(In& stream,RobotState& robotState);
    00303
    00304 /**
    00305  * Streaming operator that writes a RobotState to a stream.
    00306  * @param stream The stream to write on.
    00307  * @param robotState The RobotState object.
    00308  * @return The stream.
    00309  */
    00310 Out& operator<<(Out& stream, const RobotState& robotState);
    00311
    00312
    00313 #endif //__RobotState_h_