Homepage Demos Overview Downloads Tutorials Reference
Credits

Lookout.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_Lookout_h_
00003 #define INCLUDED_Lookout_h_
00004 
00005 #include <queue>
00006 #include "Behaviors/BehaviorBase.h"
00007 #include "Motion/MotionManager.h"
00008 #include "Motion/MotionSequenceMC.h"
00009 #include "Events/VisionObjectEvent.h"
00010 #include "LookoutRequests.h"
00011 
00012 namespace DualCoding {
00013 
00014 class LookoutRequest;
00015 class StoreModeImageRequest;
00016 class ModeImageRequest;
00017 
00018 /*!
00019  The Lookout's job is to move the head and collect sensor information.
00020  Head motion can be none (user will point the head himself), pointAt, scan, or track.
00021  The data collected can be an image or distance reading, or for scan operations, it
00022  can be a list of locations where certain VisionObject or VisionRegion streams
00023  reported hits.
00024 
00025 */
00026 
00027 class Lookout : public BehaviorBase {
00028 public:
00029   //! Constructor
00030   Lookout();
00031   //! Destructor
00032   virtual ~Lookout() {}
00033   
00034   virtual void DoStart();
00035   virtual void DoStop();
00036   virtual void processEvent(const EventBase& event);
00037 
00038   static std::string getClassDescription() { return "moves head according to request"; }
00039   virtual std::string getDescription() const { return getClassDescription(); }
00040 
00041   virtual unsigned int executeRequest(const LookoutRequest&);
00042   //  virtual bool removeRequest(unsigned int req_id);
00043   //  bool isBusy() const { return !requests.empty(); }
00044   //  bool isLandmarkVisible() const { return landmark_inview; }
00045   //  bool isExecuting(LookoutRequest::HeadMotionType_t type) const 
00046   //  { return !requests.empty() && getCurrentRequest().getHeadMotionType() == type; }
00047 
00048   static Point findLocationFor(float, float);
00049   static const unsigned int Invalid_LO_ID=(unsigned int)-1;
00050   
00051 protected:
00052   virtual void executeRequest();
00053   virtual void requestComplete();
00054   template<class T>
00055   void pushRequest(const LookoutRequest& req) {
00056     requests.push(new T(*dynamic_cast<const T*>(&req)));
00057   }
00058     
00059 
00060   //! PointAtReqeust
00061   void processPointAt(const EventBase& event);
00062   bool findPixelModes(StoreModeImageRequest& modeRequest);
00063   void getData();
00064   /*
00065   //! TrackRequest
00066   void processTrack(const EventBase& event);
00067   void processTrackVision(float normX, float normY, bool isCurrentlyVisible);
00068   void trackObjectAt(float normX, float normY); //! tracks point at [normX,normY] in cam frame
00069   Point findLocationFor(float, float);
00070   */
00071   //! ScanReqeust
00072   void processScan(const EventBase& event);
00073   void scan();
00074   void scanAlongLine(const Point& start,const Point& end);
00075   void scanArea(coordinate_t left, coordinate_t right,
00076     coordinate_t far, coordinate_t near);
00077   //  void storeRegionLocation(const SegmentedColorGenerator::color_class_state*);
00078   //  void storeVisionObjectLocation(const VisionObjectEvent*);
00079   Point findLocationFor(const VisionObjectEvent* voe) {
00080     return findLocationFor(voe->getCenterX(), voe->getCenterY());
00081   }
00082   Point findLocationFor(const CMVision::region* reg) {
00083     return findLocationFor
00084       (2.0*reg->cen_x/VRmixin::camSkS.getWidth()-1.0,
00085        2.0*reg->cen_y/VRmixin::camSkS.getHeight()-1.0);
00086   }
00087 
00088   void storeVisionRegionDataTo(vector<Point>&, const set<int>&, int);
00089   void storeIRDataTo(vector<Point>&);
00090 
00091   //  float scanSpeed() const { return  baseRange/base_pan_time; } //(rad/msec)
00092 private:
00093   Lookout& operator=(const Lookout&);
00094   Lookout(const Lookout&);
00095 
00096 protected:
00097   MotionManager::MC_ID pointer_id; //!< a HeadPointerMC object
00098   MotionManager::MC_ID sequence_id; //!< id for scan/find motion sequence
00099   queue<LookoutRequest*> requests;
00100   LookoutRequest *curReq;
00101   bool /*pan_prior, */landmarkInView;
00102   unsigned int idCounter;
00103 
00104   enum LookoutTimerSourceId_t {
00105     start_pan,
00106     pan_complete,
00107     reset_pan,
00108     no_event,
00109     dur_timer,
00110     scan_timer, //scan_timer has to be at the end of enum list
00111   };
00112 };
00113 
00114 } //namespace
00115 
00116 #endif

DualCoding 3.0beta
Generated Wed Oct 4 00:01:53 2006 by Doxygen 1.4.7