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

# Tools/Debugging/DebugKeyTable.h

Go to the documentation of this file.

    00001 /**
    00002 * @file DebugKeyTable.h
    00003 * Declaration of class DebugKey and DebugKeyTable
    00004 *
    00005 * @author <A href=mailto:brunn@sim.informatik.tu-darmstadt.de>Ronnie Brunn</A>
    00006 * @author <A href=mailto:risler@sim.informatik.tu-darmstadt.de>Max Risler</A>
    00007 * @author Martin Lötzsch
    00008 */
    00009
    00010 #ifndef __DEBUGKEYTABLE_H__
    00011 #define __DEBUGKEYTABLE_H__
    00012
    00013 #include "Tools/Streams/InOut.h"
    00014
    00015 /**
    00016 * @class DebugKey
    00017 *
    00018 * Represents a request for debug output.
    00019 */
    00020 class DebugKey
    00021 {
    00022 public:
    00023   enum modes {
    00024     disabled, /*!< dont send anything */
    00025       always, /*!< always send the debug message */
    00026       n_times, /*!< send the debug message the next n times (frames) */
    00027       every_n_times, /*!< send the message every n times (frames) */
    00028       every_n_ms /*!< send the message at most every n milliseconds */
    00029   };
    00030
    00031   /** the mode of this DebugKey */
    00032   modes mode;
    00033
    00034   /** the parameter for timed or counted debug messages */
    00035   unsigned int n;
    00036
    00037   /** last time (ever_n_ms) or number of times (every_n_times, n_times) the message was sent */
    00038   unsigned long last;
    00039
    00040   /**
    00041   * Determines if the key is active in the current frame
    00042   * This is set by activateDebugKeys()
    00043   */
    00044   bool active;
    00045
    00046   /**
    00047   * construct a new DebugKey
    00048   */
    00049   DebugKey(modes mode=disabled, unsigned int n=0);
    00050
    00051   /** sets the mode and the parameter of a DebugKey */
    00052   void set(modes mode=always, unsigned int n=0);
    00053 };
    00054
    00055
    00056 /**
    00057 * Contains a table of debug keys and all methods for using debug keys.
    00058 *
    00059 * @author <A href=mailto:brunn@sim.informatik.tu-darmstadt.de>Ronnie Brunn</A>
    00060 * @author <A href=mailto:risler@sim.informatik.tu-darmstadt.de>Max Risler</A>
    00061 * @author Martin Lötzsch
    00062 */
    00063 class DebugKeyTable
    00064 {
    00065 public:
    00066 /**
    00067 * IDs for Debug Keys.
    00068 * enter new Debug Keys here and add the corresponding string in getDebugKeyName
    00069   */
    00070   enum debugKeyID {
    00071       sendImage,
    00072       sendJPEGImage,
    00073       sendLowResImage,
    00074       sendSensorData,
    00075       sendJointData,
    00076       sendOdometryData,
    00077       sendMotionInfo,
    00078       sendBodyPosture,
    00079       sendPercepts,
    00080       sendSpecialPercept,
    00081       sendWorldState,
    00082       sendGameControlData,
    00083       sendPlayerConfig,
    00084       sendSoundRequest,
    00085       sendOptionRatings,
    00086       sendKickRecords,
    00087
    00088       sendTimeOffsets,
    00089       printRobotStatus,
    00090       printCBBRules,
    00091       printPixelUsage,
    00092       learnWalking,
    00093       sendDDPInfo,
    00094       sendWalkingEngineInfo,
    00095       sendKickEngineInfo,
    00096
    00097       sendMSHBallLocatorEvolution,
    00098
    00099       numOfDebugKeysForDebugKeyToolbar,
    00100
    00101       sendXabsl2DebugMessagesForBehaviorControl,
    00102       sendXabsl2DebugMessagesForHeadControl,
    00103       sendColorTable64,
    00104       sendColorTableReferenceColor,
    00105       sendColorTableCuboids,
    00106
    00107       // histograms
    00108       sendHistogram_imageIntensityY,
    00109       sendHistogram_imageIntensityU,
    00110       sendHistogram_imageIntensityV,
    00111       sendHistogram_scanLineIntensityY,
    00112       sendHistogram_scanLineIntensityU,
    00113       sendHistogram_scanLineIntensityV,
    00114       sendHistogram_colorFrequency,
    00115       sendHistogram_lengthOfSegments,
    00116
    00117       //image drawings
    00118       send_selfLocator_drawing,
    00119       send_imageProcessor_general_drawing,
    00120       send_imageProcessor_horizon_drawing,
    00121       send_imageProcessor_scanLines_drawing,
    00122       send_imageProcessor_coloredSegments1_drawing,
    00123       send_imageProcessor_coloredSegments2_drawing,
    00124       send_imageProcessor_coloredSegments3_drawing,
    00125       send_imageProcessor_calibration1_drawing,
    00126       send_imageProcessor_calibration2_drawing,
    00127       send_imageProcessor_ball1_drawing,
    00128       send_imageProcessor_ball2_drawing,
    00129       send_imageProcessor_ball3_drawing,
    00130       send_imageProcessor_ball4_drawing,
    00131       send_imageProcessor_ground_drawing,
    00132       send_imageProcessor_flagsAndGoals_drawing,
    00133       send_imageProcessor_obstacles_drawing,
    00134       send_imageProcessor_gradients_drawing,
    00135       send_imageProcessor_edges_drawing,
    00136       send_imageProcessor_lines_drawing,
    00137       send_imageProcessor_linefragments_drawing,
    00138       send_imageProcessor_robot_detection_drawing,
    00139       send_sketch_drawing,
    00140       send_imageProcessor_multipleBallPercepts_drawing,
    00141       send_circlePoints_image_drawing,
    00142
    00143       //field drawings
    00144       send_selfLocatorField_drawing,
    00145       send_teamBallLocatorFieldParticles_drawing,
    00146       send_teamBallLocatorField_drawing,
    00147       send_comboBallLocatorField_drawing,
    00148       send_comboTeamBallLocatorField_drawing,
    00149       send_ballLocatorField_drawing,
    00150       send_goaliePositionField_drawing,
    00151       send_headControlField_drawing,
    00152       send_playerModelField_drawing,
    00153       // send_obstaclesLocatorField_drawing,
    00154       send_behavior_CBBVector_drawing,
    00155       send_behavior_CBBWay_drawing,
    00156       send_behavior_kickAngles_drawing,
    00157       send_behavior_aStarSearch_drawing,
    00158       send_dribbleBall_drawing,
    00159       send_percepts_robot_drawing,
    00160
    00161       send_lineCrossingsField_drawing,
    00162       send_multipleBallPerceptsField_drawing,
    00163       send_circlePoints_Field_drawing,
    00164
    00165       //radar drawings
    00166       send_behavior_kickAnglesRadar_drawing,
    00167       send_models_corridorsRadar_drawing,
    00168
    00169       //debug images
    00170       send_segmentedImage1_image,
    00171       send_segmentedImage2_image,
    00172       send_segmentedImage3_image,
    00173       send_classificationY_image,
    00174       send_classificationU_image,
    00175       send_classificationV_image,
    00176       send_colorFrequency_image,
    00177       send_imageProcessorGeneral_image,
    00178       send_imageProcessorScanLines_image,
    00179       send_imageProcessorBall_image,
    00180       send_imageProcessorGoal1_image,
    00181       send_imageProcessorGoal2_image,
    00182       send_imageProcessorFlags_image,
    00183       send_imageProcessorPlayers_image,
    00184       send_imageProcessorGradients_image,
    00185       send_imageMotionRecognition_image,
    00186       send_imageProcessorRobotDetection_image,
    00187
    00188       //times
    00189       sendImageProcessorTime,
    00190       sendSensorDataProcessorTime,
    00191       sendBallLocatorTime,
    00192       sendTeamBallLocatorTime,
    00193       sendSelfLocatorTime,
    00194       sendPlayersLocatorTime,
    00195       sendObstaclesLocatorTime,
    00196       sendBehaviorControlTime,
    00197       sendMotionControlTime,
    00198       sendSoundControlTime,
    00199       sendSpecialVisionTime,
    00200       sendPerceptBehaviorControlTime,
    00201       sendSensorBehaviorControlTime,
    00202       sendHeadControlTime,
    00203       sendCollisionDetectorTime,
    00204       sendRobotStateDetectorTime,
    00205
    00206       sendGTCamWorldState,
    00207       sendATH2005SLInfo,
    00208       numOfDebugKeys,
    00209
    00210       // aliases
    00211       send_imageProcessorGoals_image = send_imageProcessorGoal1_image
    00212   } ;
    00213
    00214   /**
    00215   * returns the DebugKey's name
    00216   */
    00217   static char* getDebugKeyName (debugKeyID aID)
    00218   {
    00219     switch (aID) {
    00220     case sendImage: return "sendImage";
    00221     case sendJPEGImage: return "sendJPEGImage";
    00222     case sendLowResImage: return "sendLowResImage";
    00223     case sendSensorData: return "sendSensorData";
    00224     case sendJointData: return "sendJointData";
    00225     case sendOdometryData: return "sendOdometryData";
    00226     case sendMotionInfo: return "sendMotionInfo";
    00227     case sendBodyPosture: return "sendBodyPosture";
    00228     case sendPercepts: return "sendPercepts";
    00229     case sendSpecialPercept: return "sendSpecialPercept";
    00230     case sendWorldState: return "sendWorldState";
    00231     case sendGameControlData: return "sendGameControlData";
    00232     case sendPlayerConfig: return "sendPlayerConfig";
    00233     case sendSoundRequest: return "sendSoundRequest";
    00234
    00235     case sendXabsl2DebugMessagesForBehaviorControl: return "sendXabsl2DebugMessagesForBehaviorControl";
    00236     case sendXabsl2DebugMessagesForHeadControl: return "sendXabsl2DebugMessagesForHeadControl";
    00237     case sendTimeOffsets: return "sendTimeOffsets";
    00238     case sendColorTable64: return "sendColorTable64";
    00239     case sendColorTableCuboids: return "sendColorTableCuboids";
    00240     case sendColorTableReferenceColor: return "sendColorTableReferenceColor";
    00241     case printRobotStatus: return "printRobotStatus";
    00242     case printCBBRules: return "printCBBRules";
    00243     case printPixelUsage: return "printPixelUsage";
    00244     case learnWalking: return "learnWalking";
    00245     case sendDDPInfo: return "printDogDiscoveryProtocolInformation";
    00246     case sendKickRecords: return "sendKickRecords";
    00247     case sendWalkingEngineInfo: return "sendWalkingEngineInfo";
    00248     case sendKickEngineInfo: return "sendKickEngineInfo";
    00249     case sendATH2005SLInfo: return "sendATH2005SLInfo";
    00250     case sendMSHBallLocatorEvolution: return "sendMSHBallLocatorEvolution";
    00251
    00252       // histograms
    00253     case sendHistogram_imageIntensityY: return "sendHistogram_imageIntensityY";
    00254     case sendHistogram_imageIntensityU: return "sendHistogram_imageIntensityU";
    00255     case sendHistogram_imageIntensityV: return "sendHistogram_imageIntensityV";
    00256     case sendHistogram_scanLineIntensityY: return "sendHistogram_scanLineIntensityY";
    00257     case sendHistogram_scanLineIntensityU: return "sendHistogram_scanLineIntensityU";
    00258     case sendHistogram_scanLineIntensityV: return "sendHistogram_scanLineIntensityV";
    00259     case sendHistogram_colorFrequency: return "sendHistogram_colorFrequency";
    00260     case sendHistogram_lengthOfSegments: return "sendHistogram_lengthOfSegments";
    00261
    00262       //image drawings
    00263     case send_selfLocator_drawing: return "send_selfLocator_drawing";
    00264     case send_imageProcessor_general_drawing: return "send_imageProcessor_general_drawing";
    00265     case send_imageProcessor_horizon_drawing: return "send_imageProcessor_horizon_drawing";
    00266     case send_imageProcessor_scanLines_drawing: return "send_imageProcessor_scanLines_drawing";
    00267     case send_imageProcessor_coloredSegments1_drawing: return "send_imageProcessor_coloredSegments1_drawing";
    00268     case send_imageProcessor_coloredSegments2_drawing: return "send_imageProcessor_coloredSegments2_drawing";
    00269     case send_imageProcessor_coloredSegments3_drawing: return "send_imageProcessor_coloredSegments3_drawing";
    00270     case send_imageProcessor_calibration1_drawing: return "send_imageProcessor_calibration1_drawing";
    00271     case send_imageProcessor_calibration2_drawing: return "send_imageProcessor_calibration2_drawing";
    00272     case send_imageProcessor_ball1_drawing: return "send_imageProcessor_ball1_drawing";
    00273     case send_imageProcessor_ball2_drawing: return "send_imageProcessor_ball2_drawing";
    00274     case send_imageProcessor_ball3_drawing: return "send_imageProcessor_ball3_drawing";
    00275     case send_imageProcessor_ball4_drawing: return "send_imageProcessor_ball4_drawing";
    00276     case send_imageProcessor_ground_drawing: return "send_imageProcessor_ground_drawing";
    00277     case send_imageProcessor_flagsAndGoals_drawing: return "send_imageProcessor_flagsAndGoals_drawing";
    00278     case send_imageProcessor_obstacles_drawing: return "send_imageProcessor_obstacles_drawing";
    00279     case send_imageProcessor_gradients_drawing: return "send_imageProcessor_gradients_drawing";
    00280     case send_imageProcessor_edges_drawing: return "send_imageProcessor_edges_drawing";
    00281     case send_imageProcessor_lines_drawing: return "send_imageProcessor_lines_drawing";
    00282     case send_imageProcessor_linefragments_drawing: return "send_imageProcessor_linefragments_drawing";
    00283     case send_imageProcessor_robot_detection_drawing: return "send_imageProcessor_robot_detection_drawing";
    00284     case send_sketch_drawing: return "send_sketch_drawing";
    00285     case send_imageProcessor_multipleBallPercepts_drawing: return "send_imageProcessor_multipleBallPercepts_drawing";
    00286     case send_circlePoints_image_drawing: return "send_circlePoints_image_drawing";
    00287
    00288       // field drawings
    00289     case send_ballLocatorField_drawing: return "send_ballLocatorField_drawing";
    00290     case send_goaliePositionField_drawing: return "send_goaliePositionField_drawing";
    00291     case send_selfLocatorField_drawing: return "send_selfLocatorField_drawing";
    00292     case send_headControlField_drawing: return "send_headControlField_drawing";
    00293     case send_teamBallLocatorFieldParticles_drawing: return "send_teamBallLocatorFieldParticles_drawing";
    00294     case send_teamBallLocatorField_drawing: return "send_teamBallLocatorField_drawing";
    00295     case send_comboBallLocatorField_drawing: return "send_comboBallLocatorField_drawing";
    00296     case send_comboTeamBallLocatorField_drawing: return "send_comboTeamBallLocatorField_drawing";
    00297     case send_playerModelField_drawing: return "send_playerModelField_drawing";
    00298       //    case send_obstaclesLocatorField_drawing: return "send_obstaclesLocatorField_drawing";
    00299     case send_behavior_CBBVector_drawing: return "send_behavior_CBBVector_drawing";
    00300     case send_behavior_CBBWay_drawing: return "send_behavior_CBBWay_drawing";
    00301     case send_behavior_kickAngles_drawing: return "send_behavior_kickAngles_drawing";
    00302     case send_behavior_aStarSearch_drawing: return "send_behavior_aStarSearch_drawing";
    00303     case send_dribbleBall_drawing: return "send_dribbleBall_drawing";
    00304     case send_percepts_robot_drawing: return "send_percept_robot_drawing";
    00305
    00306     case send_lineCrossingsField_drawing: return "send_lineCrossingsField_drawing";
    00307     case send_multipleBallPerceptsField_drawing: return "send_multipleBallPerceptsField_drawing";
    00308     case send_circlePoints_Field_drawing: return "send_circlePoints_Field_drawing";
    00309
    00310       // radar drawings
    00311     case send_models_corridorsRadar_drawing: return "send_models_corridorsRadar";
    00312     case send_behavior_kickAnglesRadar_drawing: return "send_behavior_kickAnglesRadar_drawing";
    00313
    00314       // debug images
    00315     case send_segmentedImage1_image: return "send_segmentedImage1_image";
    00316     case send_segmentedImage2_image: return "send_segmentedImage2_image";
    00317     case send_segmentedImage3_image: return "send_segmentedImage3_image";
    00318     case send_classificationY_image: return "send_classificationY_image";
    00319     case send_classificationU_image: return "send_classificationU_image";
    00320     case send_classificationV_image: return "send_classificationV_image";
    00321     case send_colorFrequency_image: return "send_colorFrequency_image";
    00322     case send_imageProcessorGeneral_image: return "send_imageProcessorGeneral_image";
    00323     case send_imageProcessorScanLines_image: return "send_imageProcessorScanLines_image";
    00324     case send_imageProcessorBall_image: return "send_imageProcessorBall_image";
    00325     case send_imageProcessorGoal1_image: return "send_imageProcessorGoal1_image";
    00326     case send_imageProcessorGoal2_image: return "send_imageProcessorGoal2_image";
    00327     case send_imageProcessorFlags_image: return "send_imageProcessorFlags_image";
    00328     case send_imageProcessorPlayers_image: return "send_imageProcessorPlayers_image";
    00329     case send_imageProcessorGradients_image: return "send_imageProcessorGradients_image";
    00330   case send_imageMotionRecognition_image: return "send_imageMotionRecognition_image";
    00331     case send_imageProcessorRobotDetection_image: return "send_imageProcessorRobotDetection_image";
    00332
    00333       // times
    00334     case sendImageProcessorTime: return "sendImageProcessorTime";
    00335     case sendSensorDataProcessorTime: return "sendSensorDataProcessorTime";
    00336     case sendBallLocatorTime: return "sendBallLocatorTime";
    00337     case sendTeamBallLocatorTime: return "sendTeamBallLocatorTime";
    00338     case sendSelfLocatorTime: return "sendSelfLocatorTime";
    00339     case sendPlayersLocatorTime: return "sendPlayersLocatorTime";
    00340     case sendObstaclesLocatorTime: return "sendObstaclesLocatorTime";
    00341     case sendBehaviorControlTime: return "sendBehaviorControlTime";
    00342     case sendMotionControlTime: return "sendMotionControlTime";
    00343     case sendSoundControlTime: return "sendSoundControlTime";
    00344     case sendSpecialVisionTime: return "sendSpecialVisionTime";
    00345     case sendPerceptBehaviorControlTime: return "sendPerceptBehaviorControlTime";
    00346     case sendSensorBehaviorControlTime: return "sendSensorBehaviorControlTime";
    00347     case sendHeadControlTime: return "sendHeadControlTime";
    00348     case sendCollisionDetectorTime: return "sendCollisionDetectorTime";
    00349     case sendRobotStateDetectorTime: return "sendRobotStateDetectorTime";
    00350       //option ratings
    00351     case sendOptionRatings: return "sendOptionRatings";
    00352
    00353     default: return "please edit DebugKeyTable::getDebugKeyName!";
    00354     }
    00355   }
    00356
    00357 protected:
    00358 /**
    00359 * The Debug Key Table
    00360   */
    00361   DebugKey debugKeys[numOfDebugKeys];
    00362
    00363 public:
    00364   /** Constructor, resets the table */
    00365   DebugKeyTable();
    00366
    00367   /** sets a debug key */
    00368   void set(debugKeyID id, DebugKey::modes mode=DebugKey::always, int n=0);
    00369
    00370   /** sets only the mode of a debug key */
    00371   void setMode(debugKeyID id, DebugKey::modes mode);
    00372
    00373   /** sets only the parameter n of a debug key */
    00374   void setN(debugKeyID id, unsigned int n);
    00375
    00376   /** returns the mode of a debug key */
    00377   DebugKey::modes getMode(debugKeyID id) const;
    00378
    00379   /** returns the parameter n of a debug key */
    00380   unsigned int getN(debugKeyID id) const;
    00381
    00382   /** returns whether an debug Key is active in the current frame */
    00383   bool isActive (debugKeyID id) const;
    00384
    00385   /** resets all debug keys to disabled */
    00386   void reset();
    00387
    00388   /** Determines for all keys if they are active in the current frame */
    00389   void activate();
    00390
    00391   /** the == operator */
    00392   bool operator == (const DebugKeyTable& other);
    00393
    00394   /** the != operator */
    00395   bool operator != (const DebugKeyTable& other)
    00396   { return ! (*this == other); }
    00397 };
    00398
    00399 /**
    00400 * Streaming operator that reads a DebugKeyTable from a stream.
    00401 * @param stream The stream from which is read.
    00402 * @param debugKeyTable The DebugKeyTable object.
    00403 * @return The stream.
    00404 */
    00405 In& operator>>(In& stream,DebugKeyTable& debugKeyTable);
    00406
    00407 /**
    00408 * Streaming operator that writes a DebugKeyTable to a stream.
    00409 * @param stream The stream to write on.
    00410 * @param debugKeyTable The DebugKeyTable object.
    00411 * @return The stream.
    00412 */
    00413 Out& operator<<(Out& stream, DebugKeyTable& debugKeyTable);
    00414
    00415
    00416 #endif //__DEBUGKEYTABLE_H__