Homepage Demos Overview Downloads Tutorials Reference
Credits

CameraBehavior.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_CameraBehavior_h_
00003 #define INCLUDED_CameraBehavior_h_
00004 
00005 #include "Behaviors/BehaviorBase.h"
00006 #include "Motion/MotionManager.h"
00007 
00008 //! Will take images and write to log file
00009 /*! Press the head button to take a picture, back button to write to memory
00010  *  stick.  The leds will flash when finished writing.
00011  *
00012  *  The reason for this is to provide sample code for accessing vision
00013  *  data, and also simply because we should have a way to save
00014  *  pictures to memstick instead of relying solely on having wireless
00015  *  to transmit them over.
00016  *
00017  *  Image format is chosen by current config settings for the
00018  *  Config::vision_config::rawcam_compression and
00019  *  Config::vision_config::rawcam_channel.  However, the double
00020  *  resolution layer is always saved instead of whatever the current
00021  *  config skip value indicates.
00022  */
00023 class CameraBehavior : public BehaviorBase {
00024  public:
00025   //! constructor, just sets up the variables
00026   CameraBehavior()
00027     : BehaviorBase(), camera_click(EventBase::buttonEGID,0,EventBase::deactivateETID,150), index(0), ledID(MotionManager::invalid_MC_ID)
00028   {}
00029 
00030   //! Register for events
00031   virtual void DoStart();
00032   
00033   //! Removes its two motion commands
00034   virtual void DoStop();
00035   
00036   //! Handles event processing - determines which generator to save from and writes to current file
00037   virtual void processEvent(const EventBase& e);
00038 
00039   virtual std::string getName() const { return "CameraBehavior"; } //!< returns name of behavior
00040   static std::string getClassDescription() { return "Push head button to save a picture"; }
00041  protected:
00042   //! opens the next file to be saved to (with @a ext extension on the file name)
00043   FILE * openNextFile(const std::string& ext);
00044 
00045   //! returns the path and name of the next file to be saved to (with @a ext extension on the file name)
00046   std::string getNextName(const std::string& ext);
00047 
00048   //! scans the /ms/data directory for image files and assigns the next unused index to #index
00049   void initIndex();
00050 
00051   EventBase camera_click; //!< event mask for taking a picture (head button)
00052   unsigned int index; //!< the index to use for the next image saved
00053   
00054   MotionManager::MC_ID ledID; //!< the id of the LedMC used to signal completion
00055 };
00056 
00057 /*! @file
00058  * @brief Describes CameraBehavior, for taking pictures
00059  * @author alokl (Creator)
00060  * @author ejt (rewrite for new vision system)
00061  *
00062  * $Author: ejt $
00063  * $Name: tekkotsu-2_2 $
00064  * $Revision: 1.7 $
00065  * $State: Exp $
00066  * $Date: 2004/02/03 01:16:32 $
00067  */
00068 
00069 #endif

Tekkotsu v2.2
Generated Tue Oct 19 14:19:13 2004 by Doxygen 1.3.9.1