Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

MapBuilderRequest.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_MapBuilderRequest_h_
00003 #define INCLUDED_MapBuilderRequest_h_
00004 
00005 #include <queue>
00006 
00007 #include "ShapeTypes.h"
00008 
00009 namespace DualCoding {
00010 
00011 class LookoutSearchRequest;
00012 
00013 class MapBuilderRequest {
00014   friend class MapBuilder;
00015 
00016 public:
00017   enum MapBuilderRequestType_t { 
00018     cameraMap, 
00019     groundMap,
00020     localMap, 
00021     worldMap
00022   };
00023 
00024   MapBuilderRequestType_t requestType;  //!< Type of map to build
00025   std::map<ShapeType_t, std::set<color_index> > objectColors;   //!< For each object type, a set of object color indices
00026   std::map<ShapeType_t, std::set<color_index> > occluderColors;   //!< For each object type, a set of occluder color indices
00027   std::map<color_index, int> minBlobAreas;  //!< Minimum acceptable areas for blobs of specified colors, e.g., req.minBlobAreas[pink_index]=50
00028   std::map<color_index, BlobData::BlobOrientation_t> blobOrientations; //!< Default orientation for blobs of specified colors
00029   std::map<color_index, coordinate_t> assumedBlobHeights; //!< Fixed heights for pillar or poster  blobs of specified colors
00030   unsigned int floorColor;
00031   unsigned int motionSettleTime;  //!< Time in msec to wait before taking measurements or throwing completion event after head reaches gazePt.
00032   int numSamples; //!< Number of camera images to combine, for noise reduction
00033   int sampleInterval; //!< Interval in msec between successive samples
00034   float maxDist; //!< Ignore objects farther than this distance
00035   bool clearShapes; //!< If true, clear the shape space at start of request
00036   bool pursueShapes; //!< If true, generate new gaze points as shapes are recognized
00037   bool manualHeadMotion; //!< If true, waits for !msg MoveHead before moving to next gaze point (for debugging)
00038   bool rawY; //!< If true, leave an intensity (Y-channel) image in camera space for debugging
00039   bool removePts; //!< If true, remove pending gaze points if they're visible in current image
00040   bool doScan; //!< If true, do a continuous scan of the area to find interest points to be examined
00041   AngPi dTheta; //!< Angular step for scanning
00042   ShapeRoot searchArea; //!< The area to search, in egocentric coords
00043   std::queue<LookoutSearchRequest*> worldTargets; //!< Queue of search requests for world targets
00044   void (*userCamProcessing)(); //!< User routine to call after cam space processing
00045   void (*userGroundProcessing)(); //!< User routine to call after ground space processing
00046   void (*userLocalProcessing)(); //!< User routine to call after local space processing
00047   void (*userWorldProcessing)(); //!< User routine to call after world space processing
00048   bool (*exitTest)(); //!< If true, terminate map building and post completion event
00049   enum GroundPlaneAssumption_t { onStand, onLegs, custom } groundPlaneAssumption;
00050   NEWMAT::ColumnVector customGroundPlane; //!< User-supplied ground plane
00051 private:
00052   std::vector<Point> gazePts;
00053   std::vector<NEWMAT::Matrix> baseToCamMats;
00054   unsigned int requestID; //!< Set by mapbuilder when the request is added to its request queue
00055 
00056 public:
00057   //! Constructor
00058   MapBuilderRequest(MapBuilderRequestType_t reqtype=cameraMap)
00059     : requestType(reqtype), objectColors(), occluderColors(), 
00060       minBlobAreas(), blobOrientations(), assumedBlobHeights(), floorColor(0), 
00061       motionSettleTime(1000), numSamples(1), sampleInterval(0), maxDist(1e10), 
00062       clearShapes(true), pursueShapes(false), manualHeadMotion(false), rawY(true), removePts(true), 
00063       doScan(false), dTheta(M_PI/18),
00064       searchArea(), worldTargets(),
00065       userCamProcessing(NULL), userGroundProcessing(NULL), 
00066       userLocalProcessing(NULL), userWorldProcessing(NULL),
00067       exitTest(NULL),
00068       groundPlaneAssumption(onLegs), customGroundPlane(4),
00069       gazePts(), baseToCamMats(),
00070       requestID(0)
00071   {}
00072 
00073   //! Copy constructor
00074   MapBuilderRequest(const MapBuilderRequest &req)
00075     : requestType(req.requestType),
00076       objectColors(req.objectColors), occluderColors(req.occluderColors), 
00077       minBlobAreas(req.minBlobAreas), blobOrientations(req.blobOrientations), assumedBlobHeights(req.assumedBlobHeights),
00078       floorColor(req.floorColor), motionSettleTime(req.motionSettleTime), 
00079       numSamples(req.numSamples), sampleInterval(req.sampleInterval),
00080       maxDist(req.maxDist), clearShapes(req.clearShapes), pursueShapes(req.pursueShapes),
00081       manualHeadMotion(req.manualHeadMotion), rawY(req.rawY), removePts(req.removePts), 
00082       doScan(req.doScan), dTheta(req.dTheta),
00083       searchArea(req.searchArea), worldTargets(req.worldTargets),
00084       userCamProcessing(req.userCamProcessing), 
00085       userGroundProcessing(req.userGroundProcessing), 
00086       userLocalProcessing(req.userLocalProcessing), 
00087       userWorldProcessing(req.userWorldProcessing),
00088       exitTest(req.exitTest),
00089       groundPlaneAssumption(req.groundPlaneAssumption),
00090       customGroundPlane(req.customGroundPlane),
00091       gazePts(req.gazePts), baseToCamMats(req.baseToCamMats),
00092       requestID(req.requestID)
00093       {}
00094 
00095   virtual ~MapBuilderRequest() {} //!< Destructor
00096 
00097   MapBuilderRequestType_t getRequestType() const { return requestType; }
00098 
00099   void setCustomGroundPlane(float const angle, float const height) {
00100     float const s = std::sin(-angle);
00101     float const c = std::cos(-angle);
00102     customGroundPlane = Kinematics::pack(s, 0, c, -height * c);
00103     groundPlaneAssumption = custom;
00104   }
00105 
00106   //! Returns true if the request can complete immediately (no head motion required and numSamples <= 1)
00107   bool immediateRequest() const {
00108     return !searchArea.isValid() && worldTargets.size() == 0 && !pursueShapes && !doScan && numSamples <= 1;
00109   }
00110 
00111 private:
00112   MapBuilderRequest& operator=(const MapBuilderRequest& req);
00113 
00114 };
00115 
00116 } // namespace
00117 
00118 #endif

DualCoding 4.0
Generated Thu Nov 22 00:52:36 2007 by Doxygen 1.5.4