mrpt.maps

mrpt.maps — Metric map representations for MRPT.

Provides:
  • CMetricMap : Abstract base class for all metric maps

  • CPointsMap : Abstract base class for point cloud maps

  • CSimplePointsMap : Concrete XYZ point cloud map

  • CGenericPointsMap : XYZ point cloud + arbitrary string-keyed data channels

  • COccupancyGridMap2D : Probabilistic 2D occupancy grid map

  • COccupancyGridMap3D : Dense probabilistic 3D occupancy grid

  • CVoxelMap, CVoxelMapRGB : Sparse voxel occupancy maps

  • COctoMap : OctoMap-based 3D occupancy map

  • CHeightGridMap2D : 2.5D elevation map

  • CBeaconMap, CBeacon : Map of range-only beacons

  • CMultiMetricMap : Container of heterogeneous maps

  • CObservationPointCloud : Observation holding a point cloud map

  • VisualizationParameters, obs_to_viz() : 3D rendering of observations

  • CSimpleMap, TSetOfMetricMapInitializers, … : re-exported from mrpt.obs

Package Contents

class mrpt.maps.CBeacon

C++ API: class mrpt::maps::CBeacon

Bases: mrpt.serialization.CSerializable

The class for storing individual “beacon landmarks” under a variety of 3D position PDF distributions.

property m_ID: int

Beacon ID

getMean() → mrpt.poses.CPoint3D

Mean position of the beacon

class mrpt.maps.CBeaconMap

C++ API: class mrpt::maps::CBeaconMap

Bases: CMetricMap

A class for storing a map of 3D probabilistic beacons, using a Montecarlo, Gaussian, or Sum of Gaussians (SOG) representation (for range-only SLAM).

push_back(beacon: CBeacon) → None

Appends a beacon to the map.

size() → int

Returns the stored landmarks count.

class mrpt.maps.CGenericPointsMap

C++ API: class mrpt::maps::CGenericPointsMap

Bases: CPointsMap

A map of 3D points (X,Y,Z) plus any number of custom, string-keyed per-point data channels.

static FromNumpyFields(fields: dict) → CGenericPointsMap

Builds a map from a dict of 1D arrays of the same length, as returned by getPointFieldsAsNumpy(): x, y and z (converted to float32) and other fields, registered with the type given by their dtype (float32, float64, uint16, uint8 or uint32).

getPointFieldNames_double() → list[str]

Get list of all double channel names.

getPointFieldNames_float() → list[str]

Get list of all float channel names.

getPointFieldNames_uint16() → list[str]

Get list of all uint16_t channel names.

getPointFieldNames_uint32() → list[str]

List all uint32 channel names (New in MRPT 3.0.0)

getPointFieldNames_uint8() → list[str]

Get list of all uint8_t channel names.

getPointField_double(index: int, fieldName: str) → float

Read the value of a double channel for a given point. Returns 0 if field does not exist.

getPointField_float(index: int, fieldName: str) → float

Read the value of a float channel for a given point. Returns 0 if field does not exist.

getPointField_uint16(index: int, fieldName: str) → int

Read the value of a uint16_t channel for a given point. Returns 0 if field does not exist.

getPointField_uint32(index: int, fieldName: str) → int

Read a uint32 channel value (New in MRPT 3.0.0)

getPointField_uint8(index: int, fieldName: str) → int

Read the value of a uint8_t channel for a given point. Returns 0 if field does not exist.

hasPointField(fieldName: str) → bool

Returns true if the map has a data channel with the given name.

registerField_double(fieldName: str) → bool

Register a new per-point data channel of type float64

registerField_float(fieldName: str) → bool

Register a new per-point data channel of type float32

registerField_uint16(fieldName: str) → bool

Register a new per-point data channel of type uint16

registerField_uint32(fieldName: str) → bool

Register a new per-point data channel of type uint32 (New in MRPT 3.0.0)

registerField_uint8(fieldName: str) → bool

Register a new per-point data channel of type uint8

resize(newLength: int) → None

Resizes all point buffers so they can hold the given number of points: newly created points are set to default values, and old contents are not changed.

setPointField_double(index: int, fieldName: str, value: float) → None

Sets the value of a double channel for a given point.

setPointField_float(index: int, fieldName: str, value: float) → None

Sets the value of a float channel for a given point.

setPointField_uint16(index: int, fieldName: str, value: int) → None

Sets the value of a uint16_t channel for a given point.

setPointField_uint32(index: int, fieldName: str, value: int) → None

Set a uint32 channel value (New in MRPT 3.0.0)

