Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
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 #include "Events/EventBase.h"
00008 
00009 //! Will take images and write to log file
00010 /*! Press the head button to take a picture, back button to write to memory
00011  *  stick.  The leds will flash when finished writing.
00012  *
00013  *  The reason for this is to provide sample code for accessing vision
00014  *  data, and also simply because we should have a way to save
00015  *  pictures to memstick instead of relying solely on having wireless
00016  *  to transmit them over.
00017  *
00018  *  Image format is chosen by current config settings for the
00019  *  Config::vision_config::RawCamConfig::compression and
00020  *  Config::vision_config::RawCamConfig::channel.  However, the double
00021  *  resolution layer is always saved instead of whatever the current
00022  *  config skip value indicates.
00023  */
00024 class CameraBehavior : public BehaviorBase {
00025  public:
00026   //! constructor, just sets up the variables
00027   CameraBehavior()
00028     : BehaviorBase("CameraBehavior"), camera_click(EventBase::buttonEGID,0,EventBase::deactivateETID,150), index(0), ledID(MotionManager::invalid_MC_ID)
00029   {}
00030 
00031   //! Register for events
00032   virtual void doStart();
00033   
00034   //! Removes its two motion commands
00035   virtual void doStop();
00036   
00037   //! Handles event processing - determines which generator to save from and writes to current file
00038   virtual void doEvent();
00039 
00040   static std::string getClassDescription() { return "Push head button to save a picture"; }
00041   virtual std::string getDescription() const { return getClassDescription(); }
00042 
00043  protected:
00044   //! opens the next file to be saved to (with @a ext extension on the file name)
00045   FILE * openNextFile(const std::string& ext);
00046 
00047   //! returns the path and name of the next file to be saved to (with @a ext extension on the file name)
00048   std::string getNextName(const std::string& ext);
00049 
00050   //! scans the /ms/data directory for image files and assigns the next unused index to #index
00051   void initIndex();
00052 
00053   EventBase camera_click; //!< event mask for taking a picture (head button)
00054   unsigned int index; //!< the index to use for the next image saved
00055   
00056   MotionManager::MC_ID ledID; //!< the id of the LedMC used to signal completion
00057 };
00058 
00059 /*! @file
00060  * @brief Describes CameraBehavior, for taking pictures
00061  * @author alokl (Creator)
00062  * @author ejt (rewrite for new vision system)
00063  */
00064 
00065 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:36 2016 by Doxygen 1.6.3