00001 /** 00002 * @file Processes/CMD/Cognition.h 00003 * Declaration of Cognition 00004 * 00005 * @author <a href="mailto:dueffert@informatik.hu-berlin.de">Uwe Düffert</a> 00006 * @author <a href="mailto:juengel@informatik.hu-berlin.de">Matthias Jüngel</a> 00007 * @author <a href="mailto:martin@martin-loetzsch.de">Martin Lötzsch</a> 00008 * @author <a href="mailto:risler@sim.informatik.tu-darmstadt.de">Max Risler</a> 00009 * @author <a href="mailto:roefer@tzi.de">Thomas Röfer</a> 00010 */ 00011 00012 #ifndef __Cognition_H__ 00013 #define __Cognition_H__ 00014 00015 #include "Tools/Process.h" 00016 #include "Tools/Module/SolutionRequest.h" 00017 00018 #include "Platform/Sensors.h" 00019 #include "Platform/UDPHandler.h" 00020 00021 #include "PackageMotionCognition.h" 00022 #include "PackageCognitionMotion.h" 00023 00024 00025 #include "Modules/SensorDataProcessor/SensorDataProcessorSelector.h" 00026 #include "Modules/ImageProcessor/ImageProcessorSelector.h" 00027 #include "Modules/RobotStateDetector/RobotStateDetectorSelector.h" 00028 #include "Modules/TeamBallLocator/TeamBallLocatorSelector.h" 00029 #include "Modules/BallLocator/BallLocatorSelector.h" 00030 #include "Modules/PlayersLocator/PlayersLocatorSelector.h" 00031 #include "Modules/ObstaclesLocator/ObstaclesLocatorSelector.h" 00032 #include "Modules/SelfLocator/SelfLocatorSelector.h" 00033 #include "Modules/BehaviorControl/BehaviorControlSelector.h" 00034 #include "Modules/SensorBehaviorControl/SensorBehaviorControlSelector.h" 00035 #include "Modules/SpecialVision/DefaultSpecialVision.h" 00036 #include "Modules/CollisionDetector/CollisionDetectorSelector.h" 00037 #include "Modules/ColorTableMod/ColorTableModSelector.h" 00038 00039 #include "Representations/Perception/ColorTable.h" 00040 #include "Representations/Perception/ColorTable64.h" 00041 #include "Representations/Perception/ColorTableTSL.h" 00042 #include "Representations/Perception/ColorTable32K.h" 00043 #include "Representations/Perception/LandmarksPercept.h" 00044 #include "Representations/Perception/BallPercept.h" 00045 #include "Representations/Perception/PlayersPercept.h" 00046 #include "Representations/Perception/LinesPercept.h" 00047 #include "Representations/Perception/EdgesPercept.h" 00048 #include "Representations/Perception/CameraMatrix.h" 00049 00050 00051 /** 00052 * @class Cognition 00053 * 00054 * A Process for cognition related modules in the HU1 process layout. 00055 */ 00056 class Cognition: public Process, public Sensors 00057 { 00058 private: 00059 DEBUGGING; 00060 RECEIVER(SensorDataBuffer); 00061 RECEIVER(Image); 00062 RECEIVER(GameControlData); 00063 RECEIVER(PackageMotionCognition); 00064 RECEIVER(OdometryData); 00065 NET_SENDER(TeamMessage1); 00066 NET_SENDER(TeamMessage2); 00067 NET_SENDER(TeamMessage3); 00068 NET_RECEIVER(TeamMessage1); 00069 NET_RECEIVER(TeamMessage2); 00070 NET_RECEIVER(TeamMessage3); 00071 #ifdef FIVEDOGS 00072 NET_RECEIVER(TeamMessage4); 00073 NET_SENDER(TeamMessage4); 00074 #endif 00075 SENDER(PackageCognitionMotion); 00076 UDP_HANDLER; 00077 00078 public: 00079 /** constructor */ 00080 Cognition(); 00081 00082 /** destructor */ 00083 ~Cognition(); 00084 00085 /** is called from the framework once in every frame */ 00086 virtual int main(); 00087 00088 /** is called direct before the first call of main() */ 00089 virtual void init(); 00090 00091 /** 00092 * The function handles incoming debug messages. 00093 * @param message the message to handle 00094 * @return Has the message been handled? 00095 */ 00096 virtual bool handleMessage(InMessage& message); 00097 00098 protected: 00099 /** If true, then a new image was received in the current frame */ 00100 bool processImage; 00101 00102 /** If true, then new sensor data were received in the current frame */ 00103 bool processSensorData; 00104 00105 /** If true, then percepts were received or generated in the current frame */ 00106 bool processPercepts; 00107 00108 //!@name modules 00109 //!@{ 00110 00111 /** a reference to the colortable selector */ 00112 ColorTableModSelector* pColorTableMod; 00113 00114 /** a reference to the image processor */ 00115 ImageProcessorSelector* pImageProcessor; 00116 00117 /** a reference to the sensor data processor */ 00118 SensorDataProcessorSelector* pSensorDataProcessor; 00119 00120 /** a reference to the collision detector */ 00121 CollisionDetectorSelector* pCollisionDetector; 00122 00123 /** a reference to the robot state detector */ 00124 RobotStateDetectorSelector* pRobotStateDetector; 00125 00126 /** a reference to the ball-locator */ 00127 BallLocatorSelector* pBallLocator; 00128 00129 /** a reference to the team ball locator */ 00130 TeamBallLocatorSelector* pTeamBallLocator; 00131 00132 /** a reference to the players-locator */ 00133 PlayersLocatorSelector* pPlayersLocator; 00134 00135 /** a reference to the obstacles-locator */ 00136 ObstaclesLocatorSelector* pObstaclesLocator; 00137 00138 /** a reference to the self-locator */ 00139 SelfLocatorSelector* pSelfLocator; 00140 00141 /** a reference to the behavior control */ 00142 BehaviorControlSelector* pBehaviorControl; 00143 00144 /** a reference to sensor based behavior control */ 00145 SensorBehaviorControlSelector* pSensorBehaviorControl; 00146 00147 /** a reference to the special vison module*/ 00148 SpecialVision* pSpecialVision; 00149 00150 //!@} 00151 00152 //!@name representations 00153 //!@{ 00154 00155 /** the color tables */ 00156 char colorTableBuffer[sizeof(ColorTable64) > sizeof(ColorTableTSL) 00157 ? sizeof(ColorTable64) > sizeof(ColorTable32K) ? sizeof(ColorTable64) 00158 : sizeof(ColorTable32K) 00159 : sizeof(ColorTableTSL) > sizeof (ColorTable32K) 00160 ? sizeof(ColorTableTSL) : sizeof(ColorTable32K)]; 00161 /** the color table */ 00162 ColorTable& colorTable; 00163 00164 /** The offset and rotation of the camera */ 00165 CameraMatrix cameraMatrix; 00166 00167 /** Detected landmarks */ 00168 LandmarksPercept landmarksPercept; 00169 00170 /** Detected balls */ 00171 BallPercept ballPercept; 00172 00173 /** Detected players */ 00174 PlayersPercept playersPercept; 00175 00176 /** Detected obstacles */ 00177 ObstaclesPercept obstaclesPercept; 00178 00179 /** The collision percept */ 00180 CollisionPercept collisionPercept; 00181 00182 /** Detected lines */ 00183 LinesPercept linesPercept; 00184 00185 /** Detected edges */ 00186 EdgesPercept edgesPercept; 00187 00188 /** Detected switches */ 00189 BodyPercept bodyPercept; 00190 00191 /** The height and the inclination of the robot's body */ 00192 BodyPosture bodyPosture; 00193 00194 /** A spot relative to the robot that was detected by the PSD sensor */ 00195 PSDPercept psdPercept; 00196 00197 /** A special percept */ 00198 SpecialPercept specialPercept; 00199 00200 /** The request for the specialVision module*/ 00201 SpecialVisionRequest specialVisionRequest; 00202 00203 /** The request for calibration*/ 00204 CalibrationRequest calibrationRequest; 00205 00206 /** The sample set proxy linked to the sample set of the active locator */ 00207 SampleSetProxy<PoseSample> selfLocatorSamples; 00208 00209 /** The team message collection */ 00210 TeamMessageCollection teamMessageCollection; 00211 00212 /** The outgoing behavior team message */ 00213 BehaviorTeamMessage outgoingBehaviorTeamMessage; 00214 00215 /** Data produced by an extern sensor called joystick */ 00216 JoystickData joystickData; 00217 00218 unsigned long frameNumber; 00219 unsigned long lastFrameNumber; 00220 //!@} 00221 }; 00222 00223 00224 #endif // __Cognition_H__ 00225 00226 00227 /* 00228 * Change log : 00229 * 00230 * $Log: Cognition.h,v $ 00231 * Revision 1.7 2004/06/15 17:49:38 juengel 00232 * Added frameLostWarning. 00233 * 00234 * Revision 1.6 2004/06/15 10:58:27 thomas 00235 * added edge-specialist, edges-percept, debug-drawings etc. (not yet called from image-processor) 00236 * 00237 * Revision 1.5 2004/05/27 10:25:18 loetzsch 00238 * removed all prepocessor directives NO_COLOR_TABLE_SELECTOR 00239 * 00240 * Revision 1.4 2004/05/27 09:53:33 loetzsch 00241 * removed "timeOfImageProcessing" 00242 * 00243 * Revision 1.3 2004/05/27 09:44:25 loetzsch 00244 * clean up 00245 * 00246 * Revision 1.2 2004/05/26 15:18:44 juengel 00247 * Added BodyPosture. 00248 * 00249 * Revision 1.1.1.1 2004/05/22 17:24:56 cvsadm 00250 * created new repository GT2004_WM 00251 * 00252 * Revision 1.18 2004/05/14 14:12:08 wachter 00253 * - Added communication support for 5 robots 00254 * - rewrote parts of team-communication to be faster and more stable 00255 * 00256 * Revision 1.17 2004/04/16 14:57:39 dueffert 00257 * cleanup for Martins data flow graphics 00258 * 00259 * Revision 1.16 2004/04/14 06:37:17 loetzsch 00260 * removed the hack "kickInProgress" from the BehaviorControlInterfaces 00261 * 00262 * Revision 1.15 2004/04/08 15:33:07 wachter 00263 * GT04 checkin of Microsoft-Hellounds 00264 * 00265 * Revision 1.14 2004/04/07 14:42:56 risler 00266 * moved LandsmarksState to Cognition directory, generated by SelfLocator 00267 * 00268 * Revision 1.13 2004/04/07 13:00:47 risler 00269 * ddd checkin after go04 - second part 00270 * 00271 * Revision 1.2 2004/04/01 19:52:44 Charlie 00272 * added LandmarkState 00273 * 00274 * Revision 1.1.1.1 2004/03/29 08:28:46 Administrator 00275 * initial transfer from tamara 00276 * 00277 * Revision 1.12 2004/03/29 15:32:01 dueffert 00278 * evolution mode idea added 00279 * 00280 * Revision 1.11 2004/03/15 12:36:53 dueffert 00281 * measurement of free choosen MotionRequest allowed now 00282 * 00283 * Revision 1.10 2004/02/23 16:48:51 dueffert 00284 * several improvements for measurement of walking 00285 * 00286 * Revision 1.9 2004/02/18 23:30:51 kerdels 00287 * removed warning 00288 * 00289 * Revision 1.8 2004/02/18 14:49:59 dueffert 00290 * behavior control can now change walking parameters 00291 * 00292 * Revision 1.7 2004/01/30 15:44:33 nistico 00293 * Created a Color Table Selector, which permits to switch color tables at run time using the same image processor. 00294 * If your image processor was designed to use only ColorTable64, leave it as the default choice and you should 00295 * (hopefully) have no problems. 00296 * In case of trouble, i put a conditional compilation switch in SolutionRequest.h, simply uncomment the definition of NO_COLOR_TABLE_SELECTOR; in that case, the code should get back to the original solution, but the coltable which will be looked upon first for loading will be ColorTable64 (as it's the default solution), so there's no reason anymore to remove the other color tables from the CVS. 00297 * 00298 * Revision 1.6 2004/01/26 14:14:50 wachter 00299 * activated direct team-communication 00300 * 00301 * Revision 1.5 2004/01/20 12:40:08 nistico 00302 * - Added support for ColorTable32K (65K elements in packed format) 00303 * - RobotControl can now convert GT *.log files into AIBOVision (external ColorTable32K calibration tool) *.amv file format 00304 * 00305 * Revision 1.4 2003/11/29 07:40:19 roefer 00306 * Doxygen comments corrected 00307 * 00308 * Revision 1.3 2003/11/24 15:31:20 dueffert 00309 * SpecialPercept removed from PackageCognition 00310 * 00311 * Revision 1.2 2003/10/12 11:48:14 juengel 00312 * Added CalibrationRequest. 00313 * 00314 * Revision 1.1 2003/10/07 10:07:00 cvsadm 00315 * Created GT2004 (M.J.) 00316 * 00317 * Revision 1.3 2003/09/26 21:23:20 loetzsch 00318 * renamed class JointState to CollisionPercept 00319 * 00320 * Revision 1.2 2003/09/26 15:30:38 juengel 00321 * Renamed DataTypes to representations. 00322 * 00323 * Revision 1.1.1.1 2003/07/02 09:40:25 cvsadm 00324 * created new repository for the competitions in Padova from the 00325 * tamara CVS (Tuesday 2:00 pm) 00326 * 00327 * removed unused solutions 00328 * 00329 * Revision 1.29 2003/05/13 11:41:45 goehring 00330 * CollisionDetector added 00331 * 00332 * Revision 1.28 2003/05/12 14:08:40 brunn 00333 * renamed selfLocationSampleSetProxy to selfLocatorSamples 00334 * "Ha, glad am I that no one knew that Rumpelstiltskin I am styled" 00335 * 00336 * Revision 1.27 2003/05/12 12:28:13 brunn 00337 * renamed sampleSetProxy to selfLocationSampleSetProxy 00338 * added selfLocationSampleSetProxy to BehaviourControl-Interfaces 00339 * 00340 * Revision 1.26 2003/05/08 23:52:25 roefer 00341 * SampleSet and SampleSetProxy added 00342 * 00343 * Revision 1.25 2003/05/02 18:26:17 risler 00344 * SensorDataBuffer added 00345 * replaced SensorData with SensorDataBuffer 00346 * full SensorData resolution now accessible 00347 * 00348 * Revision 1.24 2003/05/01 17:09:09 loetzsch 00349 * Redesign of ball modeling: 00350 * - Modularized class BallPosition 00351 * - splitted up module "BallLocator" into "BallLocator" for modeling of percepts 00352 * and "TeamBallLocator" for modelling communicated positions 00353 * - Removed solution JumpingBallLocator 00354 * - Splitted Solution DefaultBallLocator into DefaultBallLocator and DefaultTeamBallLocator 00355 * - Renamed SensorFusionBallLocator to GaussBellTeamBallLocator 00356 * 00357 * Revision 1.23 2003/03/20 20:33:41 loetzsch 00358 * removed some hacks 00359 * 00360 * Revision 1.22 2003/03/19 15:40:41 jhoffman 00361 * GL simulator support improved 00362 * 00363 * Revision 1.21 2003/03/12 13:46:04 dasmuli 00364 * PlayersPerceptor added to cognition, modules.cfg, DebugKey-table etc. 00365 * 00366 * Revision 1.20 2003/03/10 13:59:05 juengel 00367 * Added ObstaclesLocator 00368 * 00369 * Revision 1.19 2003/03/06 12:03:13 dueffert 00370 * re-order warning and nested comment warnings removed 00371 * 00372 * Revision 1.18 2003/03/05 14:07:10 roefer 00373 * LinesPerceptor2 is now LinesImageProcessor 00374 * 00375 * Revision 1.17 2003/02/27 12:02:30 dueffert 00376 * JoystickData added 00377 * 00378 * Revision 1.16 2003/02/21 18:32:04 roefer 00379 * pColorTable -> colorTable finished 00380 * 00381 * Revision 1.15 2003/02/18 21:29:17 osterhues 00382 * Changed all instances of ColorTable64 to new base class ColorTable 00383 * 00384 * Revision 1.14 2003/02/07 16:43:15 dueffert 00385 * Bombay stuff added after cleanup 00386 * 00387 * Revision 1.13 2002/12/07 12:35:38 loetzsch 00388 * world states and percepts now can be viewed without sending images 00389 * 00390 * Revision 1.12 2002/11/28 14:46:51 jhoffman 00391 * added special percept for motion detection 00392 * 00393 * Revision 1.11 2002/11/26 19:19:24 loetzsch 00394 * JPEG images are put into local processes 00395 * 00396 * Revision 1.10 2002/11/19 17:38:31 dueffert 00397 * doxygen bugs corrected 00398 * 00399 * Revision 1.9 2002/11/07 17:30:10 loetzsch 00400 * renamed Module SensorDataToMotionRequest to SensorBehaviorControl 00401 * 00402 * Revision 1.8 2002/10/10 13:09:50 loetzsch 00403 * First experiments with the PSD Sensor 00404 * - SensorDataProcessor now calculates PSDPercept 00405 * - Added the PerceptBehaviorControl solution PSDTest 00406 * - Added the RadarViewer3D to RobotControl, which can display the Points3D structure 00407 * 00408 * Revision 1.7 2002/10/04 10:20:47 loetzsch 00409 * renamed bool imageIsNew to processImage, 00410 * images are also processed when a new color table arrives 00411 * 00412 * Revision 1.6 2002/09/25 10:25:13 loetzsch 00413 * removed the "executeVisionModules" variable 00414 * from SolutionRequest and ModuleHandler. 00415 * 00416 * Revision 1.5 2002/09/18 19:52:36 loetzsch 00417 * the head state is now sent from Motion to Cognition using the package. 00418 * 00419 * Revision 1.4 2002/09/17 23:55:22 loetzsch 00420 * - unraveled several datatypes 00421 * - changed the WATCH macro 00422 * - completed the process restructuring 00423 * 00424 * Revision 1.3 2002/09/12 14:20:05 juengel 00425 * Created a package for all data sent from Cognition to Motion. 00426 * 00427 * Revision 1.2 2002/09/12 12:40:58 juengel 00428 * continued change of module/solution mechanisms 00429 * 00430 * Revision 1.1 2002/09/10 15:41:25 cvsadm 00431 * Created new project GT2003 (M.L.) 00432 * - Cleaned up the /Src/DataTypes directory 00433 * - Removed challenge related source code 00434 * - Removed processing of incoming audio data 00435 * - Renamed AcousticMessage to SoundRequest 00436 * - Removed all process layouts 00437 * - Added process layout CMD 00438 * 00439 * Revision 1.12 2002/09/07 13:36:58 loetzsch 00440 * unified the vision modules into one module "ImageProcessor" 00441 * - FloodFillRLEImageProcessor, BallPerceptor, LandmarksPerceptor 00442 * and PlayersPerceptor were are combined to the new solution 00443 * "BlobImageProcessor" 00444 * - The GridImageProcessor and the SubPixelGradientCalculator became 00445 * a solution of "ImageProcessor" 00446 * 00447 * Revision 1.11 2002/07/23 13:40:51 loetzsch 00448 * - new streaming classes 00449 * - removed many #include statements 00450 * - new design of debugging architecture 00451 * - exchanged StaticQueue with MessageQueue 00452 * - new debug message handling 00453 * - general clean up 00454 * 00455 * Revision 1.10 2002/07/13 10:54:58 roefer 00456 * New command and sound sender 00457 * 00458 * Revision 1.9 2002/06/20 00:40:21 Thomas Röfer 00459 * WLan crash removed 00460 * 00461 * Revision 1.8 2002/06/12 11:34:29 roefer 00462 * SimpleLinesPerceptor removed, PerceptBehaviorControl added 00463 * 00464 * Revision 1.7 2002/06/09 15:24:52 loetzsch 00465 * Added TeamMessageCollection and BehaviorTeamMessage to the execute of BehaviorControl 00466 * 00467 * Revision 1.6 2002/06/02 23:21:09 roefer 00468 * Single color table and progress in LinesSelfLocator 00469 * 00470 * Revision 1.5 2002/05/27 15:39:13 fischer 00471 * Added SoundState (Sender and Receiver) 00472 * 00473 * Revision 1.4 2002/05/16 22:36:11 roefer 00474 * Team communication and GTMath bugs fixed 00475 * 00476 * Revision 1.3 2002/05/14 21:04:04 hebbel 00477 * processing of SoundDataIn added 00478 * 00479 * Revision 1.2 2002/05/10 17:29:43 juengel 00480 * Added SpecialVision and SpecialPercept. 00481 * 00482 * Revision 1.1.1.1 2002/05/10 12:40:19 cvsadm 00483 * Moved GT2002 Project from ute to tamara. 00484 * 00485 * Revision 1.19 2002/05/05 18:52:03 loetzsch 00486 * added 00487 * - GameControlData, 00488 * - Receivers for GameControlData 00489 * - access by behavior to GameControlData 00490 * 00491 * Revision 1.18 2002/04/29 17:17:51 hebbel 00492 * Put SoundPlay to Motion Process 00493 * 00494 * Revision 1.17 2002/04/28 19:19:46 giese 00495 * SoundPlay added... 00496 * 00497 * Revision 1.16 2002/04/02 13:10:21 dueffert 00498 * big change: odometryData and cameraMatrix in image now, old logfiles may be obsolete 00499 * 00500 * Revision 1.15 2002/02/05 20:02:16 risler 00501 * handleDebugMessage now returns bool, added debug message handling to ImageProcessor 00502 * 00503 * Revision 1.14 2002/02/05 04:19:04 loetzsch 00504 * replaced several team color hacks by getPlayer().getTeamColor() 00505 * 00506 * added a few new module selectors 00507 * 00508 * changed distribution of debug messages completely 00509 * 00510 * Revision 1.13 2002/02/03 14:37:58 juengel 00511 * Drawing of the world state removed from Berlin2001BehaviorControl. 00512 * Drawing method for world states added to PaintMethods. 00513 * Drawing of the world state added to the Processes with BehaviorControl. 00514 * 00515 * Revision 1.12 2002/01/30 17:29:55 loetzsch 00516 * handleDebugMessage um Parameter timestamp erweitert 00517 * 00518 * Revision 1.11 2002/01/22 14:56:30 juengel 00519 * ColorTable verschicken angefangen. 00520 * 00521 * Revision 1.10 2002/01/06 13:50:29 juengel 00522 * WalkDemo eingebaut 00523 * 00524 * Revision 1.9 2001/12/21 14:09:39 roefer 00525 * Added several destructors 00526 * 00527 * Revision 1.8 2001/12/20 17:14:35 loetzsch 00528 * Using debug requests from the memory stick. 00529 * 00530 * Revision 1.7 2001/12/19 16:03:55 bach 00531 * SystemDataTypes replaced by Sensors 00532 * 00533 * Revision 1.6 2001/12/15 20:32:09 roefer 00534 * Senders and receivers are now part of the processes 00535 * 00536 * Revision 1.5 2001/12/14 12:34:09 dueffert 00537 * no message 00538 * 00539 * Revision 1.4 2001/12/12 18:08:55 loetzsch 00540 * Streaming- Operatoren für Bilder eingebaut, DebugKeyTable nicht- statisch gemacht, Debuggin Mechanismen weitergemacht, Bilder aus Logfiles in RobotControl anzeigen, Logfiles in HU1/Debug auf den Stick schreiben 00541 * 00542 * Revision 1.3 2001/12/10 17:47:08 risler 00543 * change log added 00544 * 00545 */