setPointField_uint8(index: int, fieldName: str, value: int) → None

Sets the value of a uint8_t channel for a given point.

unregisterField(fieldName: str) → bool

Removes a data channel; returns True if it existed

class mrpt.maps.CHeightGridMap2D(xMin: float = -2.0, xMax: float = 2.0, yMin: float = -2.0, yMax: float = 2.0, resolution: float = 0.1)

C++ API: class mrpt::maps::CHeightGridMap2D

Bases: CMetricMap

Digital Elevation Model (DEM), a mesh or grid representation of a surface which keeps the estimated height for each (x,y) location.

class TInsertionOptions

Bases: mrpt.config.CLoadableOptions

Options for inserting observations into a CHeightGridMap2D.

property colorMap: mrpt.img.TColormap

Color map for the 3D view (default: cmJET).

property filterByHeight: bool

Only insert points with z in [z_min, z_max], relative to the robot (default: false).

property z_max: float

Maximum z, if filterByHeight is true (default: 0.5).

property z_min: float

Minimum z, if filterByHeight is true (default: -0.5).

property insertionOptions: CHeightGridMap2D

Options for inserting observations (TInsertionOptions).

countObservedCells() → int

Return the number of cells with at least one height data inserted.

getAsNumpy() → numpy.ndarray

Returns the heights as an HxW float64 array (NaN for unobserved cells)

getHeight(x: float, y: float) → float | None

Height at a metric position, or None if not observed

getResolution() → float

Returns the resolution of the grid map.

getSizeX() → int

Returns the horizontal size of grid map in cells count.

getSizeY() → int

Returns the vertical size of grid map in cells count.

getXMin() → float

Returns the “x” coordinate of left side of grid map.

getYMin() → float

Returns the “y” coordinate of top side of grid map.

insertIndividualPoint(x: float, y: float, z: float) → bool

Inserts one (x,y,z) point. Returns False if out of the map.

class mrpt.maps.CMetricMap

C++ API: class mrpt::maps::CMetricMap

Bases: mrpt.serialization.CSerializable

Declares a virtual base class for all metric maps storage classes.

genericMapParams: mrpt.obs.TMapGenericParams
GetRuntimeClass() → mrpt.rtti.TRuntimeClassId

Returns information about the class of an object in runtime.

boundingBox() → mrpt.math.TBoundingBox

Bounding box of the map contents

canComputeObservationLikelihood(obs: mrpt.obs.CObservation) → bool

Returns true if this map is able to compute a sensible likelihood function for this observation (i.e. an occupancy grid map cannot with an image).

clear() → None

Erase all the contents of the map.

computeObservationLikelihood(obs: mrpt.obs.CObservation, takenFrom: mrpt.poses.CPose3D) → float

Log-likelihood of an observation taken from a given robot pose

computeObservationsLikelihood(sf: mrpt.obs.CSensoryFrame, takenFrom: mrpt.poses.CPose3D) → float

Log-likelihood of all observations in a CSensoryFrame taken from a given pose

getVisualization() → mrpt.viz.CSetOfObjects

Returns a 3D representation of the map as a CSetOfObjects

getVisualizationInto(outObj: mrpt.viz.CSetOfObjects) → None

Appends a 3D representation of the map to a CSetOfObjects

insertObs(sf: mrpt.obs.CSensoryFrame, robotPose: mrpt.poses.CPose3D | None = None) → bool

Inserts all the observations of a CSensoryFrame. Returns true if any was inserted.

insertObservation(obs: mrpt.obs.CObservation, robotPose: mrpt.poses.CPose3D = None) → bool

Insert an observation into the map. Returns true if the map was updated.

isEmpty() → bool

Returns true if the map is empty/no observation has been inserted.

loadFromSimpleMap(simpleMap: mrpt.obs.CSimpleMap) → None

Clears the map and builds it from all keyframes of a CSimpleMap

saveMetricMapRepresentationToFile(filNamePrefix: str) → None

Saves the map in a format suitable for inspection (e.g. images or text)

class mrpt.maps.CMultiMetricMap

C++ API: class mrpt::maps::CMultiMetricMap

CMultiMetricMap(initializers: mrpt.obs.TSetOfMetricMapInitializers)

Bases: CMetricMap

A set of metric maps of any type, updated and queried together.

property maps: list[CMetricMap]

A list with all the maps (to replace one, use map[i] = newMap)

clearMaps() → None

Removes all maps (clear() only empties them)

mapByIndex(index: int) → CMetricMap

Gets the i-th map.

push_back(map: CMetricMap) → None

Appends a new child map to the list.

