MIRA
OccupancyGridMapping.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Redistribution and modification of this code is strictly prohibited.
9  *
10  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
11  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
12  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
13  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  *
15  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
16  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
18  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
19  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
20  */
21 
30 #ifndef _MIRA_OCCUPANCYGRIDMAPPING_H_
31 #define _MIRA_OCCUPANCYGRIDMAPPING_H_
32 
33 
34 #include <robot/RangeScan.h>
35 #include <transform/Pose.h>
36 
37 #include <maps/OccupancyGrid.h>
38 
39 #include <mapping/MappingExports.h>
41 
42 namespace mira { namespace maps {
43 
45 
61 {
62 public:
63 
66 
67 public:
68 
78  void insertScan(OccupancyGrid& map, const Pose3& pose,
79  const robot::RangeScan& scan, float maxRange = 5.0f)
80  {
81  insertScan(map, pose, pose, scan, maxRange);
82  }
98  void insertScan(OccupancyGrid& map, const Pose3& poseStart, const Pose3& poseEnd,
99  const robot::RangeScan& scan, float maxRange = 5.0f);
100 
101 
107  static void clampToMapOccupancyLimits(OccupancyGrid& map, const Rect2f& region, uint8 min, uint8 max);
108 
109 public:
110 
120  void setSensorReliabilitySigma(float sigma) {
121  mSensorReliabilitySigma = sigma;
122  invalidateReliabilityLUT();
123  }
124 
129  return mSensorReliabilitySigma;
130  }
131 
144  mMaxEstimationOccupancy = max;
145  mMinEstimationOccupancy = min;
146  }
152  mMinEstimationOccupancy = min;
153  }
155  return mMinEstimationOccupancy;
156  }
157 
163  mMaxEstimationOccupancy = max;
164  }
166  return mMaxEstimationOccupancy;
167  }
168 
180  void setMapOccupancyLimits(uint8 min, uint8 max);
186  setMapOccupancyLimits(min, mMaxMapOccupancy);
187  }
189  return mMinMapOccupancy;
190  }
191 
197  setMapOccupancyLimits(mMinMapOccupancy, max);
198  }
200  return mMaxMapOccupancy;
201  }
202 
209  void setEnsureOccupancyLimitsAfterUpdate(bool enable);
210 
212  return mEnsureOccupancyLimitsAfterUpdate;
213  }
214 
224  void setLocalCropRadius(float localRadius) {
225  mLocalCropRadius = localRadius;
226  }
227  float getLocalCropRadius() const {
228  return mLocalCropRadius;
229  }
230 
235  void setMinCertainty(float certainty) {
236  mMinCertainty = certainty;
237  }
238 
239  float getMinCertainty() const {
240  return mMinCertainty;
241  }
242 
243 private:
244 
245  template <bool useReliability, bool freeOnly>
246  class Visitor;
247 
248  template <bool useReliability, bool freeOnly>
249  friend class Visitor;
250 
251 private:
252 
253  template<bool useReliability>
254  void update(OccupancyGrid& map,
255  const Pose3& poseStart, const Pose3& poseEnd,
256  const robot::RangeScan& scan, float maxRange);
257 
258 
259 private:
260 
261  // the parameters that can be set above
262  uint8 mMaxEstimationOccupancy;
263  uint8 mMinEstimationOccupancy;
264  uint8 mMaxMapOccupancy;
265  uint8 mMinMapOccupancy;
266  bool mEnsureOccupancyLimitsAfterUpdate;
267 
268  float mSensorReliabilitySigma;
269 
270  float mLocalCropRadius;
271  float mMinCertainty;
272 
273 private:
274 
286  uint8 mBayesLUT[256][256];
287  void buildBayesLUT();
288 
289  enum { RELIABILITY_LUT_RESOLUTION = 1024 };
290  std::vector<uint8> mReliabilityLUT;
291  uint8 getReliability(float d) const;
292 
293  void buildReliabilityLUT(float max_d);
294  void invalidateReliabilityLUT();
295 
296 };
297 
299 }}
301 
302 #endif
bool getEnsureOccupancyLimitsAfterUpdate() const
Definition: OccupancyGridMapping.h:211
float getMinCertainty() const
Definition: OccupancyGridMapping.h:239
Rasterizes a range scan.
void setMinOccupancyLimit(uint8 min)
Sets the minimum occupancy in the map.
Definition: OccupancyGridMapping.h:185
uint8 getMinEstimationOccupancyLimit() const
Definition: OccupancyGridMapping.h:154
Definition: GridMap.h:67
uint8 getMaxEstimationOccupancyLimit() const
Definition: OccupancyGridMapping.h:165
float getSensorReliabilitySigma() const
Returns the sigma for distance reliability function.
Definition: OccupancyGridMapping.h:128
uint8 getMaxOccupancyLimit() const
Definition: OccupancyGridMapping.h:199
Mapping export macro declaration.
void setSensorReliabilitySigma(float sigma)
Set sigma for distance reliability function.
Definition: OccupancyGridMapping.h:120
Inserts range scan into an occupancy map.
Definition: OccupancyGridMapping.h:60
float getLocalCropRadius() const
Definition: OccupancyGridMapping.h:227
void setEstimationOccupancyLimits(uint8 min, uint8 max)
Set the occupancy limits for current estimation.
Definition: OccupancyGridMapping.h:143
uint8_t uint8
void setMaxEstimationOccupancyLimit(uint8 max)
Sets the maximum occupancy estimated for current observation.
Definition: OccupancyGridMapping.h:162
void setLocalCropRadius(float localRadius)
Sets the local cropping radius for mapping.
Definition: OccupancyGridMapping.h:224
void setMinEstimationOccupancyLimit(uint8 min)
Sets the minimum occupancy estimated for current observation.
Definition: OccupancyGridMapping.h:151
void insertScan(OccupancyGrid &map, const Pose3 &pose, const robot::RangeScan &scan, float maxRange=5.0f)
Inserts a range scan into the specified occupancy map at the specified robot pose.
Definition: OccupancyGridMapping.h:78
void setMinCertainty(float certainty)
Sets the minimum certainty a scan must have to be taken into account.
Definition: OccupancyGridMapping.h:235
uint8 getMinOccupancyLimit() const
Definition: OccupancyGridMapping.h:188
void setMaxOccupancyLimit(uint8 max)
Sets the maximum occupancy in the map.
Definition: OccupancyGridMapping.h:196
#define MIRA_MAPPING_MAPPING_EXPORT
Definition: MappingExports.h:44
Occupancy grid definition.