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

# Tools/Module/SolutionRequest.h

Go to the documentation of this file.

    00001 /**
    00002 * @file SolutionRequest.h
    00003 *
    00004 * Declaration of class SolutionRequest
    00005 *
    00006 * @author Max Risler
    00007 * @author Martin Lötzsch
    00008 */
    00009
    00010 #ifndef __SolutionRequest_h_
    00011 #define __SolutionRequest_h_
    00012
    00013 #include "Tools/Streams/InOut.h"
    00014
    00015 /** maximum number of solutions per module */
    00016 const int solutionRequestMaxNumOfSolutions = 40;
    00017
    00018 /** Manages runtime exchangeable modules. */
    00019 class SolutionRequest
    00020 {
    00021 public:
    00022   /**
    00023   * Enumerator for exchange modules
    00024   * Add new exchangeable module here.
    00025   * Create new selector module for new exchangeable modules
    00026   */
    00027   enum ModuleID
    00028   {
    00029     colorTableMod,
    00030     sensorDataProcessor, /*!< See class SensorDataProcessorSelector */
    00031     imageProcessor, /*!< See class ImageProcessorSelector */
    00032     ballLocator, /*!< See class BallLocatorSelector */
    00033     teamBallLocator, /*!< See class TeamBallLocatorSelector */
    00034     obstaclesLocator, /*!< See class ObstaclesLocatorSelector */
    00035     playersLocator, /*!< See class PlayersLocatorSelector */
    00036     selfLocator, /*!< See class SelfLocatorSelector */
    00037     robotStateDetector, /*!< See class RobotStateDetectorSelector */
    00038     collisionDetector, /*!< See class CollisionDetectorSelector */
    00039     behaviorControl, /*!< See class BehaviorControlSelector */
    00040     motionControl, /*!< See class MotionControlSelector */
    00041     walkingEngineNormal, /*!< See class WalkingEngineNormalSelector */
    00042     headControl, /*!< See class HeadControlSelector */
    00043     ledControl, /*!< See class LEDControlSelector */
    00044     getupEngine, /*!< See class GetupEngineSelector */
    00045     soundControl, /*!< See class SoundControlSelector */
    00046     sensorBehaviorControl, /*!< See class SensorBehaviorControlSelector */
    00047     gtCam,  /*!< See class GTCamSelector */
    00048     numOfModules /*!< Number of exchangeable modules */
    00049   };
    00050
    00051   /** enumerator for available solutions for all exchangeable modules
    00052   * \attention add new solutions here
    00053   * \attention dont forget to edit selector module too
    00054   */
    00055   enum ModuleSolutionID
    00056   {
    00057     disabled = -1,
    00058
    00059     // ColorTableMod solutions
    00060     colorTable64Mod = 0,
    00061     colorTable32KMod,
    00062     numOfColorTableModSolutions,
    00063
    00064     // SelfLocator solutions
    00065     gt2005SelfLocator = 0,
    00066     gt2005StableSelfLocator,
    00067     gt2004SelfLocator,
    00068     gtCamSelfLocator,
    00069     odometrySelfLocator,
    00070     slamSelfLocator,
    00071     comboSelfLocator,
    00072     numOfSelfLocatorSolutions,
    00073
    00074     // ImageProcessor solutions
    00075     gt2005ImageProcessor = 0,
    00076     slamImageProcessor,
    00077     vlcImageProcessor,
    00078     numOfImageProcessorSolutions,
    00079
    00080     // BehaviorControl solutions
    00081     gt2005BehaviorControlAgentSoccer = 0,
    00082     gt2005BehaviorControlAgentPenaltyShooter,
    00083     gt2005BehaviorControlAgentPenaltyShooter2,
    00084     gt2005BehaviorControlAgentPenaltyGoalie,
    00085     gt2005BehaviorControlAgentJoystickControlled,
    00086     gt2005BehaviorControlAgentSlamChallange,
    00087     gt2005BehaviorControlAgentVLCshooter,
    00088     gt2005BehaviorControlAgentVLC2shooter,
    00089     gt2005BehaviorControlAgentObstacleAvoidanceChallange03,
    00090     gt2005BehaviorControlAgentOdometryTester,
    00091     gt2005BehaviorControlAgentGuideDog,
    00092     gt2005BehaviorControlAgentBlindDog,
    00093     gt2005BehaviorControlAgentKickLogger,
    00094     gt2005BehaviorControlAgentBasicsTester,
    00095     numOfBehaviorControlSolutions,
    00096
    00097     // CollisionDetector solutions
    00098     gt2005CollisionDetector = 0,
    00099     numOfCollisionDetectorSolutions,
    00100
    00101     // WalkingEngine solutions
    00102     gt2005WalkingEngine = 0,
    00103     gt2004WalkingEngine,
    00104     invKinUpsideDownWalkingEngine,
    00105     invKinTurnWithBallWalkingEngine,
    00106     invKinTurnKickWalkingEngine,
    00107     numOfWalkingEngineSolutions,
    00108
    00109     // BallLocator solutions
    00110     gt2005BallLocator = 0,
    00111     gtCamBallLocator,
    00112     numOfBallLocatorSolutions,
    00113
    00114     // TeamBallLocator solutions
    00115     gt2005TeamBallLocator = 0,
    00116     numOfTeamBallLocatorSolutions,
    00117
    00118     // PlayersLocator solutions
    00119     gtCamPlayersLocator,
    00120     numOfPlayersLocatorSolutions,
    00121
    00122     // ObstaclesLocator solutions
    00123     gt2005ObstaclesLocator = 0,
    00124     gtCamObstaclesLocator,
    00125     numOfObstaclesLocatorSolutions,
    00126
    00127     // HeadControl solutions
    00128     gt2005HeadControl = 0,
    00129     numOfHeadControlSolutions,
    00130
    00131     // LEDControl solutions
    00132     gt2005LEDControl = 0,
    00133     numOfLEDControlSolutions,
    00134
    00135     // SensorDataProcessor solutions
    00136     gt2005SensorDataProcessor = 0,
    00137     numOfSensorDataProcessorSolutions,
    00138
    00139     // RobotStateDetector solutions
    00140     gt2005RobotStateDetector = 0,
    00141     numOfRobotStateDetectorSolutions,
    00142
    00143     // SensorBehaviorControl solutions
    00144     dummySensorBehaviorControl = 0, // this is only a dummy, remove it when adding a real solution
    00145     numOfSensorBehaviorControlSolutions,
    00146
    00147     // MotionControl solutions
    00148     gt2005MotionControl = 0,
    00149     debugMotionControl,
    00150     numOfMotionControlSolutions,
    00151
    00152     // GetupEngine solutions
    00153     gt2005GetupEngine = 0,
    00154     numOfGetupEngineSolutions,
    00155
    00156     // SoundOutControl solutions
    00157     gt2005SoundControl = 0,
    00158     numOfSoundControlSolutions,
    00159
    00160     // GTCam solutions
    00161     gtCamRaw = 0,
    00162     numOfGTCamSolutions
    00163   };
    00164
    00165   /** returns names for module ids
    00166   * Add new exchangeable module here
    00167   */
    00168   static const char* getModuleName(ModuleID id)
    00169   {
    00170     switch (id)
    00171     {
    00172     case colorTableMod: return "ColorTableModule";
    00173     case imageProcessor: return "ImageProcessor";
    00174     case selfLocator: return "SelfLocator";
    00175     case behaviorControl: return "BehaviorControl";
    00176     case collisionDetector: return "CollisionDetector";
    00177     case walkingEngineNormal: return "WalkingEngine:normal";
    00178     case headControl: return "HeadControl";
    00179     case ledControl: return "LEDControl";
    00180     case ballLocator: return "BallLocator";
    00181     case playersLocator: return "PlayersLocator";
    00182     case obstaclesLocator: return "ObstaclesLocator";
    00183     case sensorDataProcessor: return "SensorDataProcessor";
    00184     case robotStateDetector: return "RobotStateDetector";
    00185     case sensorBehaviorControl: return "SensorBehaviorControl";
    00186     case motionControl: return "MotionControl";
    00187     case getupEngine: return "GetupEngine";
    00188     case soundControl: return "SoundControl";
    00189     case teamBallLocator: return "TeamBallLocator";
    00190     case gtCam: return "GTCam";
    00191
    00192     default: return "please edit SolutionRequest::getModuleName";
    00193     }
    00194   }
    00195
    00196   /** returns categories for module ids
    00197   * Add new exchangeable module here
    00198   */
    00199   static const char* getModuleCategoryName(ModuleID id)
    00200   {
    00201     switch (id)
    00202     {
    00203     case colorTableMod: return "Perception";
    00204     case imageProcessor: return "Perception";
    00205     case selfLocator: return "Modeling";
    00206     case behaviorControl: return "Behavior";
    00207     case collisionDetector: return "Perception";
    00208     case walkingEngineNormal: return "Actorics";
    00209     case headControl: return "Actorics";
    00210     case ledControl: return "Output";
    00211     case ballLocator: return "Modeling";
    00212     case playersLocator: return "Modeling";
    00213     case obstaclesLocator: return "Modeling";
    00214     case sensorDataProcessor: return "Perception";
    00215     case robotStateDetector: return "Modeling";
    00216     case sensorBehaviorControl: return "";
    00217     case motionControl: return "Actorics";
    00218     case getupEngine: return "Actorics";
    00219     case soundControl: return "Output";
    00220     case teamBallLocator: return "Modeling";
    00221     case gtCam: return "";
    00222
    00223     default: return "please edit SolutionRequest::getModuleName";
    00224     }
    00225   }
    00226
    00227
    00228   /** Returns number of solutions in module id
    00229   * \attention add new exchangeable module here
    00230   */
    00231   static int getNumOfSolutions(ModuleID id)
    00232   {
    00233     switch (id)
    00234     {
    00235     case colorTableMod :return numOfColorTableModSolutions;
    00236     case imageProcessor: return numOfImageProcessorSolutions;
    00237     case selfLocator: return numOfSelfLocatorSolutions;
    00238     case behaviorControl: return numOfBehaviorControlSolutions;
    00239     case collisionDetector: return numOfCollisionDetectorSolutions;
    00240     case walkingEngineNormal: return numOfWalkingEngineSolutions;
    00241     case headControl: return numOfHeadControlSolutions;
    00242     case ledControl: return numOfLEDControlSolutions;
    00243     case ballLocator: return numOfBallLocatorSolutions;
    00244     case playersLocator: return numOfPlayersLocatorSolutions;
    00245     case obstaclesLocator: return numOfObstaclesLocatorSolutions;
    00246     case sensorDataProcessor: return numOfSensorDataProcessorSolutions;
    00247     case robotStateDetector: return numOfRobotStateDetectorSolutions;
    00248     case sensorBehaviorControl: return numOfSensorBehaviorControlSolutions;
    00249     case motionControl: return numOfMotionControlSolutions;
    00250     case getupEngine: return numOfGetupEngineSolutions;
    00251     case soundControl: return numOfSoundControlSolutions;
    00252     case teamBallLocator: return numOfTeamBallLocatorSolutions;
    00253     case gtCam: return numOfGTCamSolutions;
    00254
    00255     default: return 0;
    00256     }
    00257   }
    00258
    00259   /**
    00260   * Returns names for module solution ids.
    00261   * Add new solutions here.
    00262   */
    00263   static const char* getModuleSolutionName(ModuleID module, ModuleSolutionID solution)
    00264   {
    00265     if (solution == disabled) return "disabled";
    00266     switch (module)
    00267     {
    00268     case colorTableMod: switch (solution)
    00269                         {
    00270     case colorTable64Mod: return "ColorTable64Module";
    00271     case colorTable32KMod: return "ColorTable32KModule";
    00272                         }
    00273     case selfLocator: switch (solution)
    00274                       {
    00275     case gt2005SelfLocator: return "GT2005";
    00276     case gt2005StableSelfLocator: return "GT2005Stable";
    00277     case gtCamSelfLocator: return "GTCam";
    00278     case odometrySelfLocator: return "Odometry";
    00279     case slamSelfLocator: return "Slam";
    00280     case gt2004SelfLocator: return "GT2004";
    00281     case comboSelfLocator: return "Combo";
    00282                       }
    00283     case behaviorControl: switch (solution)
    00284                           {
    00285     case gt2005BehaviorControlAgentSoccer: return "GT2005-soccer";
    00286     case gt2005BehaviorControlAgentPenaltyShooter: return "GT2005-penalty-shooter";
    00287     case gt2005BehaviorControlAgentPenaltyShooter2: return "GT2005-penalty-shooter2";
    00288     case gt2005BehaviorControlAgentPenaltyGoalie: return "GT2005-penalty-goalie";
    00289     case gt2005BehaviorControlAgentJoystickControlled: return "GT2005-joystick-controlled";
    00290     case gt2005BehaviorControlAgentSlamChallange: return "GT2005-Slam-Behavior";
    00291     case gt2005BehaviorControlAgentVLCshooter: return "GT2005-VLC-shooter";
    00292     case gt2005BehaviorControlAgentVLC2shooter: return "GT2005-VLC2-shooter";
    00293     case gt2005BehaviorControlAgentObstacleAvoidanceChallange03: return "GT2005-Obstacle-Avoider";
    00294     case gt2005BehaviorControlAgentOdometryTester: return "GT2005-Odometry-Tester";
    00295     case gt2005BehaviorControlAgentKickLogger: return "GT2005-KickLogger";
    00296     case gt2005BehaviorControlAgentBasicsTester: return "GT2005-basics-tester";
    00297                           }
    00298     case collisionDetector: switch (solution)
    00299                             {
    00300     case gt2005CollisionDetector: return "GT2005";
    00301                             }
    00302     case walkingEngineNormal: switch (solution)
    00303                               {
    00304     case gt2005WalkingEngine: return "GT2005";
    00305     case gt2004WalkingEngine: return "GT2004";
    00306     case invKinUpsideDownWalkingEngine: return "InvKin:UpsideDown";
    00307     case invKinTurnWithBallWalkingEngine: return "InvKin:TurnWithBall";
    00308     case invKinTurnKickWalkingEngine: return "InvKin:invTurnKick";
    00309                               }
    00310     case headControl: switch (solution)
    00311                       {
    00312     case gt2005HeadControl: return "GT2005";
    00313                       }
    00314     case ledControl: switch (solution)
    00315                      {
    00316     case gt2005LEDControl: return "GT2005";
    00317                      }
    00318     case ballLocator: switch (solution)
    00319                       {
    00320     case gt2005BallLocator: return "GT2005";
    00321     case gtCamBallLocator: return "GTCam";
    00322                       }
    00323     case playersLocator: switch (solution)
    00324                          {
    00325     case gtCamPlayersLocator: return "GTCam";
    00326                          }
    00327     case obstaclesLocator: switch (solution)
    00328                            {
    00329     case gt2005ObstaclesLocator: return "GT2005";
    00330     case gtCamObstaclesLocator: return "GTCam";
    00331                            }
    00332     case imageProcessor: switch (solution)
    00333                          {
    00334     case gt2005ImageProcessor: return "GT2005";
    00335     case slamImageProcessor: return "SlamImageProcessor";
    00336     case vlcImageProcessor: return "VLCImageProcessor";
    00337                          }
    00338     case sensorDataProcessor: switch(solution)
    00339                               {
    00340     case gt2005SensorDataProcessor: return "GT2005";
    00341                               }
    00342     case robotStateDetector: switch (solution)
    00343                              {
    00344     case gt2005RobotStateDetector: return "GT2005";
    00345                              }
    00346     case sensorBehaviorControl: switch (solution)
    00347                                 {
    00348     case dummySensorBehaviorControl: return "Dummy";
    00349                                 }
    00350     case motionControl: switch (solution)
    00351                         {
    00352     case gt2005MotionControl: return "GT2005";
    00353     case debugMotionControl: return "Debug";
    00354                         }
    00355     case getupEngine: switch (solution)
    00356                       {
    00357     case gt2005GetupEngine: return "GT2005";
    00358                       }
    00359     case soundControl: switch (solution)
    00360                        {
    00361     case gt2005SoundControl: return "GT2005";
    00362                        }
    00363     case teamBallLocator: switch(solution)
    00364                           {
    00365     case gt2005TeamBallLocator: return "GT2005";
    00366                           }
    00367     case gtCam: switch(solution) {
    00368     case gtCamRaw: return "Raw";
    00369                 }
    00370
    00371     }
    00372     return "please edit SolutionRequest::getModuleSolutionName";
    00373   }
    00374
    00375   /** an array containing the selected solution for each module */
    00376   ModuleSolutionID solutions[numOfModules];
    00377
    00378   /** Constructor
    00379   * @param setDefault if true default modules will be selected else all modules are disabled
    00380   */
    00381   SolutionRequest(bool setDefault = false);
    00382
    00383   /**
    00384   * Returns default solution for module.
    00385   */
    00386   static ModuleSolutionID getDefaultSolution(ModuleID id)
    00387   {
    00388     static SolutionRequest defaultRequest(true);
    00389     return defaultRequest.solutions[id];
    00390   }
    00391
    00392   /**
    00393   * Sets all modules to default solutions.
    00394   */
    00395   void setDefaultSolutions();
    00396
    00397   /** the == operator */
    00398   bool operator == (const SolutionRequest& other);
    00399
    00400   /** the == operator */
    00401   bool operator != (const SolutionRequest& other)
    00402   { return ! (*this == other); }
    00403
    00404   /**
    00405   * ErrorWhileReading
    00406   * is set to true when an error occurred while reading the SolutionRequest
    00407   * eg when an module was missing or a solution was not recognized
    00408   */
    00409   bool errorWhileReading;
    00410
    00411   /** IDs for the module solutions using a Xabsl2Engine */
    00412   enum xabsl2EngineID
    00413   {
    00414     gt2005,
    00415     numOfXabslBehaviors,
    00416     hc_gt2005 = numOfXabslBehaviors,
    00417     undefined
    00418   };
    00419
    00420   /** returns the name of a xabsl2EngineID */
    00421   static const char* getXabsl2EngineIDName(xabsl2EngineID id)
    00422   {
    00423     switch (id)
    00424     {
    00425     case gt2005: return "GT2005";
    00426     case hc_gt2005: return "HC_GT2005";
    00427     default: return "unknown";
    00428     }
    00429   }
    00430
    00431   /** returns the beginning of the file name of a config file
    00432   * for a xabsl2Engine
    00433   */
    00434   static const char* getXabsl2EngineFileID(xabsl2EngineID id)
    00435   {
    00436     switch (id)
    00437     {
    00438     case gt2005: return "gt05";
    00439     case hc_gt2005: return "HeadCtrl/gt05";
    00440     default: return "unknown";
    00441     }
    00442   }
    00443 };
    00444
    00445 /**
    00446 * Streaming operator that reads a SolutionRequest from a stream.
    00447 * @param stream The stream from which is read.
    00448 * @param solutionRequest The SolutionRequest object.
    00449 * @return The stream.
    00450 */
    00451 In& operator>>(In& stream,SolutionRequest& solutionRequest);
    00452
    00453 /**
    00454 * Streaming operator that writes a SolutionRequest to a stream.
    00455 * @param stream The stream to write on.
    00456 * @param solutionRequest The SolutionRequest object.
    00457 * @return The stream.
    00458 */
    00459 Out& operator<<(Out& stream, const SolutionRequest& solutionRequest);
    00460
    00461 #endif //__SolutionRequest_h_
    00462