00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __DebugDrawings_h_
00009 #define __DebugDrawings_h_
00010
00011 #include "Tools/Debugging/Debugging.h"
00012 #include "Tools/Debugging/DebugKeyTable.h"
00013
00014
00015
00016
00017
00018
00019 class Drawings
00020 {
00021 public:
00022
00023
00024
00025
00026 enum ShapeType
00027 {
00028 circle, filledCircle, line, dot, largeDot, octangle, arrow
00029 };
00030
00031
00032
00033
00034
00035 enum FieldDrawing
00036 {
00037
00038 fieldPolygons,
00039 fieldLines,
00040
00041
00042 percepts_ballFlagsGoalsField,
00043 percepts_obstaclesAndPSDField,
00044 percepts_specialField,
00045
00046
00047 worldStateOracle,
00048 worldState,
00049 models_obstaclesField,
00050
00051
00052 selfLocatorField,
00053 ballLocatorField,
00054 goaliePositionField,
00055 headControlField,
00056 teamBallLocatorField,
00057
00058
00059 behavior_CBBVector,
00060 behavior_CBBWay,
00061 behavior_kickAngles,
00062 behavior_aStarSearch,
00063
00064 dribbleBall,
00065
00066
00067 firstDrawingInRadarViewer,
00068 percepts_ballFlagsGoalsRadar = firstDrawingInRadarViewer,
00069 percepts_obstaclesAndPSDRadar,
00070 models_obstaclesRadar,
00071 models_corridorsRadar,
00072 behavior_kickAnglesRadar,
00073
00074 numberOfFieldDrawings
00075 };
00076
00077
00078
00079
00080
00081 enum ImageDrawing
00082 {
00083 percepts_ball,
00084 percepts_flagsGoals,
00085 percepts_freePartOfGoal,
00086 percepts_lines,
00087 percepts_edges,
00088 percepts_obstacles,
00089 percepts_psd,
00090 percepts_special,
00091 models_obstacles,
00092 models_freePartOfGoal,
00093 selfLocator,
00094 imageProcessor_general,
00095 imageProcessor_horizon,
00096 imageProcessor_scanLines,
00097 imageProcessor_coloredSegments1,
00098 imageProcessor_coloredSegments2,
00099 imageProcessor_coloredSegments3,
00100 imageProcessor_calibration1,
00101 imageProcessor_calibration2,
00102 imageProcessor_ball1,
00103 imageProcessor_ball2,
00104 imageProcessor_ball3,
00105 imageProcessor_ball4,
00106 imageProcessor_ground,
00107 imageProcessor_flagsAndGoals,
00108 imageProcessor_obstacles,
00109 imageProcessor_gradients,
00110 imageProcessor_edges,
00111 sketch,
00112 numberOfImageDrawings
00113 };
00114
00115 enum TypeOfDrawing
00116 {
00117 drawingOnField,
00118 drawingOnImage
00119 };
00120
00121 static TypeOfDrawing getTypeOfDrawing(FieldDrawing) {return drawingOnField;}
00122 static TypeOfDrawing getTypeOfDrawing(ImageDrawing) {return drawingOnImage;}
00123
00124
00125
00126
00127
00128 static const char* getDrawingName(FieldDrawing fieldDrawing)
00129 {
00130 switch (fieldDrawing)
00131 {
00132 case fieldPolygons: return "field polygons";
00133 case fieldLines: return "field lines";
00134
00135 case percepts_ballFlagsGoalsField: return "percepts: ball; flags; goals";
00136 case percepts_obstaclesAndPSDField: return "percepts: obstacles; PSD";
00137 case percepts_specialField: return "percepts: special";
00138
00139 case worldStateOracle: return "world state oracle";
00140 case worldState: return "world state";
00141 case models_obstaclesField: return "models: obstacles";
00142
00143 case selfLocatorField: return "self locator";
00144 case ballLocatorField: return "ball locator";
00145 case goaliePositionField: return "goalie position";
00146 case headControlField: return "head control";
00147 case teamBallLocatorField: return "team ball locator";
00148
00149 case behavior_CBBVector: return "behavior: CBBVector";
00150 case behavior_CBBWay: return "behavior: CBBWay";
00151 case behavior_kickAngles: return "behavior: kick angles";
00152 case behavior_aStarSearch: return "behavior: A* search tree";
00153 case dribbleBall: return "dribble Ball";
00154
00155 case percepts_ballFlagsGoalsRadar: return "radar - percepts: ball; flags; goals";
00156 case percepts_obstaclesAndPSDRadar: return "radar - percepts: obstacles; PSD";
00157 case models_obstaclesRadar: return "radar - models: obstacles";
00158 case models_corridorsRadar: return "radar - models: corridors";
00159 case behavior_kickAnglesRadar: return "radar - behavior: kick angles";
00160 default: return "check available drawings";
00161 }
00162 }
00163
00164
00165
00166
00167
00168 static const char* getDrawingName(ImageDrawing imageDrawing)
00169 {
00170 switch (imageDrawing)
00171 {
00172 case percepts_ball: return "percepts: ball";
00173 case percepts_flagsGoals: return "percepts: flags; goals";
00174 case percepts_freePartOfGoal: return "percepts: free part of goal";
00175 case percepts_lines: return "percepts: lines";
00176 case percepts_edges: return "percepts: edges";
00177 case percepts_obstacles: return "percepts: obstacles";
00178 case percepts_psd: return "percepts: psd";
00179 case percepts_special: return "percepts: special";
00180 case models_obstacles: return "models: obstacles";
00181 case models_freePartOfGoal: return "models: free part of goal";
00182 case selfLocator: return "self locator";
00183 case imageProcessor_general: return "image processor: general";
00184 case imageProcessor_horizon: return "image processor: horizon";
00185 case imageProcessor_scanLines: return "image processor: scan lines";
00186 case imageProcessor_coloredSegments1: return "image processor: colored segments1";
00187 case imageProcessor_coloredSegments2: return "image processor: colored segments2";
00188 case imageProcessor_coloredSegments3: return "image processor: colored segments3";
00189 case imageProcessor_calibration1: return "image processor: calibration 1";
00190 case imageProcessor_calibration2: return "image processor: calibration 2";
00191 case imageProcessor_ball1: return "image processor: ball 1";
00192 case imageProcessor_ball2: return "image processor: ball 2";
00193 case imageProcessor_ball3: return "image processor: ball 3";
00194 case imageProcessor_ball4: return "image processor: ball 4";
00195 case imageProcessor_ground: return "image processor: ground";
00196 case imageProcessor_flagsAndGoals: return "image processor: flags; goals";
00197 case imageProcessor_obstacles: return "image processor: obstacles";
00198 case imageProcessor_gradients: return "image processor: gradients";
00199 case imageProcessor_edges: return "image processor: edges";
00200 case sketch: return "sketch";
00201 default: return "check available drawings";
00202 }
00203 }
00204
00205 static bool getDebugKeyID(enum FieldDrawing fieldDrawing, DebugKeyTable::debugKeyID& debugKeyID)
00206 {
00207 switch (fieldDrawing)
00208 {
00209 case selfLocatorField: debugKeyID = DebugKeyTable::send_selfLocatorField_drawing; return true;
00210 case ballLocatorField: debugKeyID = DebugKeyTable::send_ballLocatorField_drawing; return true;
00211 case goaliePositionField: debugKeyID = DebugKeyTable::send_goaliePositionField_drawing; return true;
00212 case headControlField: debugKeyID = DebugKeyTable::send_headControlField_drawing; return true;
00213 case teamBallLocatorField: debugKeyID = DebugKeyTable::send_teamBallLocatorField_drawing; return true;
00214
00215 case behavior_CBBVector: debugKeyID = DebugKeyTable::send_behavior_CBBVector_drawing; return true;
00216 case behavior_CBBWay: debugKeyID = DebugKeyTable::send_behavior_CBBWay_drawing; return true;
00217 case behavior_kickAngles: debugKeyID = DebugKeyTable::send_behavior_kickAngles_drawing; return true;
00218 case behavior_aStarSearch: debugKeyID = DebugKeyTable::send_behavior_aStarSearch_drawing; return true;
00219 case dribbleBall: debugKeyID = DebugKeyTable::send_dribbleBall_drawing; return true;
00220
00221 case models_corridorsRadar: debugKeyID = DebugKeyTable::send_models_corridorsRadar_drawing; return true;
00222 case behavior_kickAnglesRadar: debugKeyID = DebugKeyTable::send_behavior_kickAnglesRadar_drawing; return true;
00223
00224 default: return false;
00225 }
00226 }
00227
00228 static bool getDebugKeyID(enum ImageDrawing imageDrawing, DebugKeyTable::debugKeyID& debugKeyID)
00229 {
00230 switch (imageDrawing)
00231 {
00232 case selfLocator: debugKeyID = DebugKeyTable::send_selfLocator_drawing; return true;
00233 case imageProcessor_general: debugKeyID = DebugKeyTable::send_imageProcessor_general_drawing; return true;
00234 case imageProcessor_horizon: debugKeyID = DebugKeyTable::send_imageProcessor_horizon_drawing; return true;
00235 case imageProcessor_scanLines: debugKeyID = DebugKeyTable::send_imageProcessor_scanLines_drawing; return true;
00236 case imageProcessor_coloredSegments1: debugKeyID = DebugKeyTable::send_imageProcessor_coloredSegments1_drawing; return true;
00237 case imageProcessor_coloredSegments2: debugKeyID = DebugKeyTable::send_imageProcessor_coloredSegments2_drawing; return true;
00238 case imageProcessor_coloredSegments3: debugKeyID = DebugKeyTable::send_imageProcessor_coloredSegments3_drawing; return true;
00239 case imageProcessor_calibration1: debugKeyID = DebugKeyTable::send_imageProcessor_calibration1_drawing; return true;
00240 case imageProcessor_calibration2: debugKeyID = DebugKeyTable::send_imageProcessor_calibration2_drawing; return true;
00241 case imageProcessor_ball1: debugKeyID = DebugKeyTable::send_imageProcessor_ball1_drawing; return true;
00242 case imageProcessor_ball2: debugKeyID = DebugKeyTable::send_imageProcessor_ball2_drawing; return true;
00243 case imageProcessor_ball3: debugKeyID = DebugKeyTable::send_imageProcessor_ball3_drawing; return true;
00244 case imageProcessor_ball4: debugKeyID = DebugKeyTable::send_imageProcessor_ball4_drawing; return true;
00245 case imageProcessor_ground: debugKeyID = DebugKeyTable::send_imageProcessor_ground_drawing; return true;
00246 case imageProcessor_flagsAndGoals: debugKeyID = DebugKeyTable::send_imageProcessor_flagsAndGoals_drawing; return true;
00247 case imageProcessor_obstacles: debugKeyID = DebugKeyTable::send_imageProcessor_obstacles_drawing; return true;
00248 case imageProcessor_gradients: debugKeyID = DebugKeyTable::send_imageProcessor_gradients_drawing; return true;
00249 case imageProcessor_edges: debugKeyID = DebugKeyTable::send_imageProcessor_edges_drawing; return true;
00250 case sketch: debugKeyID = DebugKeyTable::send_sketch_drawing; return true;
00251 default: return false;
00252 }
00253 }
00254
00255
00256 enum PenStyle
00257 {
00258 ps_solid, ps_dash, ps_dot, ps_null
00259 };
00260
00261
00262 enum FillStyle
00263 {
00264 bs_solid, bs_null
00265 };
00266
00267
00268 enum Color
00269 {
00270 red, green, blue, yellow, orange, pink, skyblue, white, light_gray, gray, dark_gray, black, yellowOrange, numberOfColors
00271 };
00272
00273 };
00274
00275 #ifdef NDEBUG
00276 #define NODEBUGDRAWINGS
00277 #endif
00278 #ifdef NO_DEBUG_DRAWING
00279 #define NODEBUGDRAWINGS
00280 #endif
00281
00282 #ifdef NODEBUGDRAWINGS
00283 #define CIRCLE(id, center_x, center_y, radius, penWidth, penStyle, penColor)
00284 #define DOT(id, x, y, penColor, fillColor)
00285 #define LARGE_DOT(id, x, y, penColor, fillColor)
00286 #define ARROW(id, x1, y1, x2, y2, penWidth, penStyle, penColor)
00287 #define LINE(id, x1, y1, x2, y2, penWidth, penStyle, penColor)
00288 #define POSE_2D_SAMPLE(id, p, color)
00289 #define OCTANGLE(id, x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7,x8,y8, color, fill)
00290 #define QUADRANGLE(id, x1,y1,x2,y2,x3,y3,x4,y4, penWidth, penStyle, penColor)
00291 #define RECTANGLE(id, x1,y1,x2,y2, penWidth, penStyle, penColor)
00292
00293 #define COMPLEX_DRAWING(id,expression)
00294 #define DEBUG_DRAWING_FINISHED(id)
00295
00296 #else //NODEBUGDRAWINGS
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308 #define CIRCLE(id, center_x, center_y, radius, penWidth, penStyle, penColor) \
00309 INFO(send_##id##_drawing, idDebugDrawing2, bin, \
00310 (char)Drawings::circle << \
00311 (char)Drawings::id << \
00312 (char)Drawings::getTypeOfDrawing(Drawings::id) << \
00313 (int)(center_x) << (int)(center_y) << (int)(radius) << (char)(penWidth) << \
00314 (char)(penStyle) << (char)(penColor) \
00315 );
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325 #define DOT(id, x, y, penColor, fillColor) \
00326 INFO(send_##id##_drawing, idDebugDrawing2, bin, \
00327 (char)Drawings::dot << \
00328 (char)Drawings::id << \
00329 (char)Drawings::getTypeOfDrawing(Drawings::id) << \
00330 (int)(x) << (int)(y) << (char)(penColor) << (char)(fillColor) \
00331 );
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342 #define LARGE_DOT(id, x, y, penColor, fillColor) \
00343 INFO(send_##id##_drawing, idDebugDrawing2, bin, \
00344 (char)Drawings::largeDot << \
00345 (char)Drawings::id << \
00346 (char)Drawings::getTypeOfDrawing(Drawings::id) << \
00347 (int)(x) << (int)(y) << (char)(penColor) << (char)(fillColor) \
00348 );
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361 #define LINE(id, x1, y1, x2, y2, penWidth, penStyle, penColor) \
00362 INFO(send_##id##_drawing, idDebugDrawing2, bin, \
00363 (char)Drawings::line << \
00364 (char)Drawings::id << \
00365 (char)Drawings::getTypeOfDrawing(Drawings::id) << \
00366 (int)(x1) << (int)(y1) << (int)(x2) << (int)(y2) << (char)(penWidth) << (char)(penStyle) << (char)(penColor) \
00367 );
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381 #define ARROW(id, x1, y1, x2, y2, penWidth, penStyle, penColor) \
00382 INFO(send_##id##_drawing, idDebugDrawing2, bin, \
00383 (char)Drawings::arrow << \
00384 (char)Drawings::id << \
00385 (char)Drawings::getTypeOfDrawing(Drawings::id) << \
00386 (int)(x1) << (int)(y1) << (int)(x2) << (int)(y2) << (char)(penWidth) << (char)(penStyle) << (char)(penColor) \
00387 );
00388
00389
00390
00391
00392
00393
00394
00395
00396 #define POSE_2D_SAMPLE(id, p, color) \
00397 Pose2D current = p; current += Pose2D(-100,0); \
00398 LINE(id, int(current.translation.x),int(current.translation.y), int(p.translation.x), int(p.translation.y), \
00399 1, Drawings::ps_solid, color); \
00400 current = p; current += Pose2D(-40,-40); \
00401 LINE(id, int(current.translation.x), int(current.translation.y), int(p.translation.x), int(p.translation.y), \
00402 1, Drawings::ps_solid, color); \
00403 current = p; current += Pose2D(-40,40); \
00404 LINE(id, int(current.translation.x),int(current.translation.y),int(p.translation.x), int(p.translation.y), \
00405 1, Drawings::ps_solid, color); \
00406
00407
00408
00409
00410
00411
00412
00413
00414 #define OCTANGLE(id, x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7,x8,y8, color, fill) \
00415 INFO(send_##id##_drawing, idDebugDrawing2, bin, \
00416 (char)Drawings::octangle << \
00417 (char)Drawings::id << \
00418 (char)Drawings::getTypeOfDrawing(Drawings::id) << \
00419 (int)(x1) << (int)(y1) << (int)(x2) << (int)(y2) << (int)(x3) << (int)(y3) << (int)(x4) << (int)(y4) << \
00420 (int)(x5) << (int)(y5) << (int)(x6) << (int)(y6) << (int)(x7) << (int)(y7) << (int)(x8) << (int)(y8) << \
00421 (char)ColorClasses::colorClassToDrawingsColor(color) << (char)fill \
00422 );
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432 #define QUADRANGLE(id, x1,y1,x2,y2,x3,y3,x4,y4, penWidth, penStyle, penColor) \
00433 LINE(id, x1, y1, x2, y2, penWidth, penStyle, penColor); \
00434 LINE(id, x2, y2, x3, y3, penWidth, penStyle, penColor); \
00435 LINE(id, x3, y3, x4, y4, penWidth, penStyle, penColor); \
00436 LINE(id, x4, y4, x1, y1, penWidth, penStyle, penColor);
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446 #define RECTANGLE(id, x1,y1,x2,y2, penWidth, penStyle, penColor) \
00447 LINE(id, x1, y1, x1, y2, penWidth, penStyle, penColor); \
00448 LINE(id, x1, y2, x2, y2, penWidth, penStyle, penColor); \
00449 LINE(id, x2, y2, x2, y1, penWidth, penStyle, penColor); \
00450 LINE(id, x2, y1, x1, y1, penWidth, penStyle, penColor);
00451
00452
00453
00454
00455 #define COMPLEX_DRAWING(id,expression) \
00456 if (getDebugKeyTable().isActive(DebugKeyTable::send_##id##_drawing)) {\
00457 expression;\
00458 }
00459
00460
00461
00462
00463
00464 #define DEBUG_DRAWING_FINISHED(id) \
00465 INFO(send_##id##_drawing, idDebugDrawingFinished, bin, (char)Drawings::id << (char)Drawings::getTypeOfDrawing(Drawings::id) );
00466
00467 #endif //NODEBUGDRAWINGS
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479 #endif //__DebugDrawings_h_
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717