setListOfMaps(initializers: mrpt.obs.TSetOfMetricMapInitializers) → None

Replaces all maps with the ones described by a TSetOfMetricMapInitializers

size() → int

Number of child maps.

class mrpt.maps.CObservationPointCloud
class mrpt.maps.CObservationPointCloud(scan: mrpt.obs.CObservation3DRangeScan)

Bases: mrpt.obs.CObservation

An observation from any sensor that can be summarized as a pointcloud.

property pointcloud: CPointsMap

The point cloud (a CPointsMap)

sensorPose: mrpt.poses.CPose3D
getExternalStorageFile() → str

Returns the external file name of the point cloud, if any.

isExternallyStored() → bool

Returns true if the point cloud is stored in an external file.

class mrpt.maps.COccupancyGridMap2D(xMin: float = -10.0, xMax: float = 10.0, yMin: float = -10.0, yMax: float = 10.0, resolution: float = 0.10000000149011612)

C++ API: class mrpt::maps::COccupancyGridMap2D

Bases: CMetricMap

A 2D occupancy grid map: each cell holds its probability of being occupied.

class TInsertionOptions

Bases: mrpt.config.CLoadableOptions

Options for inserting observations into a COccupancyGridMap2D.

property CFD_features_gaussian_size: float

Sigma of the Gaussian filter of getAsImageFiltered() (default: 1, 0: disabled).

property CFD_features_median_size: float

Size of the median filter of getAsImageFiltered() (default: 3, 0: disabled).

property considerInvalidRangesAsFreeSpace: bool

Use invalid ranges (no echo) as free space, if the previous and next rays are also invalid (default: true).

property decimation: int

Decimation of range scans (default: 1, all rays).

property horizontalTolerance: float

Tolerance in pitch and roll for a scan to be horizontal, in radians.

property mapAltitude: float

Altitude (z) of the 2D scans to insert (0.01 m tolerance), if useMapAltitude is true.

property maxDistanceInsertion: float

Largest distance at which cells are updated (default: 15 m).

property maxFreenessInvalidRanges: float

Like maxFreenessUpdateCertainty, for invalid ranges (default: 0, the same as maxOccupancyUpdateCertainty).

property maxFreenessUpdateCertainty: float

Value in [0.5, 1] for the update of free cells (default: 0, the same as maxOccupancyUpdateCertainty).

property maxOccupancyUpdateCertainty: float

Value in [0.5, 1] for the Bayesian update of occupied cells (default: 0.65).

property raytraceStepSizeInCellUnits: float

Unused: kept for backwards compatibility.

property useMapAltitude: bool

Only insert 2D scans at mapAltitude (default: false).

property wideningBeamsWithDistance: bool

Rays widen with distance, like real laser beams (default: false).

class TLikelihoodMethod(value: int)

Method to compute the likelihood of observations.

Members:

lmMeanInformation

lmRayTracing

lmConsensus

lmCellsDifference

lmLikelihoodField_Thrun

lmLikelihoodField_II

lmConsensusOWA

property name: str
property value: int
lmCellsDifference: ClassVar[COccupancyGridMap2D]
lmConsensus: ClassVar[COccupancyGridMap2D]
lmConsensusOWA: ClassVar[COccupancyGridMap2D]
lmLikelihoodField_II: ClassVar[COccupancyGridMap2D]
lmLikelihoodField_Thrun: ClassVar[COccupancyGridMap2D]
lmMeanInformation: ClassVar[COccupancyGridMap2D]
lmRayTracing: ClassVar[COccupancyGridMap2D]
class TLikelihoodOptions

Bases: mrpt.config.CLoadableOptions

Options for computing the likelihood of observations in a COccupancyGridMap2D.

property LF_alternateAverageMethod: bool

[LikelihoodField] Average the likelihood of the ranges instead of multiplying them (default: false).

property LF_decimation: int

[LikelihoodField] Decimation of the points of a scan (default: 5, 1: none).

property LF_maxCorrsDistance: float

[LikelihoodField] Maximum distance to search correspondences of each point.

property LF_maxRange: float

[LikelihoodField] Maximum range of the sensor (default: 81 m).

property LF_stdHit: float

[LikelihoodField] Range sigma (default: 0.35).

property LF_useSquareDist: bool

[LikelihoodField] Use exp(-0.5*d^4/s^2) instead of exp(-0.5*d^2/s^2) (default: false).

property LF_zHit: float

[LikelihoodField] Weight of hits (default: 0.95).

property LF_zRandom: float

[LikelihoodField] Weight of random measurements (default: 0.05).

property MI_exponent: float

