MRPT  1.9.9
CRandomFieldGridMap2D.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
15 #include <mrpt/img/CImage.h>
16 #include <mrpt/maps/CMetricMap.h>
17 #include <mrpt/math/CMatrixD.h>
20 
21 #include <list>
22 
23 namespace mrpt::maps
24 {
25 class COccupancyGridMap2D;
26 
27 // Pragma defined to ensure no structure packing: since we'll serialize
28 // TRandomFieldCell to streams, we want it not to depend on compiler options,
29 // etc.
30 #if defined(MRPT_IS_X86_AMD64)
31 #pragma pack(push, 1)
32 #endif
33 
34 /** The contents of each cell in a CRandomFieldGridMap2D map.
35  * \ingroup mrpt_maps_grp
36  **/
38 {
39  /** Constructor */
40  TRandomFieldCell(double kfmean_dm_mean = 1e-20, double kfstd_dmmeanw = 0)
41  : kf_mean(kfmean_dm_mean),
42  kf_std(kfstd_dmmeanw),
43 
44  last_updated(mrpt::system::now()),
45  updated_std(kfstd_dmmeanw)
46  {
47  }
48 
49  // *Note*: Use unions to share memory between data fields, since only a set
50  // of the variables will be used for each mapping strategy.
51  // You can access to a "TRandomFieldCell *cell" like: cell->kf_mean,
52  // cell->kf_std, etc..
53  // but accessing cell->kf_mean would also modify (i.e. ARE the same memory
54  // slot) cell->dm_mean, for example.
55 
56  // Note 2: If the number of type of fields are changed in the future,
57  // *PLEASE* also update the writeToStream() and readFromStream() methods!!
58 
59  union {
60  /** [KF-methods only] The mean value of this cell */
61  double kf_mean;
62  /** [Kernel-methods only] The cumulative weighted readings of this cell
63  */
64  double dm_mean;
65  /** [GMRF only] The mean value of this cell */
66  double gmrf_mean;
67  };
68 
69  union {
70  /** [KF-methods only] The standard deviation value of this cell */
71  double kf_std;
72  /** [Kernel-methods only] The cumulative weights (concentration = alpha
73  * * dm_mean / dm_mean_w + (1-alpha)*r0 ) */
74  double dm_mean_w;
75  double gmrf_std;
76  };
77 
78  /** [Kernel DM-V only] The cumulative weighted variance of this cell */
79  double dmv_var_mean{0};
80 
81  /** [Dynamic maps only] The timestamp of the last time the cell was updated
82  */
84  /** [Dynamic maps only] The std cell value that was updated (to be used in
85  * the Forgetting_curve */
86  double updated_std;
87 };
88 
89 #if defined(MRPT_IS_X86_AMD64)
90 #pragma pack(pop)
91 #endif
92 
93 /** CRandomFieldGridMap2D represents a 2D grid map where each cell is associated
94  *one real-valued property which is estimated by this map, either
95  * as a simple value or as a probility distribution (for each cell).
96  *
97  * There are a number of methods available to build the MRF grid-map,
98  *depending on the value of
99  * `TMapRepresentation maptype` passed in the constructor.
100  *
101  * The following papers describe the mapping alternatives implemented here:
102  * - `mrKernelDM`: A Gaussian kernel-based method. See:
103  * - "Building gas concentration gridmaps with a mobile robot",
104  *Lilienthal,
105  *A. and Duckett, T., Robotics and Autonomous Systems, v.48, 2004.
106  * - `mrKernelDMV`: A kernel-based method. See:
107  * - "A Statistical Approach to Gas Distribution Modelling with Mobile
108  *Robots--The Kernel DM+ V Algorithm", Lilienthal, A.J. and Reggente, M. and
109  *Trincavelli, M. and Blanco, J.L. and Gonzalez, J., IROS 2009.
110  * - `mrKalmanFilter`: A "brute-force" approach to estimate the entire map
111  *with a dense (linear) Kalman filter. Will be very slow for mid or large maps.
112  *It's provided just for comparison purposes, not useful in practice.
113  * - `mrKalmanApproximate`: A compressed/sparse Kalman filter approach.
114  *See:
115  * - "A Kalman Filter Based Approach to Probabilistic Gas Distribution
116  *Mapping", JL Blanco, JG Monroy, J Gonzalez-Jimenez, A Lilienthal, 28th
117  *Symposium On Applied Computing (SAC), 2013.
118  * - `mrGMRF_SD`: A Gaussian Markov Random Field (GMRF) estimator, with
119  *these
120  *constraints:
121  * - `mrGMRF_SD`: Each cell only connected to its 4 immediate neighbors
122  *(Up,
123  *down, left, right).
124  * - (Removed in MRPT 1.5.0: `mrGMRF_G`: Each cell connected to a
125  *square
126  *area
127  *of neighbors cells)
128  * - See papers:
129  * - "Time-variant gas distribution mapping with obstacle
130  *information",
131  *Monroy, J. G., Blanco, J. L., & Gonzalez-Jimenez, J. Autonomous Robots,
132  *40(1), 1-16, 2016.
133  *
134  * Note that this class is virtual, since derived classes still have to
135  *implement:
136  * - mrpt::maps::CMetricMap::internal_computeObservationLikelihood()
137  * - mrpt::maps::CMetricMap::internal_insertObservation()
138  * - Serialization methods: writeToStream() and readFromStream()
139  *
140  * [GMRF only] A custom connectivity pattern between cells can be defined by
141  *calling setCellsConnectivity().
142  *
143  * \sa mrpt::maps::CGasConcentrationGridMap2D,
144  *mrpt::maps::CWirelessPowerGridMap2D, mrpt::maps::CMetricMap,
145  *mrpt::containers::CDynamicGrid, The application icp-slam,
146  *mrpt::maps::CMultiMetricMap
147  * \ingroup mrpt_maps_grp
148  */
150  : public mrpt::maps::CMetricMap,
151  public mrpt::containers::CDynamicGrid<TRandomFieldCell>,
153 {
155 
157  public:
158  /** Calls the base CMetricMap::clear
159  * Declared here to avoid ambiguity between the two clear() in both base
160  * classes.
161  */
162  inline void clear() { CMetricMap::clear(); }
163  // This method is just used for the ::saveToTextFile() method in base class.
164  float cell2float(const TRandomFieldCell& c) const override
165  {
166  return c.kf_mean;
167  }
168 
169  /** The type of map representation to be used, see CRandomFieldGridMap2D for
170  * a discussion.
171  */
173  {
174  /** Gaussian kernel-based estimator (see discussion in
175  mrpt::maps::CRandomFieldGridMap2D) */
177  /** Another alias for "mrKernelDM", for backwards compatibility (see
178  discussion in mrpt::maps::CRandomFieldGridMap2D) */
179  mrAchim = 0,
180  /** "Brute-force" Kalman filter (see discussion in
181  mrpt::maps::CRandomFieldGridMap2D) */
183  /** (see discussion in mrpt::maps::CRandomFieldGridMap2D) */
185  /** Double mean + variance Gaussian kernel-based estimator (see
186  discussion in mrpt::maps::CRandomFieldGridMap2D) */
188  // Removed in MRPT 1.5.0: mrGMRF_G, //!< Gaussian Markov Random Field,
189  // Gaussian prior weights between neighboring cells up to a certain
190  // distance (see discussion in mrpt::maps::CRandomFieldGridMap2D)
191  /** Gaussian Markov Random Field, squared differences prior weights
192  between 4 neighboring cells (see discussion in
193  mrpt::maps::CRandomFieldGridMap2D) */
195  };
196 
197  /** Constructor */
199  TMapRepresentation mapType = mrKernelDM, double x_min = -2,
200  double x_max = 2, double y_min = -2, double y_max = 2,
201  double resolution = 0.1);
202 
203  /** Destructor */
204  ~CRandomFieldGridMap2D() override;
205 
206  /** Returns true if the map is empty/no observation has been inserted (in
207  * this class it always return false,
208  * unless redefined otherwise in base classes)
209  */
210  bool isEmpty() const override;
211 
212  /** Save the current map as a graphical file (BMP,PNG,...).
213  * The file format will be derived from the file extension (see
214  *CImage::saveToFile )
215  * It depends on the map representation model:
216  * mrAchim: Each pixel is the ratio \f$ \sum{\frac{wR}{w}} \f$
217  * mrKalmanFilter: Each pixel is the mean value of the Gaussian that
218  *represents each cell.
219  *
220  * \sa \a getAsBitmapFile()
221  */
222  virtual void saveAsBitmapFile(const std::string& filName) const;
223 
224  /** Returns an image just as described in \a saveAsBitmapFile */
225  virtual void getAsBitmapFile(mrpt::img::CImage& out_img) const;
226 
227  /** Like saveAsBitmapFile(), but returns the data in matrix form (first row
228  * in the matrix is the upper (y_max) part of the map) */
229  virtual void getAsMatrix(mrpt::math::CMatrixDouble& out_mat) const;
230 
231  /** Parameters common to any derived class.
232  * Derived classes should derive a new struct from this one, plus "public
233  * utils::CLoadableOptions",
234  * and call the internal_* methods where appropiate to deal with the
235  * variables declared here.
236  * Derived classes instantions of their "TInsertionOptions" MUST set the
237  * pointer "m_insertOptions_common" upon construction.
238  */
240  {
241  /** Default values loader */
243 
244  /** See utils::CLoadableOptions */
247  const std::string& section);
248 
249  /** See utils::CLoadableOptions */
250  void internal_dumpToTextStream_common(std::ostream& out) const;
251 
252  /** @name Kernel methods (mrKernelDM, mrKernelDMV)
253  @{ */
254  /** The sigma of the "Parzen"-kernel Gaussian */
255  float sigma{0.15f};
256  /** The cutoff radius for updating cells. */
258  /** Limits for normalization of sensor readings. */
259  float R_min{0}, R_max{3};
260  /** [DM/DM+V methods] The scaling parameter for the confidence "alpha"
261  * values (see the IROS 2009 paper; see CRandomFieldGridMap2D) */
262  double dm_sigma_omega{0.05};
263  /** @} */
264 
265  /** @name Kalman-filter methods (mrKalmanFilter, mrKalmanApproximate)
266  @{ */
267  /** The "sigma" for the initial covariance value between cells (in
268  * meters). */
269  float KF_covSigma{0.35f};
270  /** The initial standard deviation of each cell's concentration (will be
271  * stored both at each cell's structure and in the covariance matrix as
272  * variances in the diagonal) (in normalized concentration units). */
273  float KF_initialCellStd{1.0};
274  /** The sensor model noise (in normalized concentration units). */
276  /** The default value for the mean of cells' concentration. */
278  /** [mrKalmanApproximate] The size of the window of neighbor cells. */
280  /** @} */
281 
282  /** @name Gaussian Markov Random Fields methods (mrGMRF_SD)
283  @{ */
284  /** The information (Lambda) of fixed map constraints */
285  double GMRF_lambdaPrior{0.01f};
286  /** The initial information (Lambda) of each observation (this
287  * information will decrease with time) */
288  double GMRF_lambdaObs{10.0f};
289  /** The loss of information of the observations with each iteration */
290  double GMRF_lambdaObsLoss{0.0f};
291 
292  /** whether to use information of an occupancy_gridmap map for building
293  * the GMRF */
295  /** simplemap_file name of the occupancy_gridmap */
297  /** image name of the occupancy_gridmap */
299  /** occupancy_gridmap resolution: size of each pixel (m) */
300  double GMRF_gridmap_image_res{0.01f};
301  /** Pixel coordinates of the origin for the occupancy_gridmap */
303  /** Pixel coordinates of the origin for the occupancy_gridmap */
305 
306  /** (Default:-inf,+inf) Saturate the estimated mean in these limits */
308  /** (Default:false) Skip the computation of the variance, just compute
309  * the mean */
310  bool GMRF_skip_variance{false};
311  /** @} */
312  };
313 
314  /** Changes the size of the grid, maintaining previous contents. \sa setSize
315  */
316  void resize(
317  double new_x_min, double new_x_max, double new_y_min, double new_y_max,
318  const TRandomFieldCell& defaultValueNewCells,
319  double additionalMarginMeters = 1.0f) override;
320 
321  /** Changes the size of the grid, erasing previous contents.
322  * \param[in] connectivity_descriptor Optional user-supplied object that
323  * will visit all grid cells to define their connectivity with neighbors and
324  * the strength of existing edges. If present, it overrides all options in
325  * insertionOptions
326  * \sa resize
327  */
328  virtual void setSize(
329  const double x_min, const double x_max, const double y_min,
330  const double y_max, const double resolution,
331  const TRandomFieldCell* fill_value = nullptr);
332 
333  /** Base class for user-supplied objects capable of describing cells
334  * connectivity, used to build prior factors of the MRF graph. \sa
335  * setCellsConnectivity() */
337  {
340  virtual ~ConnectivityDescriptor();
341 
342  /** Implement the check of whether node i=(icx,icy) is connected with
343  * node j=(jcx,jcy).
344  * This visitor method will be called only for immediate neighbors.
345  * \return true if connected (and the "information" value should be
346  * also updated in out_edge_information), false otherwise.
347  */
348  virtual bool getEdgeInformation(
349  /** The parent map on which we are running */
350  const CRandomFieldGridMap2D* parent,
351  /** (cx,cy) for node "i" */
352  size_t icx, size_t icy,
353  /** (cx,cy) for node "j" */
354  size_t jcx, size_t jcy,
355  /** Must output here the inverse of the variance of the constraint
356  edge. */
357  double& out_edge_information) = 0;
358  };
359 
360  /** Sets a custom object to define the connectivity between cells. Must call
361  * clear() or setSize() afterwards for the changes to take place. */
363  const ConnectivityDescriptor::Ptr& new_connectivity_descriptor);
364 
365  /** See docs in base class: in this class this always returns 0 */
367  const mrpt::maps::CMetricMap* otherMap,
368  const mrpt::poses::CPose3D& otherMapPose,
369  const TMatchingRatioParams& params) const override;
370 
371  /** The implementation in this class just calls all the corresponding method
372  * of the contained metric maps */
374  const std::string& filNamePrefix) const override;
375 
376  /** Save a matlab ".m" file which represents as 3D surfaces the mean and a
377  * given confidence level for the concentration of each cell.
378  * This method can only be called in a KF map model.
379  * \sa getAsMatlab3DGraphScript */
380  virtual void saveAsMatlab3DGraph(const std::string& filName) const;
381 
382  /** Return a large text block with a MATLAB script to plot the contents of
383  * this map \sa saveAsMatlab3DGraph
384  * This method can only be called in a KF map model */
385  void getAsMatlab3DGraphScript(std::string& out_script) const;
386 
387  /** Returns a 3D object representing the map (mean) */
388  void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr& outObj) const override;
389 
390  /** Returns two 3D objects representing the mean and variance maps */
391  virtual void getAs3DObject(
393  mrpt::opengl::CSetOfObjects::Ptr& varObj) const;
394 
395  /** Return the type of the random-field grid map, according to parameters
396  * passed on construction. */
398 
399  /** Direct update of the map with a reading in a given position of the map,
400  * using
401  * the appropriate method according to mapType passed in the constructor.
402  *
403  * This is a direct way to update the map, an alternative to the generic
404  * insertObservation() method which works with mrpt::obs::CObservation
405  * objects.
406  */
408  /** [in] The value observed in the (x,y) position */
409  const double sensorReading,
410  /** [in] The (x,y) location */
411  const mrpt::math::TPoint2D& point,
412  /** [in] Run a global map update after inserting this observatin
413  (algorithm-dependant) */
414  const bool update_map = true,
415  /** [in] Whether the observation "vanishes" with time (false) or not
416  (true) [Only for GMRF methods] */
417  const bool time_invariant = true,
418  /** [in] The uncertainty (standard deviation) of the reading.
419  Default="0.0" means use the default settings per map-wide parameters.
420  */
421  const double reading_stddev = .0);
422 
424  {
427  };
428 
429  /** Returns the prediction of the measurement at some (x,y) coordinates, and
430  * its certainty (in the form of the expected variance). */
431  virtual void predictMeasurement(
432  /** [in] Query X coordinate */
433  const double x,
434  /** [in] Query Y coordinate */
435  const double y,
436  /** [out] The output value */
437  double& out_predict_response,
438  /** [out] The output variance */
439  double& out_predict_response_variance,
440  /** [in] Whether to renormalize the prediction to a predefined
441  interval (`R` values in insertionOptions) */
442  bool do_sensor_normalization,
443  /** [in] Interpolation method */
444  const TGridInterpolationMethod interp_method = gimNearest);
445 
446  /** Return the mean and covariance vector of the full Kalman filter estimate
447  * (works for all KF-based methods). */
448  void getMeanAndCov(
449  mrpt::math::CVectorDouble& out_means,
450  mrpt::math::CMatrixDouble& out_cov) const;
451 
452  /** Return the mean and STD vectors of the full Kalman filter estimate
453  * (works for all KF-based methods). */
454  void getMeanAndSTD(
455  mrpt::math::CVectorDouble& out_means,
456  mrpt::math::CVectorDouble& out_STD) const;
457 
458  /** Load the mean and STD vectors of the full Kalman filter estimate (works
459  * for all KF-based methods). */
460  void setMeanAndSTD(
461  mrpt::math::CVectorDouble& out_means,
462  mrpt::math::CVectorDouble& out_STD);
463 
464  /** Run the method-specific procedure required to ensure that the mean &
465  * variances are up-to-date with all inserted observations. */
466  void updateMapEstimation();
467 
468  void enableVerbose(bool enable_verbose)
469  {
471  }
472  bool isEnabledVerbose() const
473  {
475  }
476 
477  void enableProfiler(bool enable = true)
478  {
479  this->m_gmrf.enableProfiler(enable);
480  }
481  bool isProfilerEnabled() const { return this->m_gmrf.isProfilerEnabled(); }
482 
483  protected:
485 
486  /** Common options to all random-field grid maps: pointer that is set to the
487  * derived-class instance of "insertOptions" upon construction of this
488  * class. */
490 
491  /** Get the part of the options common to all CRandomFieldGridMap2D classes
492  */
495 
496  /** The map representation type of this map, as passed in the constructor */
498 
499  /** The whole covariance matrix, used for the Kalman Filter map
500  * representation. */
502 
503  /** The compressed band diagonal matrix for the KF2 implementation.
504  * The format is a Nx(W^2+2W+1) matrix, one row per cell in the grid map
505  * with the
506  * cross-covariances between each cell and half of the window around it
507  * in the grid.
508  */
510  /** Only for the KF2 implementation. */
511  mutable bool m_hasToRecoverMeanAndCov{true};
512 
513  /** @name Auxiliary vars for DM & DM+V methods
514  @{ */
515  float m_DM_lastCutOff{0};
516  std::vector<float> m_DM_gaussWindow;
519  /** @} */
520 
521  /** Empty: default */
523 
525 
528  {
529  /** Observation value */
530  double obsValue;
531  /** "Information" of the observation (=inverse of the variance) */
532  double Lambda;
533  /** whether the observation will lose weight (lambda) as time goes on
534  * (default false) */
536 
537  double evaluateResidual() const override;
538  double getInformation() const override;
539  void evalJacobian(double& dr_dx) const override;
540 
542  : obsValue(.0), Lambda(.0), time_invariant(false), m_parent(&parent)
543  {
544  }
545 
546  private:
548  };
549 
552  {
553  /** "Information" of the observation (=inverse of the variance) */
554  double Lambda;
555 
556  double evaluateResidual() const override;
557  double getInformation() const override;
558  void evalJacobian(double& dr_dx_i, double& dr_dx_j) const override;
559 
561  : Lambda(.0), m_parent(&parent)
562  {
563  }
564 
565  private:
567  };
568 
569  // Important: converted to a std::list<> so pointers are NOT invalidated
570  // upon deletion.
571  /** Vector with the active observations and their respective Information */
572  std::vector<std::list<TObservationGMRF>> m_mrf_factors_activeObs;
573  /** Vector with the precomputed priors for each GMRF model */
574  std::deque<TPriorFactorGMRF> m_mrf_factors_priors;
575 
576  /** The implementation of "insertObservation" for Achim Lilienthal's map
577  * models DM & DM+V.
578  * \param normReading Is a [0,1] normalized concentration reading.
579  * \param point Is the sensor location on the map
580  * \param is_DMV = false -> map type is Kernel DM; true -> map type is DM+V
581  */
583  double normReading, const mrpt::math::TPoint2D& point, bool is_DMV);
584 
585  /** The implementation of "insertObservation" for the (whole) Kalman Filter
586  * map model.
587  * \param normReading Is a [0,1] normalized concentration reading.
588  * \param point Is the sensor location on the map
589  */
591  double normReading, const mrpt::math::TPoint2D& point);
592 
593  /** The implementation of "insertObservation" for the Efficient Kalman
594  * Filter map model.
595  * \param normReading Is a [0,1] normalized concentration reading.
596  * \param point Is the sensor location on the map
597  */
599  double normReading, const mrpt::math::TPoint2D& point);
600 
601  /** The implementation of "insertObservation" for the Gaussian Markov Random
602  * Field map model.
603  * \param normReading Is a [0,1] normalized concentration reading.
604  * \param point Is the sensor location on the map
605  */
607  double normReading, const mrpt::math::TPoint2D& point,
608  const bool update_map, const bool time_invariant,
609  const double reading_information);
610 
611  /** solves the minimum quadratic system to determine the new concentration
612  * of each cell */
614 
615  /** Computes the confidence of the cell concentration (alpha) */
617  const TRandomFieldCell* cell) const;
618 
619  /** Computes the average cell concentration, or the overall average value if
620  * it has never been observed */
621  double computeMeanCellValue_DM_DMV(const TRandomFieldCell* cell) const;
622 
623  /** Computes the estimated variance of the cell concentration, or the
624  * overall average variance if it has never been observed */
625  double computeVarCellValue_DM_DMV(const TRandomFieldCell* cell) const;
626 
627  /** In the KF2 implementation, takes the auxiliary matrices and from them
628  * update the cells' mean and std values.
629  * \sa m_hasToRecoverMeanAndCov
630  */
631  void recoverMeanAndCov() const;
632 
633  /** Erase all the contents of the map */
634  void internal_clear() override;
635 
636  /** Check if two cells of the gridmap (m_map) are connected, based on the
637  * provided occupancy gridmap*/
639  const mrpt::maps::COccupancyGridMap2D* m_Ocgridmap, size_t cxo_min,
640  size_t cxo_max, size_t cyo_min, size_t cyo_max, const size_t seed_cxo,
641  const size_t seed_cyo, const size_t objective_cxo,
642  const size_t objective_cyo);
643 };
644 
645 } // namespace mrpt::maps
void clear()
Erase all the contents of the map.
Definition: CMetricMap.cpp:30
Simple, scalar (1-dim) constraint (edge) for a GMRF.
std::string GMRF_gridmap_image_file
image name of the occupancy_gridmap
Gaussian kernel-based estimator (see discussion in mrpt::maps::CRandomFieldGridMap2D) ...
Parameters for CMetricMap::compute3DMatchingRatio()
float sigma
The sigma of the "Parzen"-kernel Gaussian.
void getMeanAndSTD(mrpt::math::CVectorDouble &out_means, mrpt::math::CVectorDouble &out_STD) const
Return the mean and STD vectors of the full Kalman filter estimate (works for all KF-based methods)...
A 2D grid of dynamic size which stores any kind of data at each cell.
Definition: CDynamicGrid.h:38
void clear()
Calls the base CMetricMap::clear Declared here to avoid ambiguity between the two clear() in both bas...
double evaluateResidual() const override
Return the residual/error of this observation.
This class is a "CSerializable" wrapper for "CMatrixDynamic<double>".
Definition: CMatrixD.h:23
unsigned __int16 uint16_t
Definition: rptypes.h:47
virtual void saveAsMatlab3DGraph(const std::string &filName) const
Save a matlab ".m" file which represents as 3D surfaces the mean and a given confidence level for the...
float KF_defaultCellMeanValue
The default value for the mean of cells&#39; concentration.
double getInformation() const override
Return the inverse of the variance of this constraint.
bool exist_relation_between2cells(const mrpt::maps::COccupancyGridMap2D *m_Ocgridmap, size_t cxo_min, size_t cxo_max, size_t cyo_min, size_t cyo_max, const size_t seed_cxo, const size_t seed_cyo, const size_t objective_cxo, const size_t objective_cyo)
Check if two cells of the gridmap (m_map) are connected, based on the provided occupancy gridmap...
Base class for user-supplied objects capable of describing cells connectivity, used to build prior fa...
void insertObservation_GMRF(double normReading, const mrpt::math::TPoint2D &point, const bool update_map, const bool time_invariant, const double reading_information)
The implementation of "insertObservation" for the Gaussian Markov Random Field map model...
void evalJacobian(double &dr_dx_i, double &dr_dx_j) const override
Returns the derivative of the residual wrt the node values.
std::vector< std::list< TObservationGMRF > > m_mrf_factors_activeObs
Vector with the active observations and their respective Information.
mrpt::math::CMatrixD m_cov
The whole covariance matrix, used for the Kalman Filter map representation.
void setMinLoggingLevel(const VerbosityLevel level)
Set the minimum logging level for which the incoming logs are going to be taken into account...
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:86
double Lambda
"Information" of the observation (=inverse of the variance)
mrpt::system::TTimeStamp last_updated
[Dynamic maps only] The timestamp of the last time the cell was updated
Double mean + variance Gaussian kernel-based estimator (see discussion in mrpt::maps::CRandomFieldGri...
TMapRepresentation
The type of map representation to be used, see CRandomFieldGridMap2D for a discussion.
void getMeanAndCov(mrpt::math::CVectorDouble &out_means, mrpt::math::CMatrixDouble &out_cov) const
Return the mean and covariance vector of the full Kalman filter estimate (works for all KF-based meth...
double gmrf_mean
[GMRF only] The mean value of this cell
double GMRF_lambdaPrior
The information (Lambda) of fixed map constraints.
float cutoffRadius
The cutoff radius for updating cells.
void enableVerbose(bool enable_verbose)
Another alias for "mrKernelDM", for backwards compatibility (see discussion in mrpt::maps::CRandomFie...
TMapRepresentation getMapType()
Return the type of the random-field grid map, according to parameters passed on construction.
void enableProfiler(bool enable=true)
void evalJacobian(double &dr_dx) const override
Returns the derivative of the residual wrt the node value.
void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr &outObj) const override
Returns a 3D object representing the map (mean)
double computeMeanCellValue_DM_DMV(const TRandomFieldCell *cell) const
Computes the average cell concentration, or the overall average value if it has never been observed...
virtual bool getEdgeInformation(const CRandomFieldGridMap2D *parent, size_t icx, size_t icy, size_t jcx, size_t jcy, double &out_edge_information)=0
Implement the check of whether node i=(icx,icy) is connected with node j=(jcx,jcy).
void recoverMeanAndCov() const
In the KF2 implementation, takes the auxiliary matrices and from them update the cells&#39; mean and std ...
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
void internal_dumpToTextStream_common(std::ostream &out) const
See utils::CLoadableOptions.
TMapRepresentation m_mapType
The map representation type of this map, as passed in the constructor.
mrpt::graphs::ScalarFactorGraph m_gmrf
CRandomFieldGridMap2D(TMapRepresentation mapType=mrKernelDM, double x_min=-2, double x_max=2, double y_min=-2, double y_max=2, double resolution=0.1)
Constructor.
double dm_mean_w
[Kernel-methods only] The cumulative weights (concentration = alpha
double getInformation() const override
Return the inverse of the variance of this constraint.
float KF_observationModelNoise
The sensor model noise (in normalized concentration units).
~CRandomFieldGridMap2D() override
Destructor.
VerbosityLevel getMinLoggingLevel() const
TInsertionOptionsCommon * m_insertOptions_common
Common options to all random-field grid maps: pointer that is set to the derived-class instance of "i...
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:40
bool time_invariant
whether the observation will lose weight (lambda) as time goes on (default false) ...
float R_min
Limits for normalization of sensor readings.
virtual void saveAsBitmapFile(const std::string &filName) const
Save the current map as a graphical file (BMP,PNG,...).
TRandomFieldCell(double kfmean_dm_mean=1e-20, double kfstd_dmmeanw=0)
Constructor.
This class allows loading and storing values and vectors of different types from a configuration text...
bool isEmpty() const override
Returns true if the map is empty/no observation has been inserted (in this class it always return fal...
void resize(double new_x_min, double new_x_max, double new_y_min, double new_y_max, const TRandomFieldCell &defaultValueNewCells, double additionalMarginMeters=1.0f) override
Changes the size of the grid, maintaining previous contents.
void updateMapEstimation_GMRF()
solves the minimum quadratic system to determine the new concentration of each cell ...
double kf_mean
[KF-methods only] The mean value of this cell
The contents of each cell in a CRandomFieldGridMap2D map.
void setMeanAndSTD(mrpt::math::CVectorDouble &out_means, mrpt::math::CVectorDouble &out_STD)
Load the mean and STD vectors of the full Kalman filter estimate (works for all KF-based methods)...
const GLubyte * c
Definition: glext.h:6406
Versatile class for consistent logging and management of output messages.
"Brute-force" Kalman filter (see discussion in mrpt::maps::CRandomFieldGridMap2D) ...
virtual void setSize(const double x_min, const double x_max, const double y_min, const double y_max, const double resolution, const TRandomFieldCell *fill_value=nullptr)
Changes the size of the grid, erasing previous contents.
void insertObservation_KernelDM_DMV(double normReading, const mrpt::math::TPoint2D &point, bool is_DMV)
The implementation of "insertObservation" for Achim Lilienthal&#39;s map models DM & DM+V.
float cell2float(const TRandomFieldCell &c) const override
double GMRF_lambdaObs
The initial information (Lambda) of each observation (this information will decrease with time) ...
double dm_sigma_omega
[DM/DM+V methods] The scaling parameter for the confidence "alpha" values (see the IROS 2009 paper; s...
#define MRPT_ENUM_TYPE_END()
Definition: TEnumType.h:78
void insertObservation_KF(double normReading, const mrpt::math::TPoint2D &point)
The implementation of "insertObservation" for the (whole) Kalman Filter map model.
virtual void getAsBitmapFile(mrpt::img::CImage &out_img) const
Returns an image just as described in saveAsBitmapFile.
ConnectivityDescriptor::Ptr m_gmrf_connectivity
Empty: default.
GLsizei const GLchar ** string
Definition: glext.h:4116
(see discussion in mrpt::maps::CRandomFieldGridMap2D)
void internal_loadFromConfigFile_common(const mrpt::config::CConfigFileBase &source, const std::string &section)
See utils::CLoadableOptions.
bool m_hasToRecoverMeanAndCov
Only for the KF2 implementation.
void setCellsConnectivity(const ConnectivityDescriptor::Ptr &new_connectivity_descriptor)
Sets a custom object to define the connectivity between cells.
double updated_std
[Dynamic maps only] The std cell value that was updated (to be used in the Forgetting_curve ...
double GMRF_saturate_min
(Default:-inf,+inf) Saturate the estimated mean in these limits
A class for storing an occupancy grid map.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
CRandomFieldGridMap2D represents a 2D grid map where each cell is associated one real-valued property...
Gaussian Markov Random Field, squared differences prior weights between 4 neighboring cells (see disc...
float KF_covSigma
The "sigma" for the initial covariance value between cells (in meters).
Declares a virtual base class for all metric maps storage classes.
Definition: CMetricMap.h:52
bool GMRF_skip_variance
(Default:false) Skip the computation of the variance, just compute the mean
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:84
void updateMapEstimation()
Run the method-specific procedure required to ensure that the mean & variances are up-to-date with al...
void saveMetricMapRepresentationToFile(const std::string &filNamePrefix) const override
The implementation in this class just calls all the corresponding method of the contained metric maps...
void internal_clear() override
Erase all the contents of the map.
double dmv_var_mean
[Kernel DM-V only] The cumulative weighted variance of this cell
bool GMRF_use_occupancy_information
whether to use information of an occupancy_gridmap map for building the GMRF
std::string GMRF_simplemap_file
simplemap_file name of the occupancy_gridmap
uint16_t KF_W_size
[mrKalmanApproximate] The size of the window of neighbor cells.
GLsizei GLsizei GLchar * source
Definition: glext.h:4097
GLenum GLint GLint y
Definition: glext.h:3542
MRPT_FILL_ENUM_MEMBER(mrpt::maps::CRandomFieldGridMap2D::TMapRepresentation, mrKernelDM)
double computeConfidenceCellValue_DM_DMV(const TRandomFieldCell *cell) const
Computes the confidence of the cell concentration (alpha)
virtual void predictMeasurement(const double x, const double y, double &out_predict_response, double &out_predict_response_variance, bool do_sensor_normalization, const TGridInterpolationMethod interp_method=gimNearest)
Returns the prediction of the measurement at some (x,y) coordinates, and its certainty (in the form o...
mrpt::math::CMatrixD m_stackedCov
The compressed band diagonal matrix for the KF2 implementation.
virtual CRandomFieldGridMap2D::TInsertionOptionsCommon * getCommonInsertOptions()=0
Get the part of the options common to all CRandomFieldGridMap2D classes.
double evaluateResidual() const override
Return the residual/error of this observation.
double Lambda
"Information" of the observation (=inverse of the variance)
Simple, scalar (1-dim) constraint (edge) for a GMRF.
double dm_mean
[Kernel-methods only] The cumulative weighted readings of this cell
size_t GMRF_gridmap_image_cx
Pixel coordinates of the origin for the occupancy_gridmap.
std::deque< TPriorFactorGMRF > m_mrf_factors_priors
Vector with the precomputed priors for each GMRF model.
GLenum GLint x
Definition: glext.h:3542
double computeVarCellValue_DM_DMV(const TRandomFieldCell *cell) const
Computes the estimated variance of the cell concentration, or the overall average variance if it has ...
#define MRPT_ENUM_TYPE_BEGIN(_ENUM_TYPE_WITH_NS)
Definition: TEnumType.h:62
Lightweight 2D point.
Definition: TPoint2D.h:31
void insertObservation_KF2(double normReading, const mrpt::math::TPoint2D &point)
The implementation of "insertObservation" for the Efficient Kalman Filter map model.
double GMRF_gridmap_image_res
occupancy_gridmap resolution: size of each pixel (m)
GLenum const GLfloat * params
Definition: glext.h:3538
float KF_initialCellStd
The initial standard deviation of each cell&#39;s concentration (will be stored both at each cell&#39;s struc...
size_t GMRF_gridmap_image_cy
Pixel coordinates of the origin for the occupancy_gridmap.
virtual void getAsMatrix(mrpt::math::CMatrixDouble &out_mat) const
Like saveAsBitmapFile(), but returns the data in matrix form (first row in the matrix is the upper (y...
double kf_std
[KF-methods only] The standard deviation value of this cell
double GMRF_lambdaObsLoss
The loss of information of the observations with each iteration.
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:147
void getAsMatlab3DGraphScript(std::string &out_script) const
Return a large text block with a MATLAB script to plot the contents of this map.
void insertIndividualReading(const double sensorReading, const mrpt::math::TPoint2D &point, const bool update_map=true, const bool time_invariant=true, const double reading_stddev=.0)
Direct update of the map with a reading in a given position of the map, using the appropriate method ...
float compute3DMatchingRatio(const mrpt::maps::CMetricMap *otherMap, const mrpt::poses::CPose3D &otherMapPose, const TMatchingRatioParams &params) const override
See docs in base class: in this class this always returns 0.
Sparse solver for GMRF (Gaussian Markov Random Fields) graphical models.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c26d46ba6 Thu Jul 18 13:03:42 2019 +0200 at jue jul 18 13:10:17 CEST 2019