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

# Modules/RobotStateDetector/GT2005RobotStateDetector.h

Go to the documentation of this file.

    00001 /**
    00002 * @file GT2005RobotStateDetector.h
    00003 *
    00004 * Definition of class DefaultRobotStateDetector
    00005 *
    00006 */
    00007
    00008 #ifndef __DefaultRobotStateDetector_h_
    00009 #define __DefaultRobotStateDetector_h_
    00010
    00011 #include "RobotStateDetector.h"
    00012
    00013
    00014 #include "Tools/Debugging/Debugging.h" /////*****
    00015
    00016 /**
    00017 * @class DefaultRobotStateDetector
    00018 *
    00019 * A solution of the RobotStateDetector module.
    00020 *
    00021 * @author = Max Risler
    00022 */
    00023 class GT2005RobotStateDetector : public RobotStateDetector
    00024 {
    00025 public:
    00026   /**
    00027   * Constructor.
    00028   * @param interfaces The paramters of the RobotStateDetector module.
    00029   */
    00030   GT2005RobotStateDetector(const RobotStateDetectorInterfaces& interfaces);
    00031
    00032   /** Executes the module */
    00033   virtual void execute();
    00034
    00035 private:
    00036
    00037   void calculateCollisionState();
    00038
    00039   void setNewButtonStatus();
    00040
    00041   bool switchDown[BodyPercept::numOfSwitches];
    00042   long switchDownTime[BodyPercept::numOfSwitches];
    00043   long timeSinceLastCollision[6]; //here are the last collision time points
    00044   long consecutiveCollisionTime[6]; //here are the consecutive collision time points
    00045   long remindCollision; // time distance during which the last collision is remembered
    00046   int getCollisionSide(); //on which side did more collisions occur
    00047   void setCollisionOnLeftSide(bool collision); //add another collision to left side
    00048   void setCollisionOnRightSide(bool collision);//add another collision to right side
    00049
    00050   enum {middle = 0,
    00051         left,
    00052         right,
    00053         robotSides};
    00054
    00055   enum {maxFrameHistory = 200};
    00056
    00057   bool numOfCollisions[maxFrameHistory][robotSides];
    00058
    00059
    00060   /***/
    00061   bool buttonPressed[BodyPercept::numOfSwitches]; //0 Button not pressed, 1 Button pressed
    00062   long buttonTime[BodyPercept::numOfSwitches]; // The time as the button was pressed/released
    00063   long buttonPressedTime[BodyPercept::numOfSwitches]; // How long the last button was pressed (after releasing it)
    00064   long buttonDuration[BodyPercept::numOfSwitches]; // How long the button is pressed/released
    00065   bool anyBackButtonPressed;  // The same information for any backbutton
    00066   long anyBackButtonTime;
    00067   long anyBackButtonPressedTime;
    00068   long anyBackButtonDuration;
    00069   /***/
    00070 };
    00071
    00072 #endif// __GT2005RobotStateDetector_h_