MRPT  1.9.9
CLogOddsGridMap3D.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 
16 namespace mrpt::maps
17 {
18 /** A generic provider of log-odds grid-map maintainance functions.
19  * Map cells must be type TCELL, which can be only:
20  * - int8_t or
21  * - int16_t
22  *
23  * \sa CLogOddsGridMapLUT, See derived classes for usage examples.
24  * \ingroup mrpt_maps_grp
25  */
26 template <typename TCELL>
28 {
29  /** The type of cells */
30  using cell_t = TCELL;
33 
34  /** The actual 3D voxels container */
36 
37  /** Performs Bayesian fusion of a new observation of a cell.
38  * This method increases the "occupancy-ness" of a cell, managing possible
39  * saturation.
40  * \param theCell The cell to modify
41  * \param logodd_obs Observation of the cell, in log-odd form as
42  * transformed by p2l.
43  * \param thres This must be CELLTYPE_MIN+logodd_obs
44  * \sa updateCell, updateCell_fast_free
45  */
46  inline static void updateCell_fast_occupied(
47  cell_t* theCell, const cell_t logodd_obs, const cell_t thres)
48  {
49  if (theCell == nullptr) return;
50  if (*theCell > thres)
51  *theCell -= logodd_obs;
52  else
53  *theCell = traits_t::CELLTYPE_MIN;
54  }
55 
56  /** Performs Bayesian fusion of a new observation of a cell.
57  * This method increases the "occupancy-ness" of a cell, managing possible
58  * saturation.
59  * \param x Cell index in X axis.
60  * \param y Cell index in Y axis.
61  * \param z Cell index in Z axis.
62  * \param logodd_obs Observation of the cell, in log-odd form as
63  * transformed by p2l.
64  * \param thres This must be CELLTYPE_MIN+logodd_obs
65  * \sa updateCell, updateCell_fast_free
66  */
68  const unsigned x, const unsigned y, const unsigned z,
69  const cell_t logodd_obs, const cell_t thres)
70  {
72  m_grid.cellByIndex(x, y, z), logodd_obs, thres);
73  }
74 
75  /** Performs Bayesian fusion of a new observation of a cell.
76  * This method increases the "free-ness" of a cell, managing possible
77  * saturation.
78  * \param logodd_obs Observation of the cell, in log-odd form as
79  * transformed by p2l.
80  * \param thres This must be CELLTYPE_MAX-logodd_obs
81  * \sa updateCell_fast_occupied
82  */
83  inline static void updateCell_fast_free(
84  cell_t* theCell, const cell_t logodd_obs, const cell_t thres)
85  {
86  if (theCell == nullptr) return;
87  if (*theCell < thres)
88  *theCell += logodd_obs;
89  else
90  *theCell = traits_t::CELLTYPE_MAX;
91  }
92 
93  /** Performs the Bayesian fusion of a new observation of a cell.
94  * This method increases the "free-ness" of a cell, managing possible
95  * saturation.
96  * \param x Cell index in X axis.
97  * \param y Cell index in Y axis.
98  * \param z Cell index in Z axis.
99  * \param logodd_obs Observation of the cell, in log-odd form as
100  * transformed by p2l.
101  * \param thres This must be CELLTYPE_MAX-logodd_obs
102  * \sa updateCell_fast_occupied
103  */
104  inline void updateCell_fast_free(
105  const unsigned x, const unsigned y, const unsigned z,
106  const cell_t logodd_obs, const cell_t thres)
107  {
108  updateCell_fast_free(m_grid.cellByIndex(x, y, z), logodd_obs, thres);
109  }
110 };
111 
112 } // namespace mrpt::maps
void updateCell_fast_free(const unsigned x, const unsigned y, const unsigned z, const cell_t logodd_obs, const cell_t thres)
Performs the Bayesian fusion of a new observation of a cell.
GLdouble GLdouble z
Definition: glext.h:3879
void updateCell_fast_occupied(const unsigned x, const unsigned y, const unsigned z, const cell_t logodd_obs, const cell_t thres)
Performs Bayesian fusion of a new observation of a cell.
static void updateCell_fast_occupied(cell_t *theCell, const cell_t logodd_obs, const cell_t thres)
Performs Bayesian fusion of a new observation of a cell.
OccGridCellTraits::cellType cell_t
The type of cells.
T * cellByIndex(unsigned int cx, unsigned int cy, unsigned int cz)
Returns a pointer to the contents of a voxel given by its voxel indexes, or nullptr if it is out of t...
GLenum GLint GLint y
Definition: glext.h:3542
A generic provider of log-odds grid-map maintainance functions.
grid_t m_grid
The actual 3D voxels container.
static void updateCell_fast_free(cell_t *theCell, const cell_t logodd_obs, const cell_t thres)
Performs Bayesian fusion of a new observation of a cell.
GLenum GLint x
Definition: glext.h:3542



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019