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 
00167   void setConsecutiveCollisionTimeFrontLeft(long c) {consecutiveCollisionTimeFrontLeft = c;}
00168   long getConsecutiveCollisionTimeFrontLeft() const {return consecutiveCollisionTimeFrontLeft;}
00169 
00170   void setConsecutiveCollisionTimeFrontRight(long c) {consecutiveCollisionTimeFrontRight = c;}
00171   long getConsecutiveCollisionTimeFrontRight() const {return consecutiveCollisionTimeFrontRight;}
00172 
00173   void setConsecutiveCollisionTimeHindLeft(long c) {consecutiveCollisionTimeHindLeft = c;}
00174   long getConsecutiveCollisionTimeHindLeft() const {return consecutiveCollisionTimeHindLeft;}
00175 
00176   void setConsecutiveCollisionTimeHindRight(long c) {consecutiveCollisionTimeHindRight = c;}
00177   long getConsecutiveCollisionTimeHindRight() const {return consecutiveCollisionTimeHindRight;}
00178 
00179   void setConsecutiveCollisionTimeHead(long c) {consecutiveCollisionTimeHead = c;}
00180   long getConsecutiveCollisionTimeHead() const {return consecutiveCollisionTimeHead;}
00181 
00182   void setConsecutiveCollisionTimeAggregate(long c) {consecutiveCollisionTimeAggregate = c;}
00183   long getConsecutiveCollisionTimeAggregate() const {return consecutiveCollisionTimeAggregate;}
00184 
00185   void setCollisionSide(int s) {collisionSide = s;}
00186   long getCollisionSide() const {return collisionSide;}
00187 
00188 
00189 private:
00190 
00191   /**
00192    * current state of robot position
00193    * if crashed or standing
00194    */
00195   States state;
00196 
00197   /**
00198    * current state of the mouth
00199    */
00200   MouthStates mouthState;
00201 
00202    /**
00203    * collision indicator of front left leg
00204    */
00205   bool collisionFrontLeft;
00206 
00207   /**
00208    * collision indicator of front right leg
00209    */
00210   bool collisionFrontRight;
00211 
00212   /**
00213    * collision indicator of hind left leg
00214    */
00215   bool collisionHindLeft;
00216 
00217   /**
00218    * collision indicator of hind right leg
00219    */
00220   bool collisionHindRight;
00221 
00222   /**
00223    * collision indicator of head
00224    */
00225   bool collisionHead;
00226 
00227    /**
00228    * collision indicator of collision occurrence
00229    */
00230   bool collisionAggregate;
00231 
00232    /**
00233    * Time for last consecutive collision on front left leg
00234    */
00235   long consecutiveCollisionTimeFrontLeft;
00236 
00237   /**
00238    * Time for last consecutive collision on front right leg
00239    */
00240   long consecutiveCollisionTimeFrontRight;
00241 
00242    /**
00243    * Time for last consecutive collision on hind left leg
00244    */
00245   long consecutiveCollisionTimeHindLeft;
00246 
00247   /**
00248    * Time for last consecutive collision on hind right leg
00249    */
00250   long consecutiveCollisionTimeHindRight;
00251 
00252    /**
00253    * Time for last consecutive collision on head
00254    */
00255   long consecutiveCollisionTimeHead;
00256 
00257    /**
00258    * Time for last consecutive collision aggregate
00259    */
00260   long consecutiveCollisionTimeAggregate;
00261 
00262    /**
00263    * collision occured on side
00264    */
00265   long collisionSide;
00266 
00267 
00268   /***/
00269   bool buttonPressed[BodyPercept::numOfSwitches]; //0 Button not pressed, 1 Button pressed
00270   unsigned long buttonTime[BodyPercept::numOfSwitches]; // The time as the button was pressed/released
00271   unsigned long buttonPressedTime[BodyPercept::numOfSwitches]; // How long the last button was pressed (after releasing it)
00272   unsigned long buttonDuration[BodyPercept::numOfSwitches]; // How long the button is pressed/released
00273   bool anyBackButtonPressed;  // The same information for any backbutton
00274   unsigned long anyBackButtonTime;
00275   unsigned long anyBackButtonPressedTime;
00276   unsigned long anyBackButtonDuration;
00277   /***/
00278 
00279   /** Indicates whether something has been measured by the body PSD or not*/
00280   bool somethingInFrontOfChest;
00281 
00282   /** The distance of objects in front of the body PSD*/
00283   double distanceToSIFOC;
00284   
00285   /** The last time when something has been measured by the body PSD */
00286   unsigned long int timeWhenSomethingWasInFrontOfChestLast;
00287 };
00288 
00289 /**
00290  * Streaming operator that reads a RobotState from a stream.
00291  * @param stream The stream from which is read.
00292  * @param robotState The RobotState object.
00293  * @return The stream.
00294  */ 
00295 In& operator>>(In& stream,RobotState& robotState);
00296  
00297 /**
00298  * Streaming operator that writes a RobotState to a stream.
00299  * @param stream The stream to write on.
00300  * @param robotState The RobotState object.
00301  * @return The stream.
00302  */ 
00303 Out& operator<<(Out& stream, const RobotState& robotState);
00304 
00305 
00306 #endif //__RobotState_h_
00307 
00308 /*
00309  * Change log :
00310  * 
00311  * $Log: RobotState.h,v $
00312  * Revision 1.6  2004/06/23 11:02:27  goehring
00313  * Xabsl symbol collision-side added
00314  *
00315  * Revision 1.5  2004/06/16 17:07:33  cesarz
00316  * Moved body PSD calculations
00317  *
00318  * Revision 1.4  2004/06/08 18:34:42  juengel
00319  * Added robot-state.time-since-something-was-in-front-of-chest.
00320  *
00321  * Revision 1.3  2004/05/25 12:36:51  tim
00322  * added body PSD data
00323  *
00324  * Revision 1.2  2004/05/24 14:16:06  juengel
00325  * New button evaluation.
00326  *
00327  * Revision 1.1.1.1  2004/05/22 17:25:16  cvsadm
00328  * created new repository GT2004_WM
00329  *
00330  * Revision 1.4  2004/02/10 11:12:08  dueffert
00331  * acceleration added; frameNumber is unsigned long everywhere
00332  *
00333  * Revision 1.3  2004/01/24 11:30:16  juengel
00334  * Added ERS7 switches (head, backFront, backBack).
00335  *
00336  * Revision 1.2  2003/11/13 17:39:03  goehring
00337  * frameNumber added
00338  *
00339  * Revision 1.1  2003/10/07 10:07:01  cvsadm
00340  * Created GT2004 (M.J.)
00341  *
00342  * Revision 1.4  2003/09/30 10:51:12  dueffert
00343  * typos fixed
00344  *
00345  * Revision 1.3  2003/09/25 11:23:52  juengel
00346  * Removed BlobCollection.
00347  *
00348  * Revision 1.2  2003/07/06 12:05:31  schumann
00349  * added foreleg opening angle for ball challenge
00350  *
00351  * Revision 1.1.1.1  2003/07/02 09:40:22  cvsadm
00352  * created new repository for the competitions in Padova from the 
00353  * tamara CVS (Tuesday 2:00 pm)
00354  *
00355  * removed unused solutions
00356  *
00357  * Revision 1.6  2003/06/20 15:32:32  dueffert
00358  * getting from down from wall by rolling added
00359  *
00360  * Revision 1.5  2003/06/20 13:27:21  risler
00361  * added tailLeft tailRight messages
00362  *
00363  * Revision 1.4  2003/06/20 10:31:59  goehring
00364  * Added CollisionStates
00365  *
00366  * Revision 1.3  2003/04/01 22:40:44  cesarz
00367  * added mouth states
00368  *
00369  * Revision 1.2  2003/01/30 11:26:47  juengel
00370  * Added tailPosition to bodyPercept
00371  *
00372  * Revision 1.1  2002/09/10 15:26:39  cvsadm
00373  * Created new project GT2003 (M.L.)
00374  * - Cleaned up the /Src/DataTypes directory
00375  * - Removed Challenge Code
00376  * - Removed processing of incoming audio data
00377  * - Renamed AcousticMessage to SoundRequest
00378  *
00379  * Revision 1.4  2002/08/22 14:41:03  risler
00380  * added some doxygen comments
00381  *
00382  * Revision 1.3  2002/07/23 13:32:57  loetzsch
00383  * new streaming classes
00384  *
00385  * removed many #include statements
00386  *
00387  * Revision 1.2  2002/05/15 08:09:10  risler
00388  * added button down messages
00389  *
00390  * Revision 1.1.1.1  2002/05/10 12:40:13  cvsadm
00391  * Moved GT2002 Project from ute to tamara.
00392  *
00393  * Revision 1.7  2002/04/08 17:48:53  risler
00394  * added pickedUp
00395  *
00396  * Revision 1.6  2002/03/28 16:55:58  risler
00397  * RobotStateDetector receives BodyPercept instead of PerceptCollection
00398  * added switch duration in RobotStateDetector
00399  *
00400  * Revision 1.5  2002/03/28 15:19:20  risler
00401  * implemented switch messages in RobotStateDetector
00402  *
00403  * Revision 1.4  2002/02/23 16:37:15  risler
00404  * State in RobotState like BodyPercept state
00405  *
00406  * Revision 1.3  2001/12/10 17:47:06  risler
00407  * change log added
00408  *
00409  */

Generated on Thu Sep 23 19:57:35 2004 for GT2004 by doxygen 1.3.6