Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef THREADLOCALIZE_H_
00009 #define THREADLOCALIZE_H_
00010
00011 #include "ThreadSLAM.h"
00012
00013 #include <sensor_msgs/LaserScan.h>
00014 #include <ros/ros.h>
00015 #include <sensor_msgs/LaserScan.h>
00016 #include <tf/transform_broadcaster.h>
00017
00018 #include "obvision/reconstruct/grid/SensorPolar2D.h"
00019 #include "obvision/reconstruct/grid/TsdGrid.h"
00020 #include "obvision/reconstruct/grid/RayCastPolar2D.h"
00021 #include "obvision/registration/icp/icp_def.h"
00022
00023 #include <string>
00024
00025 namespace ohm_tsd_slam
00026 {
00027
00028 class SlamNode;
00029 class ThreadMapping;
00030 class Localization;
00031
00032
00033 namespace
00034 {
00035 const unsigned int ICP_ITERATIONS = 25;
00036 const double TRNS_THRESH = 0.25;
00037 const double ROT_THRESH = 0.17;
00038 const double TRNS_MIN = 0.05;
00039 const double ROT_MIN = 0.03;
00040 const double DIST_FILT_MIN = 0.1;
00041 const double DIST_FILT_MAX = 1.0;
00042 const int RANSAC_TRIALS = 50;
00043 const double RANSAC_EPS_THRESH = 0.15;
00044 const int RANSAC_CTRL_SET_SIZE = 180;
00045 const double RANSAC_PHI_MAX = 30.0;
00046 }
00047
00048 class ThreadLocalize: public ThreadSLAM
00049 {
00050 enum EnumRegModes
00051 {
00052 ICP = 0,
00053 EXP
00054 };
00055
00056 public:
00066 ThreadLocalize(obvious::TsdGrid* grid, ThreadMapping* mapper, ros::NodeHandle* nh, std::string nameSpace,
00067 const double xOffset, const double yOffset);
00068
00072 virtual ~ThreadLocalize();
00073
00079 void laserCallBack(const sensor_msgs::LaserScan& scan);
00080 protected:
00081
00086 virtual void eventLoop(void);
00087 private:
00088
00094 void init(const sensor_msgs::LaserScan& scan);
00095
00102 double calcAngle(obvious::Matrix* T);
00103
00112 bool isPoseChangeSignificant(obvious::Matrix* lastPose, obvious::Matrix* curPose);
00113
00127 obvious::Matrix doRegistration(obvious::SensorPolar2D* sensor,
00128 obvious::Matrix* M,
00129 obvious::Matrix* Mvalid,
00130 obvious::Matrix* N,
00131 obvious::Matrix* Nvalid,
00132 obvious::Matrix* S,
00133 obvious::Matrix* Svalid,
00134 const bool experimental
00135 );
00136
00145 bool isRegistrationError(obvious::Matrix* T, const double trnsMax, const double rotMax);
00146
00152 void sendTransform(obvious::Matrix* T);
00153
00158 void sendNanTransform();
00159
00169 obvious::Matrix maskMatrix(obvious::Matrix* Mat, bool* mask, unsigned int maskSize, unsigned int validPoints);
00170
00182 void reduceResolution(bool* const maskIn, const obvious::Matrix* matIn, bool* const maskOut, obvious::Matrix* matOut,
00183 unsigned int pointsIn, unsigned int pointsOut, unsigned int reductionFactor);
00184
00185
00189 ros::NodeHandle* _nh;
00190
00194 ThreadMapping& _mapper;
00195
00199 obvious::SensorPolar2D* _sensor;
00200
00204 bool _initialized;
00205
00209 const double _gridWidth;
00210
00214 const double _gridHeight;
00215
00219 boost::mutex _dataMutex;
00220
00224 const double _gridOffSetX;
00225
00229 const double _gridOffSetY;
00230
00234 double _trnsMax;
00235
00239 double _rotMax;
00240
00244 const double _xOffset;
00245
00249 const double _yOffset;
00250
00254 EnumRegModes _regMode;
00255
00256
00257
00258
00259
00260
00261
00262
00263
00267 unsigned int _ranTrials;
00268
00272 double _ranEpsThresh;
00273
00277 unsigned int _ranSizeCtrlSet;
00278
00282 double _ranPhiMax;
00283
00287 std::string _nameSpace;
00288
00292 std::deque<sensor_msgs::LaserScan*> _laserData;
00293
00297 double* _modelCoords;
00298
00302 double* _modelNormals;
00303
00307 bool* _maskM;
00308
00312 double* _scene;
00313
00317 bool* _maskS;
00318
00322 obvious::RayCastPolar2D* _rayCaster;
00323
00327 obvious::PairAssignment* _assigner;
00328
00332 obvious::OutOfBoundsFilter2D* _filterBounds;
00333
00337 obvious::DistanceFilter* _filterDist;
00338
00342 obvious::ReciprocalFilter* _filterReciprocal;
00343
00347 obvious::IRigidEstimator* _estimator;
00348
00352 obvious::Icp* _icp;
00353
00357 obvious::Matrix* _lastPose;
00358
00362 ros::Publisher _posePub;
00363
00367 geometry_msgs::PoseStamped _poseStamped;
00368
00372 tf::TransformBroadcaster _tfBroadcaster;
00373
00377 tf::StampedTransform _tf;
00378 };
00379
00380
00381
00382 }
00383
00384 #endif