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

Modules/SensorBehaviorControl/ImageSaver.cpp

Go to the documentation of this file.
00001 /**
00002 * @file ImageSaver.cpp
00003 * This file contains a class that demonstrates walking.
00004 * 
00005 * @author <A href=mailto: goehring@informatik.hu-berlin.de>Daniel Goehring</A>
00006 */
00007 
00008 #include "ImageSaver.h"
00009 #include "Tools/Debugging/GenericDebugData.h"
00010 #include "Representations/Perception/JPEGImage.h"
00011 
00012 
00013 ImageSaver::ImageSaver(SensorBehaviorControlInterfaces& interfaces)
00014 : SensorBehaviorControl(interfaces)
00015 {
00016   lastSavingTime = SystemCall::getCurrentSystemTime();
00017   for(int i = 0; i < 14; i++) ledRequest.faceLED[i] = LEDRequest::oooo;
00018   
00019   ledRequest.headWhiteLED = LEDRequest::oooo;
00020   ledRequest.headOrangeLED = LEDRequest::oooo;
00021   
00022   ledRequest.backFrontBlueLED = LEDRequest::oooo;
00023   ledRequest.backMiddleOrangeLED = LEDRequest::oooo;
00024   ledRequest.backRearRedLED = LEDRequest::oooo;
00025   
00026   ledRequest.backFrontWhiteLED = LEDRequest::oooo;
00027   ledRequest.backMiddleWhiteLED = LEDRequest::oooo;
00028   ledRequest.backRearWhiteLED = LEDRequest::oooo;
00029 
00030   hcm.headControlMode = HeadControlMode::searchForBall;
00031 }
00032 
00033 void ImageSaver::init()
00034 {
00035 }
00036 
00037 void ImageSaver::execute()
00038 {
00039   motionRequest.motionType = MotionRequest::stand;
00040   headControlMode.headControlMode = hcm.headControlMode;
00041 
00042   // head button pressed short and released
00043   if(
00044     !robotState.getButtonPressed(BodyPercept::head) &&
00045     robotState.getButtonPressedTime(BodyPercept::head) > 100 &&
00046     robotState.getButtonPressedTime(BodyPercept::head) < 1000 &&
00047     SystemCall::getTimeSince(robotState.getButtonTime(BodyPercept::head)) < 700
00048     )
00049   {
00050     switch(hcm.headControlMode)
00051     {
00052     case HeadControlMode::lookStraightAhead: hcm.headControlMode = HeadControlMode::stayAsForced; break;
00053     case HeadControlMode::stayAsForced: hcm.headControlMode = HeadControlMode::searchForBall; break;
00054     case HeadControlMode::searchForBall: hcm.headControlMode = HeadControlMode::lookStraightAhead; break;
00055     }
00056   }
00057   
00058   if (SystemCall::getCurrentSystemTime() - lastSavingTime > 3000)
00059   {
00060     ledRequest.backFrontWhiteLED = LEDRequest::llll;
00061     ledRequest.backMiddleWhiteLED = LEDRequest::llll;
00062     ledRequest.backRearWhiteLED = LEDRequest::llll;
00063     if (robotState.getButtonPressed(BodyPercept::backBack)||
00064       robotState.getButtonPressed(BodyPercept::backFront)||
00065       robotState.getButtonPressed(BodyPercept::backMiddle))
00066     {
00067       lastSavingTime = SystemCall::getCurrentSystemTime();
00068       OUTPUT(idJPEGImage,bin,JPEGImage(image) << cameraMatrix);
00069       ledRequest.backFrontWhiteLED = LEDRequest::oooo;
00070       ledRequest.backMiddleWhiteLED = LEDRequest::oooo;
00071       ledRequest.backRearWhiteLED = LEDRequest::oooo;
00072     }
00073   }
00074 }
00075 
00076 
00077 
00078 bool ImageSaver::handleMessage(InMessage& message)
00079 {
00080   return false;
00081 }
00082 
00083 
00084 /*
00085 * Change log :
00086 * 
00087 * $Log: ImageSaver.cpp,v $
00088 * Revision 1.7  2004/09/08 14:39:03  wachter
00089 * - Fixed some doxygen-errors
00090 *
00091 * Revision 1.6  2004/06/28 01:23:02  juengel
00092 * Head button switches head-control-mode.
00093 *
00094 * Revision 1.5  2004/06/21 18:52:37  dueffert
00095 * shiny new bug fixed
00096 *
00097 * Revision 1.4  2004/06/21 18:28:42  dueffert
00098 * easier button interface
00099 *
00100 * Revision 1.3  2004/06/20 18:16:19  dueffert
00101 * ImageSaver may work now
00102 *
00103 * Revision 1.2  2004/06/16 21:47:18  goehring
00104 * review
00105 *
00106 * Revision 1.1  2004/06/16 20:57:07  goehring
00107 * no message
00108 *
00109 *
00110 */

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