gridslamprocessor.h
Go to the documentation of this file.
1 #ifndef GRIDSLAMPROCESSOR_H
2 #define GRIDSLAMPROCESSOR_H
3 
4 #include <climits>
5 #include <limits>
6 #include <fstream>
7 #include <vector>
8 #include <deque>
12 #include <gmapping/log/sensorlog.h>
16 #include "motionmodel.h"
17 
18 
19 namespace GMapping {
20 
35  public:
36 
37 
42  struct TNode{
50  TNode(const OrientedPoint& pose, double weight, TNode* parent=0, unsigned int childs=0);
51 
54  ~TNode();
55 
58 
60  double weight;
61 
63  double accWeight;
64 
65  double gweight;
66 
67 
70 
73 
75  unsigned int childs;
76 
78  mutable unsigned int visitCounter;
79 
81  mutable bool flag;
82  };
83 
84  typedef std::vector<GridSlamProcessor::TNode*> TNodeVector;
85  typedef std::deque<GridSlamProcessor::TNode*> TNodeDeque;
86 
88  struct Particle{
92  Particle(const ScanMatcherMap& map);
93 
95  inline operator double() const {return weight;}
97  inline operator OrientedPoint() const {return pose;}
101  inline void setWeight(double w) {weight=w;}
106 
109 
111  double weight;
112 
114  double weightSum;
115 
116  double gweight;
117 
120 
123  };
124 
125 
126  typedef std::vector<Particle> ParticleVector;
127 
130 
134  GridSlamProcessor(std::ostream& infoStr);
135 
138  GridSlamProcessor* clone() const;
139 
141  virtual ~GridSlamProcessor();
142 
143  //methods for accessing the parameters
144  void setSensorMap(const SensorMap& smap);
145  void init(unsigned int size, double xmin, double ymin, double xmax, double ymax, double delta,
146  OrientedPoint initialPose=OrientedPoint(0,0,0));
147  void setMatchingParameters(double urange, double range, double sigma, int kernsize, double lopt, double aopt,
148  int iterations, double likelihoodSigma=1, double likelihoodGain=1, unsigned int likelihoodSkip=0);
149  void setMotionModelParameters(double srr, double srt, double str, double stt);
150  void setUpdateDistances(double linear, double angular, double resampleThreshold);
151  void setUpdatePeriod(double p) {period_=p;}
152 
153  //the "core" algorithm
154  void processTruePos(const OdometryReading& odometry);
155  bool processScan(const RangeReading & reading, int adaptParticles=0);
156 
162  TNodeVector getTrajectories() const;
163  void integrateScanSequence(TNode* node);
164 
168  std::ofstream& outputStream();
170  std::ostream& infoStream();
172  inline const ParticleVector& getParticles() const {return m_particles; }
173 
174  inline const std::vector<unsigned int>& getIndexes() const{return m_indexes; }
175  int getBestParticleIndex() const;
176  //callbacks
177  virtual void onOdometryUpdate();
178  virtual void onResampleUpdate();
179  virtual void onScanmatchUpdate();
180 
181  //accessor methods
183  MEMBER_PARAM_SET_GET(m_matcher, double, laserMaxRange, protected, public, public);
184 
186  MEMBER_PARAM_SET_GET(m_matcher, double, usableRange, protected, public, public);
187 
189  MEMBER_PARAM_SET_GET(m_matcher,double, gaussianSigma, protected, public, public);
190 
192  MEMBER_PARAM_SET_GET(m_matcher,double, likelihoodSigma, protected, public, public);
193 
195  MEMBER_PARAM_SET_GET(m_matcher, int, kernelSize, protected, public, public);
196 
198  MEMBER_PARAM_SET_GET(m_matcher, double, optAngularDelta, protected, public, public);
199 
201  MEMBER_PARAM_SET_GET(m_matcher, double, optLinearDelta, protected, public, public);
202 
204  MEMBER_PARAM_SET_GET(m_matcher, unsigned int, optRecursiveIterations, protected, public, public);
205 
207  MEMBER_PARAM_SET_GET(m_matcher, unsigned int, likelihoodSkip, protected, public, public);
208 
210  MEMBER_PARAM_SET_GET(m_matcher, double, llsamplerange, protected, public, public);
211 
213  MEMBER_PARAM_SET_GET(m_matcher, double, lasamplerange, protected, public, public);
214 
216  MEMBER_PARAM_SET_GET(m_matcher, double, llsamplestep, protected, public, public);
217 
219  MEMBER_PARAM_SET_GET(m_matcher, double, lasamplestep, protected, public, public);
220 
222  MEMBER_PARAM_SET_GET(m_matcher, bool, generateMap, protected, public, public);
223 
225  MEMBER_PARAM_SET_GET(m_matcher, bool, enlargeStep, protected, public, public);
226 
228  MEMBER_PARAM_SET_GET(m_matcher, OrientedPoint, laserPose, protected, public, public);
229 
230 
232  STRUCT_PARAM_SET_GET(m_motionModel, double, srr, protected, public, public);
233 
235  STRUCT_PARAM_SET_GET(m_motionModel, double, srt, protected, public, public);
236 
238  STRUCT_PARAM_SET_GET(m_motionModel, double, str, protected, public, public);
239 
241  STRUCT_PARAM_SET_GET(m_motionModel, double, stt, protected, public, public);
242 
244  PARAM_SET_GET(double, minimumScore, protected, public, public);
245 
246  protected:
249 
251  unsigned int m_beams;
253  double period_;
254 
256  ParticleVector m_particles;
257 
259  std::vector<unsigned int> m_indexes;
260 
262  std::vector<double> m_weights;
263 
266 
268  PARAM_SET_GET(double, resampleThreshold, protected, public, public);
269 
270  //state
276  PARAM_GET(double, neff, protected, public);
277 
278  //processing parameters (size of the map)
279  PARAM_GET(double, xmin, protected, public);
280  PARAM_GET(double, ymin, protected, public);
281  PARAM_GET(double, xmax, protected, public);
282  PARAM_GET(double, ymax, protected, public);
283  //processing parameters (resolution of the map)
284  PARAM_GET(double, delta, protected, public);
285 
286  //registration score (if a scan score is above this threshold it is registered in the map)
287  PARAM_SET_GET(double, regScore, protected, public, public);
288  //registration score (if a scan score is below this threshold a scan matching failure is reported)
289  PARAM_SET_GET(double, critScore, protected, public, public);
290  //registration score maximum move allowed between consecutive scans
291  PARAM_SET_GET(double, maxMove, protected, public, public);
292 
293  //process a scan each time the robot translates of linearThresholdDistance
294  PARAM_SET_GET(double, linearThresholdDistance, protected, public, public);
295 
296  //process a scan each time the robot rotates more than angularThresholdDistance
297  PARAM_SET_GET(double, angularThresholdDistance, protected, public, public);
298 
299  //smoothing factor for the likelihood
300  PARAM_SET_GET(double, obsSigmaGain, protected, public, public);
301 
302  //stream in which to write the gfs file
303  std::ofstream m_outputStream;
304 
305  // stream in which to write the messages
306  std::ostream& m_infoStream;
307 
308 
309  // the functions below performs side effect on the internal structure,
310  //should be called only inside the processScan method
311  private:
312 
314  inline void scanMatch(const double *plainReading);
316  inline void normalize();
317 
318  // return if a resampling occured or not
319  inline bool resample(const double* plainReading, int adaptParticles,
320  const RangeReading* rr=0);
321 
322  //tree utilities
323 
324  void updateTreeWeights(bool weightsAlreadyNormalized = false);
325  void resetTree();
326  double propagateWeights();
327 
328  };
329 
330 typedef std::multimap<const GridSlamProcessor::TNode*, GridSlamProcessor::TNode*> TNodeMultimap;
331 
332 
333 #include "gridslamprocessor.hxx"
334 
335 };
336 
337 #endif
const char *const *argv double delta
Definition: gfs2stream.cpp:19
bool neff
Definition: gfs2stream.cpp:39
PARAM_GET(double, neff, protected, public)
std::vector< double > m_weights
const ParticleVector & getParticles() const
std::vector< GridSlamProcessor::TNode * > TNodeVector
std::vector< unsigned int > m_indexes
void setMatchingParameters(double urange, double range, double sigma, int kernsize, double lopt, double aopt, int iterations, double likelihoodSigma=1, double likelihoodGain=1, unsigned int likelihoodSkip=0)
bool processScan(const RangeReading &reading, int adaptParticles=0)
STRUCT_PARAM_SET_GET(m_motionModel, double, srr, protected, public, public)
bool resample(const double *plainReading, int adaptParticles, const RangeReading *rr=0)
std::vector< Particle > ParticleVector
TNode(const OrientedPoint &pose, double weight, TNode *parent=0, unsigned int childs=0)
std::deque< GridSlamProcessor::TNode * > TNodeDeque
std::multimap< const GridSlamProcessor::TNode *, GridSlamProcessor::TNode * > TNodeMultimap
const std::vector< unsigned int > & getIndexes() const
void setUpdateDistances(double linear, double angular, double resampleThreshold)
void setSensorMap(const SensorMap &smap)
void processTruePos(const OdometryReading &odometry)
GridSlamProcessor * clone() const
void scanMatch(const double *plainReading)
std::map< std::string, Sensor * > SensorMap
Definition: sensor.h:19
PARAM_SET_GET(double, minimumScore, protected, public, public)
void init(unsigned int size, double xmin, double ymin, double xmax, double ymax, double delta, OrientedPoint initialPose=OrientedPoint(0, 0, 0))
void setMotionModelParameters(double srr, double srt, double str, double stt)
void updateTreeWeights(bool weightsAlreadyNormalized=false)
orientedpoint< double, double > OrientedPoint
Definition: point.h:203
MEMBER_PARAM_SET_GET(m_matcher, double, laserMaxRange, protected, public, public)


openslam_gmapping
Author(s): Giorgio Grisetti, Cyrill Stachniss, Wolfram Burgard
autogenerated on Mon Jun 10 2019 14:04:22