[MI] Exponent (default: 2.5).

property MI_ratio_max_distance: float

[MI] Ratio of the maximum distance, with respect to the insertion one (default: 1.5).

property MI_skip_rays: int

[MI] Use one out of N rays (default: 10).

property OWA_weights: list[float]

[OWA] Weights of the sorted likelihood values (the largest first). Assign a whole list to change it.

property consensus_pow: float

[Consensus] Power of the likelihood (default: 5).

property consensus_takeEachRange: int

[Consensus] Use one out of N ranges (default: 1).

property enableLikelihoodCache: bool

Use a cache of likelihood values, for the likelihood field methods (default: true).

property likelihoodMethod: COccupancyGridMap2D

Likelihood method (default: lmLikelihoodField_Thrun).

property rayTracing_decimation: int

[rayTracing] Simulate one out of N rays (default: 10).

property rayTracing_stdHit: float

[rayTracing] Range sigma (default: 1).

property rayTracing_useDistanceFilter: bool

[rayTracing] Unused: kept for backwards compatibility.

property insertionOptions: COccupancyGridMap2D

Options for inserting observations (TInsertionOptions).

property likelihoodOptions: COccupancyGridMap2D

Options for computing the likelihood of observations (TLikelihoodOptions).

lmCellsDifference: ClassVar[COccupancyGridMap2D]
lmConsensus: ClassVar[COccupancyGridMap2D]
lmConsensusOWA: ClassVar[COccupancyGridMap2D]
lmLikelihoodField_II: ClassVar[COccupancyGridMap2D]
lmLikelihoodField_Thrun: ClassVar[COccupancyGridMap2D]
lmMeanInformation: ClassVar[COccupancyGridMap2D]
lmRayTracing: ClassVar[COccupancyGridMap2D]
getAsNumpy() → numpy.ndarray

Returns the occupancy grid as an HxW float32 numpy array (0=occupied, 1=free)

getCell(x: int, y: int) → float

Get occupancy probability [0,1] at cell (x,y)

getPos(x: float, y: float) → float

Get occupancy probability at metric position (x,y)

getResolution() → float

Returns the resolution of the grid map.

getSizeX() → int

Returns the horizontal size of grid map in cells count.

getSizeY() → int

Returns the vertical size of grid map in cells count.

getXMax() → float

Returns the “x” coordinate of right side of grid map.

getXMin() → float

Returns the “x” coordinate of left side of grid map.

getYMax() → float

Returns the “y” coordinate of bottom side of grid map.

getYMin() → float

Returns the “y” coordinate of top side of grid map.

idx2x(arg0: int) → float

Transform a cell index into a coordinate value (center of the cell)

idx2y(arg0: int) → float

Transforms a cell index into a y coordinate (center of the cell).

isEmpty() → bool

Returns true upon map construction or after calling clear(), the return changes to false upon successful insertObservation() or any other method to load data in the map.

laserScanSimulator(inout_Scan: mrpt.obs.CObservation2DRangeScan, robotPose: mrpt.poses.CPose2D, threshold: float = 0.6000000238418579, N: int = 361, noiseStd: float = 0.0, decimation: int = 1, angleNoiseStd: float = 0.0) → None

Simulates a 2D laser scan from robotPose (CPose2D) into this grid. inout_Scan (CObservation2DRangeScan) must have its aperture, maxRange, sensorPose and rightToLeft set, and gets the N simulated ranges. threshold is the minimum occupancy of a cell to be an obstacle; noiseStd and angleNoiseStd are the sigmas of the range and angle noise; only one ray out of ‘decimation’ is simulated.

loadFromBitmapFile(file: str, resolution: float) → bool

Loads the grid map from an image file, given its resolution and origin.

loadFromROSMapServerYAML(yamlFilePath: str) → bool

Load a ROS map_server YAML + PNG/PGM file pair

saveAsBitmapFile(arg0: str) → bool

Saves the grid map as an image file; the format is given by the file extension.

setCell(x: int, y: int, value: float) → None

Set occupancy probability [0,1] at cell (x,y)

setFromNumpy(array: numpy.ndarray) → None

Sets all the cells from an HxW array, with the same layout and values as getAsNumpy() (0=occupied, 1=free).

setPos(x: float, y: float, value: float) → None

Set occupancy probability at metric position (x,y)

x2idx(x: float) → int

Transform a coordinate value into a cell index. Uses floor() to correctly handle negative coordinates near zero.

y2idx(y: float) → int

Transforms a y coordinate into a cell index.

