MRPT  2.0.0
CLogOddsGridMap2D.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-2020, 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 
14 
15 namespace mrpt::maps
16 {
17 /** A generic provider of log-odds grid-map maintainance functions.
18  * Map cells must be type TCELL, which can be only:
19  * - int8_t or
20  * - int16_t
21  *
22  * \sa CLogOddsGridMapLUT, See derived classes for usage examples.
23  * \ingroup mrpt_maps_grp
24  */
25 template <typename TCELL>
27 {
28  /** The type of cells */
29  using cell_t = TCELL;
31 
32  /** Performs the Bayesian fusion of a new observation of a cell, without
33  * checking for grid limits nor updateInfoChangeOnly.
34  * This method increases the "occupancy-ness" of a cell, managing possible
35  * saturation.
36  * \param x Cell index in X axis.
37  * \param y Cell index in Y axis.
38  * \param logodd_obs Observation of the cell, in log-odd form as
39  * transformed by p2l.
40  * \param thres This must be CELLTYPE_MIN+logodd_obs
41  * \sa updateCell, updateCell_fast_free
42  */
43  inline static void updateCell_fast_occupied(
44  const unsigned x, const unsigned y, const cell_t logodd_obs,
45  const cell_t thres, cell_t* mapArray, const unsigned _size_x)
46  {
47  cell_t* theCell = mapArray + (x + y * _size_x);
48  if (*theCell > thres)
49  *theCell -= logodd_obs;
50  else
51  *theCell = traits_t::CELLTYPE_MIN;
52  }
53 
54  /** Performs the Bayesian fusion of a new observation of a cell, without
55  * checking for grid limits nor updateInfoChangeOnly.
56  * This method increases the "occupancy-ness" of a cell, managing possible
57  * saturation.
58  * \param theCell The cell to modify
59  * \param logodd_obs Observation of the cell, in log-odd form as
60  * transformed by p2l.
61  * \param thres This must be CELLTYPE_MIN+logodd_obs
62  * \sa updateCell, updateCell_fast_free
63  */
64  inline static void updateCell_fast_occupied(
65  cell_t* theCell, const cell_t logodd_obs, const cell_t thres)
66  {
67  if (*theCell > thres)
68  *theCell -= logodd_obs;
69  else
70  *theCell = traits_t::CELLTYPE_MIN;
71  }
72 
73  /** Performs the Bayesian fusion of a new observation of a cell, without
74  * checking for grid limits nor updateInfoChangeOnly.
75  * This method increases the "free-ness" of a cell, managing possible
76  * saturation.
77  * \param x Cell index in X axis.
78  * \param y Cell index in Y axis.
79  * \param logodd_obs Observation of the cell, in log-odd form as
80  * transformed by p2l.
81  * \param thres This must be CELLTYPE_MAX-logodd_obs
82  * \sa updateCell_fast_occupied
83  */
84  inline static void updateCell_fast_free(
85  const unsigned x, const unsigned y, const cell_t logodd_obs,
86  const cell_t thres, cell_t* mapArray, const unsigned _size_x)
87  {
88  cell_t* theCell = mapArray + (x + y * _size_x);
89  if (*theCell < thres)
90  *theCell += logodd_obs;
91  else
92  *theCell = traits_t::CELLTYPE_MAX;
93  }
94 
95  /** Performs the Bayesian fusion of a new observation of a cell, without
96  * checking for grid limits nor updateInfoChangeOnly.
97  * This method increases the "free-ness" of a cell, managing possible
98  * saturation.
99  * \param x Cell index in X axis.
100  * \param y Cell index in Y axis.
101  * \param logodd_obs Observation of the cell, in log-odd form as
102  * transformed by p2l.
103  * \param thres This must be CELLTYPE_MAX-logodd_obs
104  * \sa updateCell_fast_occupied
105  */
106  inline static void updateCell_fast_free(
107  cell_t* theCell, const cell_t logodd_obs, const cell_t thres)
108  {
109  if (*theCell < thres)
110  *theCell += logodd_obs;
111  else
112  *theCell = traits_t::CELLTYPE_MAX;
113  }
114 
115 }; // end of CLogOddsGridMap2D
116 
117 } // namespace mrpt::maps
OccGridCellTraits::cellType cell_t
The type of cells.
static void updateCell_fast_free(const unsigned x, const unsigned y, const cell_t logodd_obs, const cell_t thres, cell_t *mapArray, const unsigned _size_x)
Performs the Bayesian fusion of a new observation of a cell, without checking for grid limits nor upd...
A generic provider of log-odds grid-map maintainance functions.
static void updateCell_fast_free(cell_t *theCell, const cell_t logodd_obs, const cell_t thres)
Performs the Bayesian fusion of a new observation of a cell, without checking for grid limits nor upd...
static void updateCell_fast_occupied(cell_t *theCell, const cell_t logodd_obs, const cell_t thres)
Performs the Bayesian fusion of a new observation of a cell, without checking for grid limits nor upd...
static void updateCell_fast_occupied(const unsigned x, const unsigned y, const cell_t logodd_obs, const cell_t thres, cell_t *mapArray, const unsigned _size_x)
Performs the Bayesian fusion of a new observation of a cell, without checking for grid limits nor upd...



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020