10 #ifndef CLogOddsGridMap2D_H 11 #define CLogOddsGridMap2D_H 27 static const int8_t CELLTYPE_MIN = -127;
28 static const int8_t CELLTYPE_MAX = 127;
29 static const int8_t P2LTABLE_SIZE = CELLTYPE_MAX;
30 static const size_t LOGODDS_LUT_ENTRIES = 1<<8;
34 static const int16_t CELLTYPE_MIN = -32767;
35 static const int16_t CELLTYPE_MAX = 32767;
36 static const int16_t P2LTABLE_SIZE = CELLTYPE_MAX;
37 static const size_t LOGODDS_LUT_ENTRIES = 1<<16;
49 template <
typename TCELL>
69 const unsigned _size_x)
71 cell_t *theCell = mapArray + (
x+
y*_size_x);
72 if (*theCell > thres )
73 *theCell -= logodd_obs;
74 else *theCell = traits_t::CELLTYPE_MIN;
89 if (*theCell > thres )
90 *theCell -= logodd_obs;
91 else *theCell = traits_t::CELLTYPE_MIN;
108 const unsigned _size_x)
110 cell_t *theCell = mapArray + (
x+
y*_size_x);
111 if (*theCell < thres )
112 *theCell += logodd_obs;
113 else *theCell = traits_t::CELLTYPE_MAX;
129 if (*theCell < thres )
130 *theCell += logodd_obs;
131 else *theCell = traits_t::CELLTYPE_MAX;
144 template <
typename TCELL>
166 static const double LOGODD_K = 16;
167 static const double LOGODD_K_INV = 1.0/LOGODD_K;
171 for (
int i=traits_t::CELLTYPE_MIN;i<=traits_t::CELLTYPE_MAX;i++)
173 float f = 1.0f / (1.0f + exp( - i * LOGODD_K_INV ) );
174 unsigned int idx = -traits_t::CELLTYPE_MIN+i;
180 p2lTable.resize( traits_t::P2LTABLE_SIZE+1 );
181 double K = 1.0 / traits_t::P2LTABLE_SIZE;
182 for (
int j=0;j<=traits_t::P2LTABLE_SIZE;j++)
190 double logodd = log(
p)-log(1-
p);
191 int L =
round(logodd * LOGODD_K);
192 if (L>traits_t::CELLTYPE_MAX)
193 L=traits_t::CELLTYPE_MAX;
194 else if (L<traits_t::CELLTYPE_MIN)
195 L=traits_t::CELLTYPE_MIN;
204 if (l<traits_t::CELLTYPE_MIN)
213 if (l<traits_t::CELLTYPE_MIN)
222 return p2lTable[
static_cast<unsigned int>(
p * traits_t::P2LTABLE_SIZE) ];
TCELL cell_t
The type of cells.
std::vector< uint8_t > logoddsTable_255
A lookup table to compute occupancy probabilities in the range [0,255] from integer log-odds values i...
cell_t p2l(const float p)
Scales a real valued probability in [0,1] to an integer representation of: log(p)-log(1-p) in the val...
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...
detail::logoddscell_traits< TCELL > traits_t
CLogOddsGridMapLUT()
Constructor: computes all the required stuff.
std::vector< cell_t > p2lTable
A lookup table for passing from float to log-odds as cell_t.
detail::logoddscell_traits< TCELL > traits_t
std::vector< float > logoddsTable
A lookup table to compute occupancy probabilities in [0,1] from integer log-odds values in the cells...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
uint8_t l2p_255(const cell_t l)
Scales an integer representation of the log-odd into a linear scale [0,255], using p=exp(l)/(1+exp(l)...
int round(const T value)
Returns the closer integer (int) to x.
A generic provider of log-odds grid-map maintainance functions.
float l2p(const cell_t l)
Scales an integer representation of the log-odd into a real valued probability in [0...
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...
One static instance of this struct should exist in any class implementing CLogOddsGridMap2D to hold t...
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...