10#ifndef CRandomFieldGridMap2D_H
11#define CRandomFieldGridMap2D_H
23#if EIGEN_VERSION_AT_LEAST(3,1,0)
24 #include <Eigen/SparseCore>
25 #include <Eigen/SparseCholesky>
35#if defined(MRPT_IS_X86_AMD64)
46 kf_mean (kfmean_dm_mean),
47 kf_std (kfstd_dmmeanw),
49 last_updated(
mrpt::system::
now()),
50 updated_std (kfstd_dmmeanw)
81#if defined(MRPT_IS_X86_AMD64)
149 double x_min = -2,
double x_max = 2,
150 double y_min = -2,
double y_max = 2,
151 double resolution = 0.1
190 const std::string §ion);
232 virtual 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 )
MRPT_OVERRIDE;
235 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 = NULL);
256 virtual
void getAs3DObject (
mrpt::opengl::CSetOfObjectsPtr &meanObj,
mrpt::opengl::CSetOfObjectsPtr &varObj ) const;
266 const
double sensorReading,
267 const
mrpt::math::TPoint2D & point,
268 const
bool update_map = true,
269 const
bool time_invariant = true
281 double &out_predict_response,
282 double &out_predict_response_variance,
283 bool do_sensor_normalization,
332#if EIGEN_VERSION_AT_LEAST(3,1,0)
333 std::vector<Eigen::Triplet<double> > H_prior;
414 const
size_t seed_cxo,
415 const
size_t seed_cyo,
416 const
size_t objective_cxo,
417 const
size_t objective_cyo);
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
Declares a virtual base class for all metric maps storage classes.
void clear()
Erase all the contents of the map.
A class for storing an occupancy grid map.
CRandomFieldGridMap2D represents a 2D grid map where each cell is associated one real-valued property...
virtual 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) MRPT_OVERRIDE
Changes the size of the grid, maintaining previous contents.
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...
void updateMapEstimation()
Run the method-specific procedure required to ensure that the mean & variances are up-to-date with al...
virtual bool isEmpty() const MRPT_OVERRIDE
Returns true if the map is empty/no observation has been inserted (in this class it always return fal...
void enableVerbose(bool enable_verbose)
double m_average_normreadings_mean
bool m_rfgm_verbose
Enable verbose debug output for Random Field grid map operations (Default: false)
std::vector< std::vector< TobservationGMRF > > activeObs
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 computeMeanCellValue_DM_DMV(const TRandomFieldCell *cell) const
Computes the average cell concentration, or the overall average value if it has never been observed
void insertObservation_KernelDM_DMV(double normReading, const mrpt::math::TPoint2D &point, bool is_DMV)
The implementation of "insertObservation" for Achim Lilienthal's map models DM & DM+V.
void insertIndividualReading(const double sensorReading, const mrpt::math::TPoint2D &point, const bool update_map=true, const bool time_invariant=true)
Direct update of the map with a reading in a given position of the map, using the appropriate method ...
std::multimap< size_t, size_t > cell_interconnections
virtual void saveAsBitmapFile(const std::string &filName) const
Save the current map as a graphical file (BMP,PNG,...).
mrpt::math::CMatrixD m_stackedCov
The compressed band diagonal matrix for the KF2 implementation.
float cell2float(const TRandomFieldCell &c) const MRPT_OVERRIDE
virtual ~CRandomFieldGridMap2D()
Destructor.
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.
virtual CRandomFieldGridMap2D::TInsertionOptionsCommon * getCommonInsertOptions()=0
Get the part of the options common to all CRandomFieldGridMap2D classes.
TMapRepresentation
The type of map representation to be used, see CRandomFieldGridMap2D for a discussion.
@ mrKalmanApproximate
(see discussion in mrpt::maps::CRandomFieldGridMap2D)
@ mrGMRF_SD
Gaussian Markov Random Field, squared differences prior weights between 4 neighboring cells (see disc...
@ mrKernelDMV
Double mean + variance Gaussian kernel-based estimator (see discussion in mrpt::maps::CRandomFieldGri...
@ mrAchim
Another alias for "mrKernelDM", for backwards compatibility (see discussion in mrpt::maps::CRandomFie...
@ mrGMRF_G
Gaussian Markov Random Field, Gaussian prior weights between neighboring cells up to a certain distan...
@ mrKalmanFilter
"Brute-force" Kalman filter (see discussion in mrpt::maps::CRandomFieldGridMap2D)
@ mrKernelDM
Gaussian kernel-based estimator (see discussion in mrpt::maps::CRandomFieldGridMap2D)
virtual void getAs3DObject(mrpt::opengl::CSetOfObjectsPtr &outObj) const MRPT_OVERRIDE
Returns a 3D object representing the map (mean)
size_t m_average_normreadings_count
void clear()
Calls the base CMetricMap::clear Declared here to avoid ambiguity between the two clear() in both bas...
virtual void getAsBitmapFile(mrpt::utils::CImage &out_img) const
Returns an image just as described in saveAsBitmapFile.
void getAsMatlab3DGraphScript(std::string &out_script) const
Return a large text block with a MATLAB script to plot the contents of this map.
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_cov
The whole covariance matrix, used for the Kalman Filter map representation.
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=NULL)
Changes the size of the grid, erasing previous contents.
virtual void saveMetricMapRepresentationToFile(const std::string &filNamePrefix) const MRPT_OVERRIDE
The implementation in this class just calls all the corresponding method of the contained metric maps...
void recoverMeanAndCov() const
In the KF2 implementation, takes the auxiliary matrices and from them update the cells' mean and std ...
void insertObservation_GMRF(double normReading, const mrpt::math::TPoint2D &point, const bool update_map, const bool time_invariant)
The implementation of "insertObservation" for the Gaussian Markov Random Field map model.
float compute3DMatchingRatio(const mrpt::maps::CMetricMap *otherMap, const mrpt::poses::CPose3D &otherMapPose, const TMatchingRatioParams ¶ms) const MRPT_OVERRIDE
See docs in base class: in this class this always returns 0.
double m_average_normreadings_var
bool isEnabledVerbose() const
double computeConfidenceCellValue_DM_DMV(const TRandomFieldCell *cell) const
Computes the confidence of the cell concentration (alpha)
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.
bool m_rfgm_run_update_upon_clear
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).
TInsertionOptionsCommon * m_insertOptions_common
Common options to all random-field grid maps: pointer that is set to the derived-class instance of "i...
TMapRepresentation m_mapType
The map representation type of this map, as passed in the constructor.
std::vector< float > m_DM_gaussWindow
virtual void internal_clear() MRPT_OVERRIDE
Erase all the contents of the map.
TMapRepresentation getMapType()
Return the type of the random-field grid map, according to parameters passed on construction.
static bool ENABLE_GMRF_PROFILER
[default:false] Enables a profiler to show a performance report at application end.
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...
void insertObservation_KF(double normReading, const mrpt::math::TPoint2D &point)
The implementation of "insertObservation" for the (whole) Kalman Filter map model.
std::vector< float > gauss_val
double computeVarCellValue_DM_DMV(const TRandomFieldCell *cell) const
Computes the estimated variance of the cell concentration, or the overall average variance if it has ...
utils::CDynamicGrid< TRandomFieldCell > BASE
void insertObservation_KF2(double normReading, const mrpt::math::TPoint2D &point)
The implementation of "insertObservation" for the Efficient Kalman Filter map model.
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).
void updateMapEstimation_GMRF()
solves the minimum quadratic system to determine the new concentration of each cell
bool m_hasToRecoverMeanAndCov
Only for the KF2 implementation.
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
This class allows loading and storing values and vectors of different types from a configuration text...
A 2D grid of dynamic size which stores any kind of data at each cell.
std::vector< TRandomFieldCell > m_map
The cells.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
A bidirectional version of std::map, declared as bimap<KEY,VALUE> and which actually contains two std...
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
CMatrixTemplateNumeric< double > CMatrixDouble
Declares a matrix of double numbers (non serializable).
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Parameters common to any derived class.
uint16_t GMRF_constraintsSize
[mrGMRF_G only] The size of the Gaussian window to impose fixed restrictions between cells.
float cutoffRadius
The cutoff radius for updating cells.
size_t GMRF_gridmap_image_cy
Pixel coordinates of the origin for the occupancy_gridmap.
void internal_dumpToTextStream_common(mrpt::utils::CStream &out) const
See utils::CLoadableOptions.
double GMRF_lambdaObsLoss
The loss of information of the observations with each iteration.
float sigma
The sigma of the "Parzen"-kernel Gaussian.
float KF_observationModelNoise
The sensor model noise (in normalized concentration units).
uint16_t KF_W_size
[mrKalmanApproximate] The size of the window of neighbor cells.
size_t GMRF_gridmap_image_cx
Pixel coordinates of the origin for the occupancy_gridmap.
double GMRF_saturate_max
(Default:-inf,+inf) Saturate the estimated mean in these limits
double dm_sigma_omega
[DM/DM+V methods] The scaling parameter for the confidence "alpha" values (see the IROS 2009 paper; s...
float KF_covSigma
The "sigma" for the initial covariance value between cells (in meters).
std::string GMRF_gridmap_image_file
image name of the occupancy_gridmap
double GMRF_lambdaPrior
The information (Lambda) of fixed map constraints.
bool GMRF_use_occupancy_information
whether to use information of an occupancy_gridmap map for buidling the GMRF
float KF_initialCellStd
The initial standard deviation of each cell's concentration (will be stored both at each cell's struc...
double GMRF_gridmap_image_res
occupancy_gridmap resolution: size of each pixel (m)
double GMRF_lambdaObs
The initial information (Lambda) of each observation (this information will decrease with time)
float R_max
Limits for normalization of sensor readings.
std::string GMRF_simplemap_file
simplemap_file name of the occupancy_gridmap
float KF_defaultCellMeanValue
The default value for the mean of cells' concentration.
TInsertionOptionsCommon()
Default values loader.
double GMRF_constraintsSigma
[mrGMRF_G only] The sigma of the Gaussian window to impose fixed restrictions between cells.
void internal_loadFromConfigFile_common(const mrpt::utils::CConfigFileBase &source, const std::string §ion)
See utils::CLoadableOptions.
bool GMRF_skip_variance
(Default:false) Skip the computation of the variance, just compute the mean
Parameters for CMetricMap::compute3DMatchingRatio()
The contents of each cell in a CRandomFieldGridMap2D map.
TRandomFieldCell(double kfmean_dm_mean=1e-20, double kfstd_dmmeanw=0)
Constructor.
double kf_mean
[KF-methods only] The mean value of this cell
double dmv_var_mean
[Kernel DM-V only] The cumulative weighted variance of this cell
double kf_std
[KF-methods only] The standard deviation value of this cell
double dm_mean_w
[Kernel-methods only] The cumulative weights (concentration = alpha * dm_mean / dm_mean_w + (1-alpha)...
double updated_std
[Dynamic maps only] The std cell value that was updated (to be used in the Forgetting_curve
double gmrf_mean
[GMRF only] The mean value of this cell
mrpt::system::TTimeStamp last_updated
[Dynamic maps only] The timestamp of the last time the cell was updated
double dm_mean
[Kernel-methods only] The cumulative weighted readings of this cell
maps::CRandomFieldGridMap2D::TMapRepresentation enum_t
static void fill(bimap< enum_t, std::string > &m_map)
Only specializations of this class are defined for each enum type of interest.