00001
00002 #ifndef INCLUDED_MapBuilderRequest_h_
00003 #define INCLUDED_MapBuilderRequest_h_
00004
00005 #include "Behaviors/BehaviorBase.h"
00006 #include "Shared/fmatSpatial.h"
00007 #include "Vision/colors.h"
00008
00009 #include <queue>
00010
00011 #include "DualCoding/BlobData.h"
00012 #include "DualCoding/MarkerData.h"
00013 #include "DualCoding/Point.h"
00014 #include "DualCoding/ShapeTypes.h"
00015
00016 using namespace std;
00017
00018 namespace DualCoding {
00019
00020 class LookoutSearchRequest;
00021
00022 class GazePoint {
00023 public:
00024 enum GazePointType_t {
00025 visible,
00026 centered
00027 } type;
00028 Point point;
00029 GazePoint(GazePointType_t _type, Point _point) : type(_type), point(_point) {}
00030 GazePoint() : type(), point() {}
00031 };
00032
00033 class MapBuilderRequest {
00034 friend class MapBuilder;
00035
00036 public:
00037 enum MapBuilderRequestType_t {
00038 cameraMap,
00039 groundMap,
00040 localMap,
00041 worldMap
00042 };
00043
00044 typedef unsigned int MapBuilderVerbosity_t;
00045 static coordinate_t defaultMarkerHeight;
00046
00047 MapBuilderRequestType_t requestType;
00048 std::map<ShapeType_t, std::set<color_index> > objectColors;
00049 std::map<ShapeType_t, std::set<color_index> > secondColors;
00050 std::map<ShapeType_t, std::set<color_index> > occluderColors;
00051 float minLineLength;
00052 float minRayLength;
00053 float minEllipseSemiMajor;
00054 std::map<color_index, int> minBlobAreas;
00055 std::map<color_index, BlobData::BlobOrientation_t> blobOrientations;
00056 std::map<color_index, coordinate_t> assumedBlobHeights;
00057 std::map<color_index, coordinate_t> assumedCylinderHeights;
00058 std::set<MarkerType_t> markerTypes;
00059 std::map<MarkerType_t, coordinate_t> markerHeights;
00060 unsigned int floorColor;
00061 string siftDatabasePath;
00062 std::set<std::string> siftObjectNames;
00063 std::pair<int,int> aprilTagFamily;
00064 fmat::Column<3> dominoDimensions;
00065 fmat::Column<3> naughtDimensions;
00066 fmat::Column<3> crossDimensions;
00067 unsigned int motionSettleTime;
00068 int numSamples;
00069 int sampleInterval;
00070 float maxDist;
00071 bool clearCamera;
00072 bool clearLocal;
00073 bool clearWorld;
00074 bool ignoreCamera;
00075 bool pursueShapes;
00076 bool immediateRequest;
00077 bool manualHeadMotion;
00078 bool rawY;
00079 bool removePts;
00080 bool doScan;
00081 AngPi dTheta;
00082 ShapeRoot searchArea;
00083 std::queue<LookoutSearchRequest*> worldTargets;
00084 void (*userImageProcessing)();
00085 void (*userCamProcessing)();
00086 void (*userGroundProcessing)();
00087 void (*userLocalProcessing)();
00088 void (*userWorldProcessing)();
00089 bool (*exitTest)();
00090 enum GroundPlaneAssumption_t { onStand, onLegs, onWheel, custom } groundPlaneAssumption;
00091 PlaneEquation customGroundPlane;
00092 BehaviorBase* requestingBehavior;
00093 MapBuilderVerbosity_t setVerbosity;
00094 MapBuilderVerbosity_t clearVerbosity;
00095 fmat::Transform baseTransform;
00096
00097 private:
00098 std::vector<GazePoint> gazePts;
00099 std::vector<fmat::Transform> baseToCamMats;
00100 unsigned int requestID;
00101 MapBuilderVerbosity_t verbosity;
00102
00103 public:
00104
00105 MapBuilderRequest(MapBuilderRequestType_t reqtype=cameraMap)
00106 : requestType(reqtype), objectColors(), secondColors(), occluderColors(),
00107 minLineLength(70), minRayLength(40), minEllipseSemiMajor(9),
00108 minBlobAreas(), blobOrientations(), assumedBlobHeights(),
00109 assumedCylinderHeights(), markerTypes(), markerHeights(), floorColor(0),
00110 siftDatabasePath(""), siftObjectNames(), aprilTagFamily(),
00111 dominoDimensions(fmat::pack(200.0, 89.0, 67.0)),
00112 naughtDimensions(fmat::pack(90.0, 90.0, 57.0)),
00113 crossDimensions(fmat::pack(100.0, 68.0, 41.0)),
00114 motionSettleTime(1000), numSamples(1), sampleInterval(0), maxDist(1e10f),
00115 clearCamera(true), clearLocal(true), clearWorld(false), ignoreCamera(false),
00116 pursueShapes(false), immediateRequest(false), manualHeadMotion(false), rawY(true), removePts(true),
00117 doScan(false), dTheta((float)M_PI/18),
00118 searchArea(), worldTargets(),
00119 userImageProcessing(NULL), userCamProcessing(NULL), userGroundProcessing(NULL),
00120 userLocalProcessing(NULL), userWorldProcessing(NULL),
00121 exitTest(NULL),
00122 groundPlaneAssumption(onLegs), customGroundPlane(), requestingBehavior(NULL),
00123 setVerbosity(0), clearVerbosity(0),
00124 baseTransform(),
00125 gazePts(), baseToCamMats(),
00126 requestID(0),
00127 verbosity(0)
00128 {}
00129
00130
00131 MapBuilderRequest(const MapBuilderRequest &req)
00132 : requestType(req.requestType),
00133 objectColors(req.objectColors), secondColors(req.secondColors), occluderColors(req.occluderColors),
00134 minLineLength(req.minLineLength), minRayLength(req.minRayLength),
00135 minEllipseSemiMajor(req.minEllipseSemiMajor),
00136 minBlobAreas(req.minBlobAreas), blobOrientations(req.blobOrientations), assumedBlobHeights(req.assumedBlobHeights),
00137 assumedCylinderHeights(req.assumedCylinderHeights),
00138 markerTypes(req.markerTypes), markerHeights(req.markerHeights),
00139 floorColor(req.floorColor),
00140 siftDatabasePath(req.siftDatabasePath), siftObjectNames(req.siftObjectNames),
00141 aprilTagFamily(req.aprilTagFamily),
00142 dominoDimensions(req.dominoDimensions),
00143 naughtDimensions(req.naughtDimensions),
00144 crossDimensions(req.crossDimensions),
00145 motionSettleTime(req.motionSettleTime),
00146 numSamples(req.numSamples), sampleInterval(req.sampleInterval),
00147 maxDist(req.maxDist),
00148 clearCamera(req.clearCamera), clearLocal(req.clearLocal), clearWorld(req.clearWorld),
00149 ignoreCamera(req.ignoreCamera), pursueShapes(req.pursueShapes),
00150 immediateRequest(req.immediateRequest),
00151 manualHeadMotion(req.manualHeadMotion),
00152 rawY(req.rawY), removePts(req.removePts),
00153 doScan(req.doScan), dTheta(req.dTheta),
00154 searchArea(req.searchArea), worldTargets(req.worldTargets),
00155 userImageProcessing(req.userImageProcessing),
00156 userCamProcessing(req.userCamProcessing),
00157 userGroundProcessing(req.userGroundProcessing),
00158 userLocalProcessing(req.userLocalProcessing),
00159 userWorldProcessing(req.userWorldProcessing),
00160 exitTest(req.exitTest),
00161 groundPlaneAssumption(req.groundPlaneAssumption),
00162 customGroundPlane(req.customGroundPlane),
00163 requestingBehavior(req.requestingBehavior),
00164 setVerbosity(req.setVerbosity), clearVerbosity(req.clearVerbosity),
00165 baseTransform(req.baseTransform),
00166 gazePts(req.gazePts), baseToCamMats(req.baseToCamMats),
00167 requestID(req.requestID), verbosity(req.verbosity)
00168 {}
00169
00170
00171 MapBuilderRequest& operator=(const MapBuilderRequest &req) {
00172 requestType = req.requestType;
00173 objectColors = req.objectColors;
00174 secondColors = req.secondColors;
00175 occluderColors = req.occluderColors;
00176 minLineLength = req.minLineLength;
00177 minRayLength = req.minRayLength;
00178 minEllipseSemiMajor = req.minEllipseSemiMajor;
00179 minBlobAreas = req.minBlobAreas;
00180 blobOrientations = req.blobOrientations;
00181 assumedBlobHeights = req.assumedBlobHeights;
00182 markerTypes = req.markerTypes;
00183 markerHeights = req.markerHeights;
00184 floorColor = req.floorColor;
00185 siftDatabasePath = req.siftDatabasePath;
00186 siftObjectNames = req.siftObjectNames;
00187 aprilTagFamily = req.aprilTagFamily;
00188 dominoDimensions = req.dominoDimensions;
00189 naughtDimensions = req.naughtDimensions;
00190 crossDimensions = req.crossDimensions;
00191 motionSettleTime = req.motionSettleTime;
00192 numSamples = req.numSamples;
00193 sampleInterval = req.sampleInterval;
00194 maxDist = req.maxDist;
00195 clearCamera = req.clearCamera;
00196 clearLocal = req.clearLocal;
00197 clearWorld = req.clearWorld;
00198 ignoreCamera = req.ignoreCamera;
00199 pursueShapes = req.pursueShapes;
00200 immediateRequest = req.immediateRequest;
00201 manualHeadMotion = req.manualHeadMotion;
00202 rawY = req.rawY;
00203 removePts = req.removePts;
00204 doScan = req.doScan;
00205 dTheta = req.dTheta;
00206 searchArea = req.searchArea;
00207 worldTargets = req.worldTargets;
00208 userImageProcessing = req.userImageProcessing;
00209 userCamProcessing = req.userCamProcessing;
00210 userGroundProcessing = req.userGroundProcessing;
00211 userLocalProcessing = req.userLocalProcessing;
00212 userWorldProcessing = req.userWorldProcessing;
00213 exitTest = req.exitTest;
00214 groundPlaneAssumption = req.groundPlaneAssumption;
00215 customGroundPlane = req.customGroundPlane;
00216 requestingBehavior = req.requestingBehavior;
00217 setVerbosity = req.setVerbosity;
00218 clearVerbosity = req.clearVerbosity;
00219 baseTransform = req.baseTransform;
00220 gazePts = req.gazePts;
00221 baseToCamMats = req.baseToCamMats;
00222 requestID = req.requestID;
00223 verbosity = req.verbosity;
00224 return *this;
00225 }
00226
00227 virtual ~MapBuilderRequest() {}
00228
00229 MapBuilderRequestType_t getRequestType() const { return requestType; }
00230
00231
00232 std::set<color_index> allColors();
00233
00234
00235 void addObjectColor(ShapeType_t type, std::string const &color_name);
00236
00237
00238 void addObjectColor(ShapeType_t type, rgb color);
00239
00240
00241 void addSecondColor(ShapeType_t type, std::string const &color_name);
00242
00243
00244 void addSecondColor(ShapeType_t type, rgb color);
00245
00246
00247 void addAllObjectColors(ShapeType_t type);
00248
00249
00250 void addOccluderColor(ShapeType_t type, std::string const &color_name);
00251
00252
00253 void addMinBlobArea(std::string const &color_name, int area);
00254
00255
00256 void addAllMinBlobAreas(int area);
00257
00258
00259 void addBlobOrientation(std::string const &color_name, BlobData::BlobOrientation_t orient, coordinate_t assumedHeight=0);
00260
00261
00262 void addBlobOrientation(rgb color, BlobData::BlobOrientation_t orient, coordinate_t assumedHeight=0);
00263
00264
00265 void addCylinderHeight(std::string const &color_name, coordinate_t assumedHeight=0);
00266
00267
00268 void addCylinderHeight(rgb color, coordinate_t assumedHeight=0);
00269
00270
00271 void addMarkerType(MarkerType_t type);
00272
00273
00274 void addSiftObject(string const &name);
00275
00276
00277 void addAttributes(const ShapeRoot &shape);
00278
00279
00280 void setAprilTagFamily();
00281
00282
00283 void setAprilTagFamily(int bits, int minimumHammingDistance);
00284
00285
00286 void addAgentRecognition();
00287
00288 protected:
00289 bool validateRequest();
00290 static bool validateColors(const map<ShapeType_t,set<color_index> > &shapes2colors);
00291 bool validateSift();
00292 bool validateRequestType();
00293 static bool validateAdd(ShapeType_t type, std::string const &color_name);
00294
00295 };
00296
00297 }
00298
00299 #endif