BeoSub.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef BEOSUB_H_DEFINED
00039 #define BEOSUB_H_DEFINED
00040
00041 #include "Util/Angle.H"
00042 #include "BeoSub/Attitude.H"
00043 #include "BeoSub/BeoSubDB.H"
00044 #include "BeoSub/BeoSubCanny.H"
00045 #include "BeoSub/BeoSubTaskDecoder.H"
00046 #include "BeoSub/ColorTracker.H"
00047 #include "Component/ModelComponent.H"
00048 #include "Component/ModelParam.H"
00049 #include "Image/Image.H"
00050 #include "Image/Pixels.H"
00051 #include "Image/ImageSet.H"
00052 #include "SIFT/VisualObject.H"
00053 #include "Util/Timer.H"
00054 #include <pthread.h>
00055
00056 class RawVisualCortex;
00057 class VisualObjectDB;
00058 class ShapeModel;
00059
00060
00061 struct Location {
00062 float x, y;
00063 };
00064
00065
00066 enum BeoSubCamera { BEOSUBCAMDOWN = 0, BEOSUBCAMFRONT = 1,
00067 BEOSUBCAMUP = 2 };
00068
00069
00070 const char *beoSubCameraName(const BeoSubCamera cam);
00071
00072
00073
00074
00075
00076
00077
00078 class BeoSub : public ModelComponent
00079 {
00080 public:
00081
00082
00083
00084
00085
00086 BeoSub(OptionManager& mgr,
00087 const std::string& descrName = "BeoSub",
00088 const std::string& tagName = "BeoSub");
00089
00090
00091 virtual ~BeoSub();
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 virtual void checkpoint(const char *fmt, ...)
00103 // NOTE: this __attribute__ tells gcc that it should issue
00104 // printf-style warnings when compiling calls to
00105 // BeoSub::checkpoint(), treating the 1st argument (fmt) as the
00106 // format string, and the 2nd and subsequent arguments as the
00107 // printf-style parameters (SUBNOTE: because this is a member
00108 // function, there is a hidden 'this' parameter that counts as arg
00109 // 1, so the listed arguments are counted starting from 2)
00110 __attribute__((format(__printf__, 2, 3))) = 0;
00111
00112
00113 */
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 bool targetReached(const float tol = 1.0F) const;
00124
00125
00126 void waitMove(const double timeout);
00127
00128
00129
00130
00131 void turnAbs(const Angle finalHeading, const bool blocking = false);
00132
00133
00134 void turnRel(const Angle relHeading, const bool blocking = false);
00135
00136 virtual void turnOpen(const Angle openHeading, const bool stop = true) = 0;
00137
00138
00139 void pitchAbs(const Angle finalPitch, const bool blocking = false);
00140
00141
00142 void diveAbs(const float finalDepth, const bool blocking = false);
00143
00144
00145
00146 void diveRel(const float relDepth, const bool blocking = false);
00147
00148
00149
00150
00151
00152 virtual void advanceRel(const float relDist, const bool stop = true) = 0;
00153
00154
00155
00156
00157
00158 virtual void strafeRel(const float relDist);
00159
00160
00161 virtual void dropMarker(const bool blocking = false) = 0;
00162
00163
00164
00165
00166
00167
00168
00169
00170 virtual Image< PixRGB<byte> >
00171 grabImage(const enum BeoSubCamera cam) const = 0;
00172
00173
00174
00175
00176
00177 virtual Image<float> getSaliencyMap(const enum BeoSubCamera cam) const;
00178
00179
00180 bool matchSIFT(const enum BeoSubCamera cam,
00181 const rutz::shared_ptr<VisualObject>& obj) const;
00182
00183
00184
00185 virtual bool recognizeSIFT(const enum BeoSubCamera cam,
00186 MappingData& data, Angle& myHeading) const;
00187
00188 virtual bool affineSIFT(const enum BeoSubCamera cam,
00189 rutz::shared_ptr<VisualObject> goal);
00190
00191 virtual bool findShape(rutz::shared_ptr<ShapeModel>& shapeArg, const char* colorArg, const enum BeoSubCamera camArg) const;
00192
00193 virtual bool centerColor(const char* colorArg, const enum BeoSubCamera camArg, float& thresholdMass);
00194
00195 virtual bool approachArea(std::string name, const enum BeoSubCamera cam, float stepdist);
00196
00197 virtual bool approachArea(MappingData goalArea, MappingData currentArea, float stepDist);
00198
00199 virtual bool Decode();
00200
00201 virtual bool TaskGate();
00202
00203 virtual bool TaskA();
00204
00205 virtual bool TaskB();
00206
00207 virtual bool TaskC();
00208
00209
00210
00211
00212
00213
00214 bool TaskScheduler(int TaskOrder);
00215
00216
00217 bool LookForRedLight();
00218 bool CenterRedLight();
00219 bool ApproachRedLight();
00220 bool PushRedLight();
00221
00222
00223
00224 virtual bool ApproachPipeLine();
00225
00226 bool FollowPipeLine();
00227
00228 int RecognizeBin();
00229
00230 bool TestBin(nub::soft_ref<FrameIstream> gb, int testColor);
00231
00232 bool CenterBin();
00233
00234 bool DropMarker();
00235
00236 bool PassBin();
00237
00238
00239
00240
00241
00242
00243
00244 double getTime() const;
00245
00246
00247 Attitude getCurrentAttitude() const;
00248
00249
00250 Attitude getTargetAttitude() const;
00251
00252
00253 Angle getHeading() const;
00254
00255
00256 Angle getPitch() const;
00257
00258
00259 Angle getRoll() const;
00260
00261
00262 void getCompass(Angle& heading, Angle& pitch, Angle& roll) const;
00263
00264
00265 float getDepth() const;
00266
00267
00268
00269
00270 protected:
00271 OModelParam<std::string> itsFrontVODBfname;
00272 rutz::shared_ptr<VisualObjectDB> itsFrontVODB;
00273 OModelParam<std::string> itsDownVODBfname;
00274 rutz::shared_ptr<VisualObjectDB> itsDownVODB;
00275 OModelParam<std::string> itsUpVODBfname;
00276 rutz::shared_ptr<VisualObjectDB> itsUpVODB;
00277
00278 Timer itsMasterClock;
00279 int itsCkPt;
00280 Attitude itsCurrentAttitude;
00281
00282
00283
00284
00285
00286 Location itsGlobalPosition;
00287 Angle itsGlobalHeading;
00288
00289 Attitude itsTargetAttitude;
00290 nub::soft_ref<RawVisualCortex> itsVisualCortex;
00291
00292 std::string itsFrontDBfname;
00293 rutz::shared_ptr<BeoSubDB> itsFrontDB;
00294 std::string itsDownDBfname;
00295 rutz::shared_ptr<BeoSubDB> itsDownDB;
00296 std::string itsUpDBfname;
00297 rutz::shared_ptr<BeoSubDB> itsUpDB;
00298
00299 nub::soft_ref<BeoSubCanny> itsShapeDetector;
00300 nub::soft_ref<BeoSubTaskDecoder> itsTaskDecoder;
00301 nub::soft_ref<ColorTracker> itsColorTracker;
00302 nub::soft_ref<ColorTracker> itsColorTracker2;
00303
00304 bool decoderIsRed;
00305 public:
00306 bool taskAdone;
00307 bool taskBdone;
00308 bool taskCdone;
00309 std::list<char> itsTasks;
00310 std::list<char>::iterator itsTasksIter;
00311
00312 rutz::shared_ptr<VisualObject> itsVOtaskAdown, itsVOtaskAfront;
00313 rutz::shared_ptr<VisualObject> itsVOtaskBdown, itsVOtaskBfront;
00314 rutz::shared_ptr<VisualObject> itsVOtaskCdown, itsVOtaskCfront, itsVOtaskCup;
00315 rutz::shared_ptr<VisualObject> itsVOtaskGdown, itsVOtaskGfront, itsVOtaskGup;
00316 rutz::shared_ptr<VisualObject> itsVOtaskDfront;
00317
00318 Location taskAposition, taskBposition, taskCposition, taskGposition;
00319
00320 protected:
00321 pthread_mutex_t itsLock;
00322
00323 virtual void start1();
00324 };
00325
00326
00327 #endif
00328
00329
00330
00331
00332
00333