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_