class mrpt.maps.COccupancyGridMap3D(corner_min: mrpt.math.TPoint3D = ..., corner_max: mrpt.math.TPoint3D = ..., resolution: float = 0.25)

C++ API: class mrpt::maps::COccupancyGridMap3D

Bases: CMetricMap

A 3D occupancy grid map with a regular, even distribution of voxels.

class TInsertionOptions

Bases: mrpt.config.CLoadableOptions

Options for inserting observations into a COccupancyGridMap3D.

property decimation: int

Decimation of point clouds and 2D range scans (default: 1).

property decimation_3d_range: int

Decimation of 3D range scans: keeps the minimum range of each NxN block (default: 8).

property maxDistanceInsertion: float

Largest distance at which voxels are updated (default: 15 m).

property maxFreenessUpdateCertainty: float

Value in [0.5, 1] for the update of free voxels (default: 0, the same as maxOccupancyUpdateCertainty).

property maxOccupancyUpdateCertainty: float

Value in [0.5, 1] for the Bayesian update of occupied voxels (default: 0.65).

property raytraceEmptyCells: bool

Mark the voxels along the rays as free (default: true), or only update the end points.

class TLikelihoodMethod(value: int)

Method to compute the likelihood of observations.

Members:

lmLikelihoodField_Thrun

lmRayTracing

property name: str
property value: int
lmLikelihoodField_Thrun: ClassVar[COccupancyGridMap3D]
lmRayTracing: ClassVar[COccupancyGridMap3D]
class TLikelihoodOptions

Bases: mrpt.config.CLoadableOptions

Options for computing the likelihood of observations in a COccupancyGridMap3D (not implemented yet for this map: likelihoods are always 0).

property LF_decimation: int

[LikelihoodField] Decimation of the points (default: 1, none).

property LF_maxCorrsDistance: float

[LikelihoodField] Maximum distance to search correspondences of each point.

property LF_maxRange: float

[LikelihoodField] Maximum range of the sensor (default: 20 m).

property LF_stdHit: float

[LikelihoodField] Range sigma (default: 0.35).

property LF_useSquareDist: bool

[LikelihoodField] Use exp(-0.5*d^4/s^2) instead of exp(-0.5*d^2/s^2) (default: false).

property LF_zHit: float

[LikelihoodField] Weight of hits (default: 0.95).

property LF_zRandom: float

[LikelihoodField] Weight of random measurements (default: 0.05).

property likelihoodMethod: COccupancyGridMap3D

Likelihood method (default: lmLikelihoodField_Thrun).

property rayTracing_decimation: int

[rayTracing] Simulate one out of N rays (default: 10).

property rayTracing_stdHit: float

[rayTracing] Range sigma (default: 1).

property insertionOptions: COccupancyGridMap3D

Options for inserting observations (TInsertionOptions).

property likelihoodOptions: COccupancyGridMap3D

Options for computing the likelihood of observations (TLikelihoodOptions).

lmLikelihoodField_Thrun: ClassVar[COccupancyGridMap3D]
lmRayTracing: ClassVar[COccupancyGridMap3D]
fill(default_value: float = 0.5) → None

Sets all voxels to a freeness value

getCellFreeness(cx: int, cy: int, cz: int) → float

Freeness probability [0,1] of a voxel by index (1 = free)

getFreenessByPos(x: float, y: float, z: float) → float

Freeness probability [0,1] at a metric position (1 = free)

getOccupiedVoxelsAsNumpy(occupiedThreshold: float = 0.5) → numpy.ndarray

Returns the centers of the voxels with an occupancy probability above the threshold, as an Nx3 float32 array.

getResolution() → float

Voxel size (meters)

getSizeX() → int

Number of voxels in X

getSizeY() → int

Number of voxels in Y

getSizeZ() → int

Number of voxels in Z

setCellFreeness(cx: int, cy: int, cz: int, value: float) → None

Sets the freeness probability [0,1] of a voxel by index

setFreenessByPos(x: float, y: float, z: float, value: float) → None

Sets the freeness probability [0,1] at a metric position

class mrpt.maps.COctoMap(resolution: float = 0.1)

C++ API: class mrpt::maps::COctoMap

Bases: CMetricMap

A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the “octomap” C++ library.

class TInsertionOptions

Bases: mrpt.config.CLoadableOptions

Options for inserting observations into a COctoMap. Access them through COctoMap.insertionOptions: the sensor model parameters are stored in the map itself.

property clampingThresMax: float

Maximum occupancy probability for clamping (default: 0.971).

property clampingThresMin: float

Minimum occupancy probability for clamping (default: 0.1192).

property maxrange: float

