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

Tools/KickSelectionTable.h

Go to the documentation of this file.
00001 /** 
00002 * @file KickSelectionTable.h
00003 * Declaration of class KickSelectionTable.
00004 *
00005 * @author <A href=mailto:juengel@informatik.hu-berlin.de>Matthias Jüngel</A>
00006 * @author Martin Lötzsch
00007 */
00008 
00009 #ifndef _KickSelectionTable_h_
00010 #define _KickSelectionTable_h_
00011 
00012 #include "Tools/Math/Vector2.h"
00013 #include "Platform/GTAssert.h"
00014 #include "Representations/Motion/MotionRequest.h"
00015 
00016 /**
00017 * Represents the results and the preconditions of a single kick experiment
00018 * @author Martin Lötzsch
00019 */
00020 class KickCase
00021 {
00022 public:
00023   /** The relative x position of the ball when the kick was requested */
00024   double ballXR;
00025 
00026   /** The relative y position of the ball when the kick was requested */
00027   double ballYR;
00028 
00029   /** The time since the ball was seen last when the kick was requested */
00030   unsigned long ballTR;
00031 
00032   /** The relative x position of the ball when the kick was started */
00033   double ballXS;
00034 
00035   /** The relative y position of the ball when the kick was started */
00036   double ballYS;
00037 
00038   /** The time since the ball was seen last when the kick was started */
00039   unsigned long ballTS;
00040 
00041   /** The relative x position of the ball after the kick */
00042   double ballXA;
00043 
00044   /** The relative y position of the ball after the kick */
00045   double ballYA;
00046 
00047   /** The time since the kick was finished when the record was written */
00048   unsigned long tA;
00049 
00050 };
00051 
00052 /**
00053 * @class KickSelectionTable
00054 *
00055 * @author <A href=mailto:juengel@informatik.hu-berlin.de>Matthias Jüngel</A>
00056 * @author Martin Lötzsch
00057 *
00058 * Provides for a set of tables which provides a kick selection depending 
00059 * on a desired kick angle and ball position.
00060 */
00061 class KickSelectionTable
00062 {
00063 public:
00064   /** Constructor */
00065   KickSelectionTable();
00066   
00067   /** Destructor */
00068   ~KickSelectionTable();
00069   
00070   /** Ids for all possible actions */
00071   enum ActionID{
00072     nothing = 0,
00073       headLeft,
00074       headRight,
00075       anyLeft,
00076       anyRight,
00077       hookLeft,
00078       hookRight,
00079       leftPaw,
00080       rightPaw,
00081       armLeft,
00082       armRight,
00083       pushSoft,
00084       pushStrong,
00085       chestSoft,
00086       chestStrong,
00087       putRight,
00088       putLeft,
00089       forwardKickFast,
00090       forwardKickHard,
00091       slapRight,
00092       slapLeft,
00093       headLeftSoft,
00094       headRightSoft,
00095       numberOfActions
00096   };
00097   
00098   /** returns names for action ids */
00099   static const char* getActionName(ActionID id)
00100   {
00101     switch (id)
00102     {
00103     case nothing: return "nothing";
00104     case headLeft: return "headLeft"; 
00105     case headRight: return "headRight";
00106     case anyLeft: return "anyLeft";
00107     case anyRight: return "anyRight";
00108     case hookLeft: return "hookLeft";
00109     case hookRight: return "hookRight";
00110     case leftPaw: return "leftPaw";
00111     case rightPaw: return "rightPaw";
00112     case armLeft: return "armLeft";
00113     case armRight: return "armRight";
00114     case pushSoft: return "pushSoft";
00115     case pushStrong: return "pushStrong";
00116     case chestSoft: return "chestSoft";
00117     case chestStrong: return "chestStrong";
00118     case putRight: return "putRight";
00119     case putLeft: return "putLeft";
00120     case forwardKickFast: return "forwardKickFast";
00121     case forwardKickHard: return "forwardKickHard";
00122     case slapRight: return "slapRight";
00123     case slapLeft: return "slapLeft";
00124     case headLeftSoft: return "headLeftSoft";
00125     case headRightSoft: return "headRightSoft";
00126 
00127     default: return "please edit KickSelectionTable::getActionName";
00128     }
00129   }
00130   
00131   /** returns short names for action ids (used by streaming operator)*/
00132   static const char* getShortActionName(ActionID id)
00133   {
00134     switch (id)
00135     {
00136     case nothing: return "no";
00137     case headLeft: return "head_l"; 
00138     case headRight: return "head_r";
00139     case anyLeft: return "any_l";
00140     case anyRight: return "any_r";
00141     case hookLeft: return "hook_l";
00142     case hookRight: return "hook_r";
00143     case leftPaw: return "l_paw";
00144     case rightPaw: return "r_paw";
00145     case armLeft: return "arm_l";
00146     case armRight: return "arm_r";
00147     case pushSoft: return "push_so";
00148     case pushStrong: return "pu_str";
00149     case chestSoft: return "che_so";
00150     case chestStrong: return "ch_str";
00151     case putRight: return "put_r";
00152     case putLeft: return "put_l";
00153     case forwardKickFast: return "forw_f";
00154     case forwardKickHard: return "forw_h";
00155     case slapRight: return "slap_r";
00156     case slapLeft: return "slap_l";
00157     case headLeftSoft: return "head_sl";
00158     case headRightSoft: return "head_sr";
00159 
00160     default: 
00161       ASSERT(false);
00162       return 0;
00163     }
00164   }
00165   
00166   /** IDs for different kick selection tables */
00167   enum KickSelectionTableID
00168   {
00169     inCenterOfField, 
00170       atLeftBorder, 
00171       atRightBorder, 
00172       atLeftOpponentBorder, 
00173       atRightOpponentBorder, 
00174       nearOwnGoal, 
00175       goalie,
00176       whenStuck,
00177       numberOfKickSelectionTableIDs
00178   };
00179   
00180   /** returns a name for an action table id */
00181   static const char* getKickSelectionTableIDName(KickSelectionTableID id)
00182   {
00183     switch (id)
00184     {
00185     case inCenterOfField: return "inCenterOfField";
00186     case atLeftBorder: return "atLeftBorder";
00187     case atRightBorder: return "atRightBorder";
00188     case atLeftOpponentBorder: return "atLeftOpponentBorder";
00189     case atRightOpponentBorder: return "atRightOpponentBorder";
00190     case nearOwnGoal: return "nearOwnGoal"; 
00191     case goalie: return "goalie";
00192     case whenStuck: return "whenStuck";
00193     default: 
00194       ASSERT(false);
00195       return 0;
00196     }
00197   }
00198   
00199   /** Returns an action id for a special action id */
00200   static const ActionID getActionIDFromSpecialActionID(SpecialActionRequest::SpecialActionID id)
00201   {
00202     switch (id)
00203     {
00204       case SpecialActionRequest::headLeft: return headLeft; 
00205       case SpecialActionRequest::headRight: return headRight;
00206       case SpecialActionRequest::anyLeft: return anyLeft;
00207       case SpecialActionRequest::anyRight: return anyRight;
00208       case SpecialActionRequest::hookLeft: return hookLeft;
00209       case SpecialActionRequest::hookRight: return hookRight;
00210       case SpecialActionRequest::leftPaw: return leftPaw;
00211       case SpecialActionRequest::rightPaw: return rightPaw;
00212       case SpecialActionRequest::armLeft: return armLeft;
00213       case SpecialActionRequest::armRight: return armRight;
00214       case SpecialActionRequest::pushSoft: return pushSoft;
00215       case SpecialActionRequest::pushStrong: return pushStrong;
00216       case SpecialActionRequest::chestSoft: return chestSoft;
00217       case SpecialActionRequest::putRight: return putRight;
00218       case SpecialActionRequest::putLeft: return putLeft;
00219       case SpecialActionRequest::forwardKickFast: return forwardKickFast;
00220       case SpecialActionRequest::forwardKickHard: return forwardKickHard;
00221       case SpecialActionRequest::slapRight: return slapRight;
00222       case SpecialActionRequest::slapLeft: return slapLeft;
00223       case SpecialActionRequest::headLeftSoft: return headLeftSoft;
00224       case SpecialActionRequest::headRightSoft: return headRightSoft;
00225       default: return nothing;
00226     }
00227   }
00228   
00229   /**  */ 
00230   enum{xRange = 20}; 
00231   
00232   /**  */ 
00233   enum{yRange = 40};
00234   
00235   /**  */ 
00236   enum{numberOfSectors = 12};
00237   
00238   /** 
00239   * Calculates the best kick based on the position of the ball relative to the 
00240   * robot and a target angle. 
00241   */
00242   ActionID retrieveKick(
00243     double ballOffsetX, double ballOffsetY, 
00244     double destinationAngle,
00245     KickSelectionTableID kickSelectionTableID
00246     ) const;
00247   
00248   /** The action tables */
00249   ActionID action[xRange][yRange][numberOfSectors][numberOfKickSelectionTableIDs];
00250   
00251   /** Returns a table id for a name */
00252   static KickSelectionTableID getTableIDFromName(const char* name);
00253   
00254   /** Returns an action id for a short name */
00255   static ActionID getActionIDFromShortName(const char* name);
00256   
00257   /** Loads a kick selection table from a file */
00258   void load(const char* fileName);
00259 };
00260 
00261 /**
00262 * Streaming operator that reads KickSelectionTable from a stream.
00263 * @param stream The stream from which is read.
00264 * @param kickSelectionTable The KickSelectionTable object.
00265 * @return The stream.
00266 */ 
00267 In& operator>>(In& stream, KickSelectionTable& kickSelectionTable);
00268 
00269 /**
00270 * Streaming operator that writes KickSelectionTable to a stream.
00271 * @param stream The stream to write on.
00272 * @param kickSelectionTable The KickSelectionTable object.
00273 * @return The stream.
00274 */ 
00275 Out& operator<<(Out& stream, const KickSelectionTable& kickSelectionTable);
00276 
00277 /**
00278 * Streaming operator that reads KickCase from a stream.
00279 * @param stream The stream from which is read.
00280 * @param kickCase The KickCase object.
00281 * @return The stream.
00282 */ 
00283 In& operator>>(In& stream, KickCase& kickCase);
00284 
00285 /**
00286 * Streaming operator that writes KickCase to a stream.
00287 * @param stream The stream to write on.
00288 * @param kickCase The KickCase object.
00289 * @return The stream.
00290 */ 
00291 Out& operator<<(Out& stream, const KickCase& kickCase);
00292 
00293 
00294 #endif   //  _KickSelectionTable_h_
00295 
00296 /*
00297 * Change log :
00298 * 
00299 * $Log: KickSelectionTable.h,v $
00300 * Revision 1.7  2004/07/02 16:04:54  risler
00301 * added headLeft/RightSoft
00302 *
00303 * Revision 1.6  2004/07/01 12:02:12  risler
00304 * slapLeft/Right added
00305 *
00306 * Revision 1.5  2004/06/30 19:56:55  risler
00307 * added when-stuck kick table
00308 * handle-ball-... options use when-stuck kick table when average ball distance is low
00309 *
00310 * Revision 1.4  2004/06/30 08:37:53  lohmann
00311 * Added forwardKickHard and forwardKickFast
00312 *
00313 * Revision 1.3  2004/06/20 15:22:35  risler
00314 * increased kick editor usability:
00315 * KickLogger now sends kick record via debug key instead of writing to file
00316 * KickEditor automatically displays sent kick records
00317 * KickCase moved to KickSelectionTable
00318 *
00319 * Revision 1.2  2004/05/27 14:37:27  loetzsch
00320 * new actions in the kick selection table
00321 *
00322 * Revision 1.1.1.1  2004/05/22 17:35:53  cvsadm
00323 * created new repository GT2004_WM
00324 *
00325 * Revision 1.9  2004/05/04 18:10:01  juengel
00326 * Added short names for msh kicks
00327 *
00328 * Revision 1.8  2004/05/04 14:44:37  loetzsch
00329 * added a few kicks
00330 *
00331 * Revision 1.7  2004/04/05 17:56:50  loetzsch
00332 * merged the local German Open CVS of the aibo team humboldt with the tamara CVS
00333 *
00334 * Revision 1.3  2004/04/03 15:31:10  juengel
00335 * bug fixed
00336 *
00337 * Revision 1.2  2004/04/03 01:29:25  loetzsch
00338 * added arm kicks
00339 *
00340 * Revision 1.1.1.1  2004/03/31 11:17:00  loetzsch
00341 * created ATH repository for german open 2004
00342 *
00343 * Revision 1.6  2004/03/28 16:02:01  juengel
00344 * beautified
00345 *
00346 * Revision 1.5  2004/03/27 20:33:22  loetzsch
00347 * added table id for goalie
00348 *
00349 * Revision 1.4  2004/03/19 21:19:28  altmeyer
00350 * SideHeadKick and SideHeadKick2 changed and renamed to SideHeadKick L and SideHeadKickR
00351 * a few ATH ERS7-kicks removed
00352 *
00353 * Revision 1.3  2004/03/17 19:55:55  juengel
00354 * Comments added.
00355 *
00356 * Revision 1.2  2004/03/16 16:26:16  altmeyer
00357 * added new ATH-ERS7 kicks
00358 *
00359 * Revision 1.1  2004/03/16 14:00:23  juengel
00360 * Integrated Improvments from "Günne"
00361 * -ATH2004ERS7Behavior
00362 * -ATHHeadControl
00363 * -KickSelectionTable
00364 * -KickEditor
00365 *
00366 * Revision 1.11  2004/03/11 17:29:11  juengel
00367 * Added kicks with head.
00368 *
00369 * Revision 1.10  2004/03/11 11:40:28  loetzsch
00370 * renamed fastHeadKickRight to headKickRight
00371 *
00372 * Revision 1.9  2004/03/10 18:41:00  loetzsch
00373 * first functioning version
00374 *
00375 * Revision 1.8  2004/03/10 14:06:04  juengel
00376 * Implemented retrieveKick.
00377 *
00378 * Revision 1.7  2004/03/09 18:48:58  juengel
00379 * Added ActionID "nothing".
00380 *
00381 * Revision 1.6  2004/03/09 18:43:45  juengel
00382 * Added ActionID "nothing".
00383 *
00384 * Revision 1.5  2004/03/09 18:41:09  loetzsch
00385 * no message
00386 *
00387 * Revision 1.4  2004/03/09 14:56:37  loetzsch
00388 * bug fix
00389 *
00390 * Revision 1.3  2004/03/09 14:54:09  loetzsch
00391 * changed comments
00392 *
00393 * Revision 1.2  2004/03/09 14:45:27  loetzsch
00394 * automated generation of kick-selection-symbols.xml
00395 *
00396 * Revision 1.1  2004/03/09 13:40:30  juengel
00397 * Moved KickSelectionTable to Tools.
00398 *
00399 * Revision 1.1  2004/03/09 01:14:36  juengel
00400 * Added class KickSelectionTable.
00401 *
00402 */

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