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

Representations/Perception/BodyPercept.h

Go to the documentation of this file.
00001 /**
00002  * @file BodyPercept.h
00003  * 
00004  * Declaration of class BodyPercept
00005  */ 
00006 
00007 #ifndef __BodyPercept_h_
00008 #define __BodyPercept_h_
00009 
00010 
00011 #include "Tools/Streams/InOut.h"
00012 #include "Tools/Math/Vector3.h"
00013 
00014 /**
00015  * The class represents the robots body percept
00016  *
00017  * The percept consists of current switches and a variable containing
00018  * whether the robot stands or is crashed. */
00019 class BodyPercept
00020 {
00021 public:
00022 
00023   enum States { undefined, standing, crashed, rollLeft, rollRight, pickedUp };
00024 
00025 
00026   /** bit position of switch bits in switches value */
00027   enum Switches { 
00028                   backMiddle = 0,
00029                   backFront,
00030                   backBack,
00031                   head,
00032                   mouth,
00033                   chin,
00034                   numOfSwitches};
00035   
00036   enum MouthStates { mouthOpen, mouthClosed };
00037   
00038   Vector3<double> acceleration;
00039 
00040   BodyPercept();
00041   ~BodyPercept();
00042 
00043   /**< The frame number when perceived. */
00044   unsigned long frameNumber; 
00045 
00046   /**
00047   * The functions sets the frame number
00048   */
00049   void setFrameNumber(unsigned long frameNumber) {this->frameNumber = frameNumber;}
00050 
00051   void setState(const States s) {state = s;}
00052   States getState() const {return state;}
00053 
00054   void setSwitches(const int s) {switches = s;}
00055   int getSwitches() const {return switches;}
00056 
00057   void setMouthState(const MouthStates t) {mouthState = t;}
00058   MouthStates getMouthState() const {return mouthState;}
00059 
00060   void setBodyPSDHighValue(bool value) {bodyPSDHighValue = value;}
00061   bool getBodyPSDHighValue() const {return bodyPSDHighValue;}
00062 
00063   void setBodyPSDDistance(double value) {bodyPSDDistance = value;}
00064   double getBodyPSDDistance() const {return bodyPSDDistance;}
00065 
00066   /** copies another BodyPercept to this one */
00067   void operator = (const BodyPercept& other);
00068 
00069   static const char* getStateName(States s)
00070   {
00071     switch (s)
00072     {
00073       case undefined: return "undefined";
00074       case standing: return "standing";
00075       case crashed: return "crashed";
00076       case rollLeft: return "rollLeft";
00077       case rollRight: return "rollRight";
00078       case pickedUp: return "pickedUp";
00079       default: return "please edit BodyPercept::getStateName";
00080     }
00081   }
00082 
00083 private:
00084 
00085   /**
00086    * current state of robot position
00087    * if crashed or standing
00088    */
00089   States state;
00090 
00091   /** value representing pressed switches bits according to switches enum */
00092   int switches;
00093 
00094   /** The state of the mouth*/
00095   MouthStates mouthState;
00096 
00097   /** Flag, set to true, if the body PSD has a high value, indicating something 
00098       in front of the robot*/
00099   bool bodyPSDHighValue;
00100 
00101   /** The measured distance (0 - 5 cm) of objects in front of the body PSD*/
00102   double bodyPSDDistance;
00103 };
00104 
00105 /**
00106  * Streaming operator that reads a BodyPercept from a stream.
00107  * @param stream The stream from which is read.
00108  * @param bodyPercept The BodyPercept object.
00109  * @return The stream.
00110  */ 
00111 In& operator>>(In& stream,BodyPercept& bodyPercept);
00112  
00113 /**
00114  * Streaming operator that writes a BodyPercept to a stream.
00115  * @param stream The stream to write on.
00116  * @param bodyPercept The BodyPercept object.
00117  * @return The stream.
00118  */ 
00119 Out& operator<<(Out& stream, const BodyPercept& bodyPercept);
00120 
00121 
00122 #endif //__BodyPercept_h_
00123 
00124 /*
00125  * Change log :
00126  * 
00127  * $Log: BodyPercept.h,v $
00128  * Revision 1.4  2004/06/16 17:07:33  cesarz
00129  * Moved body PSD calculations
00130  *
00131  * Revision 1.3  2004/05/25 12:36:51  tim
00132  * added body PSD data
00133  *
00134  * Revision 1.2  2004/05/24 14:16:06  juengel
00135  * New button evaluation.
00136  *
00137  * Revision 1.1.1.1  2004/05/22 17:25:31  cvsadm
00138  * created new repository GT2004_WM
00139  *
00140  * Revision 1.4  2004/01/28 08:32:28  dueffert
00141  * frameNumber is unsigned long everywhere, missing cases added
00142  *
00143  * Revision 1.3  2004/01/24 11:27:39  juengel
00144  * Added ERS7 switches (head, backFront, backBack).
00145  *
00146  * Revision 1.2  2003/11/14 19:02:25  goehring
00147  * frameNumber added
00148  *
00149  * Revision 1.1  2003/10/07 10:09:36  cvsadm
00150  * Created GT2004 (M.J.)
00151  *
00152  * Revision 1.3  2003/09/25 11:23:52  juengel
00153  * Removed BlobCollection.
00154  *
00155  * Revision 1.2  2003/07/06 12:05:31  schumann
00156  * added foreleg opening angle for ball challenge
00157  *
00158  * Revision 1.1.1.1  2003/07/02 09:40:22  cvsadm
00159  * created new repository for the competitions in Padova from the 
00160  * tamara CVS (Tuesday 2:00 pm)
00161  *
00162  * removed unused solutions
00163  *
00164  * Revision 1.6  2003/06/20 15:32:32  dueffert
00165  * getting from down from wall by rolling added
00166  *
00167  * Revision 1.5  2003/06/20 14:50:07  risler
00168  * numOfSwitches added
00169  *
00170  * Revision 1.4  2003/06/20 13:27:18  risler
00171  * added tailLeft tailRight messages
00172  *
00173  * Revision 1.3  2003/04/01 22:40:45  cesarz
00174  * added mouth states
00175  *
00176  * Revision 1.2  2003/01/30 11:26:47  juengel
00177 
00178   * Added tailPosition to bodyPercept
00179  *
00180  * Revision 1.1  2002/09/10 15:26:40  cvsadm
00181  * Created new project GT2003 (M.L.)
00182  * - Cleaned up the /Src/DataTypes directory
00183  * - Removed Challenge Code
00184  * - Removed processing of incoming audio data
00185  * - Renamed AcousticMessage to SoundRequest
00186  *
00187  * Revision 1.3  2002/08/22 14:41:03  risler
00188  * added some doxygen comments
00189  *
00190  * Revision 1.2  2002/07/23 13:32:57  loetzsch
00191  * new streaming classes
00192  *
00193  * removed many #include statements
00194  *
00195  * Revision 1.1.1.1  2002/05/10 12:40:13  cvsadm
00196  * Moved GT2002 Project from ute to tamara.
00197  *
00198  * Revision 1.9  2002/04/08 17:48:53  risler
00199  * added pickedUp
00200  *
00201  * Revision 1.8  2002/03/28 15:19:20  risler
00202  * implemented switch messages in RobotStateDetector
00203  *
00204  * Revision 1.7  2002/02/23 16:37:15  risler
00205  * State in RobotState like BodyPercept state
00206  *
00207  * Revision 1.6  2002/02/05 03:30:52  loetzsch
00208  * replaced direct member access by
00209  * inline const VALUE& get...() const   and
00210  * inline void set...(const Value&) methods.
00211  *
00212  * Revision 1.5  2002/02/01 15:03:23  risler
00213  * Removed pickup detection, as not working with paw sensors
00214  *
00215  * Revision 1.4  2002/01/18 11:19:41  petters
00216  * data fields and access methods added
00217  *
00218  * Revision 1.3  2001/12/10 17:47:05  risler
00219  * change log added
00220  *
00221  */

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