Maximum range of the inserted rays (default: -1, the complete rays).

property occupancyThres: float

Occupancy probability threshold of the sensor model (default: 0.5).

property probHit: float

Probability of a hit in the sensor model (default: 0.7).

property probMiss: float

Probability of a miss in the sensor model (default: 0.4).

property pruning: bool

Prune the tree after each insertion (default: true).

class TLikelihoodOptions

Bases: mrpt.config.CLoadableOptions

Options for computing the likelihood of observations in a COctoMap.

property decimation: int

Use one out of N rays (default: 1, all of them).

property insertionOptions: COctoMap

Options for inserting observations (TInsertionOptions): modify its fields in place.

property likelihoodOptions: COctoMap

Options for computing the likelihood of observations (TLikelihoodOptions).

getMetricMax() → mrpt.math.TPoint3D

Maximum value of the bounding box of all known space in x, y, z.

getMetricMin() → mrpt.math.TPoint3D

Minimum value of the bounding box of all known space in x, y, z.

getOccupiedVoxelsAsNumpy() → tuple

Returns the occupied leaf voxels (occupancy >= 0.5) as a tuple (centers: Nx3 float32 array, side lengths: float32 array). Pruned leaves may be larger than the resolution.

getPointOccupancy(x: float, y: float, z: float) → float | None

Occupancy probability [0,1] at a point, or None if the point is not in the octree

getResolution() → float

Returns the size of the octomap leaf voxels.

insertPointCloud(points: CPointsMap, sensor_x: float, sensor_y: float, sensor_z: float) → None

Inserts a point cloud as rays from the sensor position

isPointWithinOctoMap(x: float, y: float, z: float) → bool

Check whether the given point lies within the volume covered by the octomap (that is, whether it is “mapped”)

size() → int

Number of octree nodes

updateVoxel(x: float, y: float, z: float, occupied: bool) → None

Updates one voxel with an occupied or free observation

class mrpt.maps.CPointsMap

C++ API: class mrpt::maps::CPointsMap

Bases: CMetricMap

A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors.

getLoadPLYErrorString() → str

Description of the error of the last failed loadFromPlyFile().

getPoint(i: int) → tuple

Returns (x, y, z) tuple for point i

getPointFieldsAsNumpy() → dict

Returns a dict with a 1D NumPy array (a copy) for x, y, z and every other point field, with its dtype: float32, float64, uint16, uint8 or uint32.

getPointsAsNumpy() → numpy.ndarray

Returns all points as an Nx3 float32 numpy array

getSavePLYErrorString() → str

Description of the error of the last failed saveToPlyFile().

insertPoint(x: float, y: float, z: float = 0.0) → None

Provides a way to insert (append) individual points into the map: the missing fields of child classes (color, weight, etc) are left to their default values.

isEmpty() → bool

Returns true if the map is empty/no observation has been inserted.

load2D_from_text_file(arg0: str) → bool

Load from a text file. Each line should contain an “X Y” coordinate pair, separated by whitespaces.

load3D_from_text_file(arg0: str) → bool

Load from a text file. Each line should contain an “X Y Z” coordinate tuple, separated by whitespaces.

loadFromKittiVelodyneFile(filename: str) → bool

Loads a KITTI Velodyne scan (binary XYZI, gzip-compressed if the name ends in “.gz”), with the intensity in the “intensity” field if the map supports it. Returns True on success.

loadFromPlyFile(filename: str) → bool

Loads the points from a PLY file. Returns False on error: see getLoadPLYErrorString().

nn_multiple_search(query: mrpt.math.TPoint2D, N: int) → tuple

The N closest points to a 2D query point, ignoring z (KD-tree search), sorted by distance. Returns (indices: uint64 array, points: Nx2 float32 array, squared distances: float32 array).

nn_radius_search(query: mrpt.math.TPoint2D, search_radius_sqr: float, maxPoints: int = 0) → tuple

The points within a distance of a 2D query point, ignoring z (KD-tree search). The radius is given squared; maxPoints=0 means no limit. Returns (indices: uint64 array, points: Nx2 float32 array, squared distances: float32 array).

nn_single_search(query: mrpt.math.TPoint2D) → Any

Closest point to a 2D query point, ignoring z (KD-tree search). Returns (index, point, squared distance), or None if none was found.

reserve(arg0: int) → None

Reserves memory for a given number of points, without changing the map size.

save2D_to_text_file(arg0: str) → bool

Save to a text file. Each line will contain “X Y” point coordinates.

save3D_to_text_file(arg0: str) → bool

Save to a text file. Each line will contain “X Y Z” point coordinates.

