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

# Modules/BehaviorControl/GT2005BehaviorControl/GT2005BasicBehaviors/GT2005PotentialFieldBasicBehaviors.h

Go to the documentation of this file.

    00001 /**
    00002 * @file GT2005PotentialFieldBasicBehaviors.h
    00003 *
    00004 * Declaration of basic behaviors defined in potential-field-basic-behaviors.xml.
    00005 *
    00006 * @author <a href="mailto:timlaue@tzi.de">Tim Laue</a>
    00007 */
    00008
    00009 #ifndef __GT2005PotentialFieldBasicBehaviors_h_
    00010 #define __GT2005PotentialFieldBasicBehaviors_h_
    00011
    00012 #include "Tools/Xabsl2/Xabsl2Engine/Xabsl2Engine.h"
    00013 #include "Tools/PotentialFields/GTStandardConverter.h"
    00014 #include "Modules/BehaviorControl/BehaviorControl.h"
    00015 #include "Tools/Xabsl2/Xabsl2Engine/Xabsl2BasicBehavior.h"
    00016
    00017
    00018 /**
    00019 * An abstract base class for all potential field based basic behaviors
    00020 *
    00021 * @author Tim Laue
    00022 */
    00023 class GT2005PotentialFieldBasicBehavior : public Xabsl2BasicBehavior,
    00024                                           public BehaviorControlInterfaces
    00025 {
    00026 public:
    00027 /*
    00028 * Constructor.
    00029 * @param errorHandler Is invoked when errors occur
    00030 * @param interfaces The paramters of the BehaviorControl module.
    00031   */
    00032   GT2005PotentialFieldBasicBehavior(const BehaviorControlInterfaces& interfaces,
    00033     Xabsl2ErrorHandler& errorHandler, const char* behaviorName, const char* pfcFileName):
    00034             Xabsl2BasicBehavior(behaviorName, errorHandler),
    00035             BehaviorControlInterfaces(interfaces)
    00036   {
    00037     potentialfields.load(pfcFileName);
    00038   };
    00039
    00040   /**  Executes the basic behavior. */
    00041   virtual void execute() = 0;
    00042
    00043 protected:
    00044   /** An instance of the potential field architecture*/
    00045   GTStandardConverter potentialfields;
    00046   /** A standard instance of a result structure*/
    00047   PotentialfieldResult result;
    00048 };
    00049
    00050
    00051 class GT2005PotentialFieldBasicBehaviorSupport : public GT2005PotentialFieldBasicBehavior
    00052 {
    00053 public:
    00054   /*
    00055 * Constructor.
    00056 * @param errorHandler Is invoked when errors occur
    00057 * @param interfaces The paramters of the BehaviorControl module.
    00058   */
    00059   GT2005PotentialFieldBasicBehaviorSupport(const BehaviorControlInterfaces& interfaces,
    00060                                            Xabsl2ErrorHandler& errorHandler);
    00061
    00062   /**  Executes the basic behavior. */
    00063   virtual void execute();
    00064
    00065 private:
    00066   /** Parameter potential-field-support.x*/
    00067   double x;
    00068   /** Parameter potential-field-support.y*/
    00069   double y;
    00070   /** Parameter potential-field-support.max-speed*/
    00071   double maxSpeed;
    00072 };
    00073
    00074
    00075 class GT2005PotentialFieldBasicBehaviorOffensiveSupport : public GT2005PotentialFieldBasicBehavior
    00076 {
    00077 public:
    00078   /*
    00079 * Constructor.
    00080 * @param errorHandler Is invoked when errors occur
    00081 * @param interfaces The paramters of the BehaviorControl module.
    00082   */
    00083   GT2005PotentialFieldBasicBehaviorOffensiveSupport(const BehaviorControlInterfaces& interfaces,
    00084                                                     Xabsl2ErrorHandler& errorHandler);
    00085
    00086   /**  Executes the basic behavior. */
    00087   virtual void execute();
    00088
    00089 private:
    00090   /** Parameter potential-field-offensive-support.x*/
    00091   double x;
    00092   /** Parameter potential-field-offensive-support.y*/
    00093   double y;
    00094   /** Parameter potential-field-offensive-support.max-speed*/
    00095   double maxSpeed;
    00096 };
    00097
    00098
    00099 class GT2005PotentialFieldBasicBehaviorAvoidRobots : public GT2005PotentialFieldBasicBehavior
    00100 {
    00101 public:
    00102   /*
    00103 * Constructor.
    00104 * @param errorHandler Is invoked when errors occur
    00105 * @param interfaces The paramters of the BehaviorControl module.
    00106   */
    00107   GT2005PotentialFieldBasicBehaviorAvoidRobots(const BehaviorControlInterfaces& interfaces,
    00108                                                     Xabsl2ErrorHandler& errorHandler);
    00109
    00110   /**  Executes the basic behavior. */
    00111   virtual void execute();
    00112
    00113 private:
    00114   /** Parameter potential-field-offensive-support.x*/
    00115   double x;
    00116   /** Parameter potential-field-offensive-support.y*/
    00117   double y;
    00118   /** Parameter potential-field-offensive-support.max-speed*/
    00119   double maxSpeed;
    00120 };
    00121
    00122
    00123 /**
    00124 * @class PotentialFieldBasicBehaviors
    00125 *
    00126 * Creates and registers potential field basic behaviors
    00127 */
    00128 class GT2005PotentialFieldBasicBehaviors : public BehaviorControlInterfaces
    00129 {
    00130 public:
    00131   /**
    00132   * Constructor
    00133   */
    00134   GT2005PotentialFieldBasicBehaviors(BehaviorControlInterfaces& interfaces,
    00135     Xabsl2ErrorHandler& errorHandler):
    00136   BehaviorControlInterfaces(interfaces),
    00137   errorHandler(errorHandler),
    00138   potentialFieldSupport(interfaces, errorHandler),
    00139   potentialFieldOffensiveSupport(interfaces, errorHandler),
    00140   potentialFieldAvoidRobots(interfaces, errorHandler)
    00141   {}
    00142
    00143   /** Registers basic behaviors at the engine */
    00144   void registerBasicBehaviors(Xabsl2Engine& engine)
    00145   {
    00146     engine.registerBasicBehavior(potentialFieldSupport);
    00147     engine.registerBasicBehavior(potentialFieldOffensiveSupport);
    00148     engine.registerBasicBehavior(potentialFieldAvoidRobots);
    00149   }
    00150
    00151   /** updates some variables */
    00152   void update() {};
    00153
    00154 private:
    00155   /** Is invoked when errors occurs */
    00156   Xabsl2ErrorHandler& errorHandler;
    00157
    00158   //!@name Basic Behaviors
    00159   //!@{
    00160   GT2005PotentialFieldBasicBehaviorSupport potentialFieldSupport;
    00161   GT2005PotentialFieldBasicBehaviorOffensiveSupport potentialFieldOffensiveSupport;
    00162   GT2005PotentialFieldBasicBehaviorAvoidRobots potentialFieldAvoidRobots;
    00163   //!@}
    00164 };
    00165
    00166 #endif // __GT2005PotentialFieldBasicBehaviors_h_