Class CPosePDFGrid
Defined in File CPosePDFGrid.h
Inheritance Relationships
Base Types
public mrpt::poses::CPosePDF(Class CPosePDF)public mrpt::poses::CPose2DGridTemplate< double >(Template Class CPose2DGridTemplate)
Class Documentation
-
class CPosePDFGrid : public mrpt::poses::CPosePDF, public mrpt::poses::CPose2DGridTemplate<double>
Represents a Probability Distribution Function (PDF) of a 2D pose (x, y, phi) as a discrete 3D grid over the SE(2) space.
Each cell in the grid stores a (non-negative) probability value. The grid spans a rectangular region in (x, y) and a range of heading angles phi. Cell resolutions are set independently for the spatial and angular dimensions.
Important: The constructor initializes the grid with a uniform distribution (all cells equal, summing to 1). If you intend to build a custom distribution, call uniformDistribution() or manually zero out cells before assigning probabilities, then call normalize().
See also
Public Functions
-
CPosePDFGrid(double xMin = -1.0f, double xMax = 1.0f, double yMin = -1.0f, double yMax = 1.0f, double resolutionXY = 0.5f, double resolutionPhi = mrpt::DEG2RAD(180.0), double phiMin = -M_PI, double phiMax = M_PI)
Constructor: Initializes a uniform distribution over the given range.
Note
After construction all cells have equal probability (uniform). Use getByPos() / getByIndex() to modify individual cells, then call normalize() before sampling or querying the distribution.
- Parameters:
xMin – [in] Minimum x coordinate (meters).
xMax – [in] Maximum x coordinate (meters).
yMin – [in] Minimum y coordinate (meters).
yMax – [in] Maximum y coordinate (meters).
resolutionXY – [in] Spatial cell size (meters).
resolutionPhi – [in] Angular cell size (radians).
phiMin – [in] Minimum heading angle (radians, default -π).
phiMax – [in] Maximum heading angle (radians, default +π).
-
~CPosePDFGrid() override
-
virtual void copyFrom(const CPosePDF &o) override
Copy from another PDF, translating representations if needed.
-
void normalize()
Normalizes the PDF so that all cells sum to 1.
-
void uniformDistribution()
Resets all cells to a uniform distribution (all equal, summing to 1).
-
std::tuple<cov_mat_t, type_value> getCovarianceAndMean() const override
Returns the covariance matrix and the mean of the distribution.
-
bool saveToTextFile(const std::string &dataFile) const override
Save the 3D grid to a text file as vertically concatenated matrices (one per phi level). A companion file “<filename>_dims.txt” stores the grid dimensions.
- Returns:
false on error
-
virtual void changeCoordinatesReference(const CPose3D &newReferenceBase) override
Applies a coordinate change: this = newReferenceBase (+) this. Useful for converting from local to global coordinates.
-
virtual void bayesianFusion(const CPosePDF &p1, const CPosePDF &p2, const double minMahalanobisDistToDrop = 0) override
Bayesian fusion of two densities via pointwise multiplication.
- Parameters:
minMahalanobisDistToDrop – [in] Unused in the grid representation.
-
virtual void inverse(CPosePDF &o) const override
Returns the inverse PDF: NEW_PDF = (0,0,0) − THIS_PDF.
-
void drawSingleSample(CPose2D &outPart) const override
Draws a single sample from the distribution.
Note
The distribution must be normalized (call normalize() first).
-
void drawManySamples(size_t N, std::vector<mrpt::math::CVectorDouble> &outSamples) const override
Draws N samples from the distribution. Each entry in outSamples is a 3-element vector [x, y, phi].
-
virtual void printTo(std::ostream &out) const override
Write a human-readable description of this PDF to the given stream. Derived classes must override this method.
-
CPosePDFGrid(double xMin = -1.0f, double xMax = 1.0f, double yMin = -1.0f, double yMax = 1.0f, double resolutionXY = 0.5f, double resolutionPhi = mrpt::DEG2RAD(180.0), double phiMin = -M_PI, double phiMax = M_PI)