saveToKittiVelodyneFile(filename: str) → bool

Saves the points and their “intensity” field in the binary XYZI format of the KITTI dataset, always compressed: use a file name ending in “.gz” to load it back. Returns True on success.

saveToPlyFile(filename: str, save_in_binary: bool = False, file_comments: list[str] = []) → bool

Saves the points to a PLY file (text or binary). Returns False if the file cannot be created, or on other errors: see getSavePLYErrorString().

setPointsFromNumpy(arr: numpy.ndarray) → None

Replaces all the points with those of an Nx3 array (other point fields are reset to their default values).

size() → int

Returns the number of points.

class mrpt.maps.CSimpleMap

C++ API: class mrpt::maps::CSimpleMap

Bases: mrpt.serialization.CSerializable

A view-based map: a set of poses and what the robot saw from those poses.

class Keyframe
class Keyframe(pose: mrpt.poses.CPose3DPDF, sf: CSensoryFrame, localTwist: mrpt.math.TTwist3D | None = None)

One keyframe of a CSimpleMap: a pose PDF, a sensory frame and an optional twist.

localTwist: mrpt.math.TTwist3D | None
pose: mrpt.poses.CPose3DPDF
sf: CSensoryFrame
changeCoordinatesOrigin(newOrigin: mrpt.poses.CPose3D) → None

Transforms all keyframe poses so the old origin becomes newOrigin

clear() → None

Remove all stored keyframes.

empty() → bool

Returns true if the map has no keyframes.

get(index: int) → CSimpleMap

Returns the i-th keyframe.

insert(pose: mrpt.poses.CPose3DPDF, sf: CSensoryFrame, localTwist: mrpt.math.TTwist3D | None = None) → None
insert(keyframe: CSimpleMap) → None

Appends a keyframe (pose PDF and sensory frame).

loadFromFile(fileName: str) → bool

Loads a .simplemap file (possibly compressed). Returns False on error.

remove(index: int) → None

Removes the i-th keyframe.

saveToFile(fileName: str) → bool

Saves to a .simplemap file. Returns False on error.

size() → int

Returns the number of keyframes in the map.

class mrpt.maps.CSimplePointsMap

C++ API: class mrpt::maps::CSimplePointsMap

Bases: CPointsMap

A cloud of points in 2D or 3D, which can be built from a sequence of laser scans.

class mrpt.maps.CVoxelMap(resolution: float = 0.05, inner_bits: int = 2, leaf_bits: int = 3)

C++ API: class mrpt::maps::CVoxelMap

Bases: CMetricMap

A sparse 3D occupancy voxel map, with log-odds occupancy per voxel.

property insertionOptions: TVoxelMap_InsertionOptions

Options for inserting observations (TVoxelMap_InsertionOptions).

property likelihoodOptions: TVoxelMap_LikelihoodOptions

Options for computing the likelihood of observations (TVoxelMap_LikelihoodOptions).

getOccupiedVoxels() → CSimplePointsMap

Returns the centers of all occupied voxels as a CSimplePointsMap

getPointOccupancy(x: float, y: float, z: float) → float | None

Occupancy probability [0,1] of the voxel at a point, or None if not observed

insertPointCloudAsEndPoints(points: CPointsMap, sensorPt: mrpt.math.TPoint3D) → None

Inserts a point cloud updating only the end points

insertPointCloudAsRays(points: CPointsMap, sensorPt: mrpt.math.TPoint3D) → None

Inserts a point cloud, marking free space along the rays from sensorPt

updateVoxel(x: float, y: float, z: float, occupied: bool) → None

Updates one voxel with an occupied or free observation

class mrpt.maps.CVoxelMapRGB(resolution: float = 0.05, inner_bits: int = 2, leaf_bits: int = 3)

C++ API: class mrpt::maps::CVoxelMapRGB

Bases: CMetricMap

A sparse 3D occupancy voxel map, with log-odds occupancy and an RGB color per voxel.

property insertionOptions: TVoxelMap_InsertionOptions

Options for inserting observations (TVoxelMap_InsertionOptions).

property likelihoodOptions: TVoxelMap_LikelihoodOptions

Options for computing the likelihood of observations (TVoxelMap_LikelihoodOptions).

getOccupiedVoxels() → CSimplePointsMap

Returns the centers of all occupied voxels as a CSimplePointsMap

getPointOccupancy(x: float, y: float, z: float) → float | None

Occupancy probability [0,1] of the voxel at a point, or None if not observed

insertPointCloudAsEndPoints(points: CPointsMap, sensorPt: mrpt.math.TPoint3D) → None

Inserts a point cloud updating only the end points

insertPointCloudAsRays(points: CPointsMap, sensorPt: mrpt.math.TPoint3D) → None

Inserts a point cloud, marking free space along the rays from sensorPt

updateVoxel(x: float, y: float, z: float, occupied: bool) → None

Updates one voxel with an occupied or free observation

class mrpt.maps.PointCloudRecoloringParameters

Parameters for recolorize3Dpc(), or part of VisualizationParameters if using obs_to_viz()

colorMap: mrpt.img.TColormap
colorMapMaxCoord: float | None
colorMapMinCoord: float | None
colorizeByField: str
invertColorMapping: bool
outlierRejectionPercentile: float | None
class mrpt.maps.TMapGenericParams

C++ API: class mrpt::maps::TMapGenericParams

Bases: mrpt.config.CLoadableOptions, mrpt.serialization.CSerializable

Parameters common to all metric maps.

enableObservationInsertion: bool
enableObservationLikelihood: bool
enableSaveAs3DObject: bool
class mrpt.maps.TMetricMapInitializer

C++ API: struct mrpt::maps::TMetricMapInitializer

Bases: mrpt.config.CLoadableOptions

Base class of the definitions of one metric map (its type and parameters).

genericMapParams: TMapGenericParams
static factory(mapClassName: str) → TMetricMapInitializer

Creates the definition of a map by its class name, e.g. ‘COccupancyGridMap2D’. Requires importing mrpt.maps first, which registers the map types.

getMetricMapClassName() → str

Returns the C++ class name of the map this definition creates

class mrpt.maps.TSetOfMetricMapInitializers

C++ API: class mrpt::maps::TSetOfMetricMapInitializers

Bases: mrpt.config.CLoadableOptions

A set of map definitions, used to build a CMultiMetricMap.

clear() → None

Removes all map definitions.

push_back(mapDefinition: TMetricMapInitializer) → None

Appends a map definition.

size() → int

Returns the number of map definitions.

class mrpt.maps.TVoxelMap_InsertionOptions

C++ API: struct mrpt::maps::TVoxelMap_InsertionOptions

Bases: mrpt.config.CLoadableOptions

Options for inserting observations into a CVoxelMap or CVoxelMapRGB.

property clamp_max: float

Maximum occupancy probability (default: 0.95).

property clamp_min: float

Minimum occupancy probability (default: 0.10).

property decimation: int

Use one out of N points (default: 1).

property max_range: float

Maximum range of the inserted rays (<0: no limit).

property prob_hit: float

Occupancy probability of a voxel where a ray ends, > 0.5 (default: 0.65).

property prob_miss: float

Occupancy probability of a voxel crossed by a ray, < 0.5 (default: 0.45).

property ray_trace_free_space: bool

Mark the voxels along the rays as free (default: true).

property remove_voxels_farther_than: float

If not 0, remove the voxels farther than this L1 distance, in meters (default: 0).

class mrpt.maps.TVoxelMap_LikelihoodOptions

C++ API: struct mrpt::maps::TVoxelMap_LikelihoodOptions

Bases: mrpt.config.CLoadableOptions

Options for computing the likelihood of observations in a CVoxelMap or CVoxelMapRGB.

property decimate_up_to: int

Use at most this number of points (default: 0, values <= 1 mean all of them).

property occupiedThreshold: float

Minimum occupancy for a voxel to be occupied (default: 0.60).

class mrpt.maps.VisualizationParameters

Here we can customize the way observations will be rendered as 3D objects in obs_to_viz(), obs3Dscan_to_viz(), etc.

axisLimits: float
axisTickFrequency: float
axisTickTextSize: float
colorFromRGBimage: bool
coloring: PointCloudRecoloringParameters
drawSensorPose: bool
onlyPointsWithColor: bool
pointSize: float
points2DscansColor: mrpt.img.TColor
sensorPoseScale: float
showAxis: bool
showPointsIn2Dscans: bool
showSurfaceIn2Dscans: bool
surface2DscansColor: mrpt.img.TColor
mrpt.maps.obs_to_viz(obs: mrpt.obs.CObservation, params: VisualizationParameters = ..., out: mrpt.viz.CSetOfObjects = None) → mrpt.viz.CSetOfObjects
mrpt.maps.obs_to_viz(sf: mrpt.obs.CSensoryFrame, params: VisualizationParameters = ..., out: mrpt.viz.CSetOfObjects = None) → mrpt.viz.CSetOfObjects

Renders all observations of a CSensoryFrame into a CSetOfObjects (a new one if out is None), and returns it