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- 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- size() int
- class mrpt.maps.CGenericPointsMap
C++ API: class mrpt::maps::CGenericPointsMap
Bases:
CPointsMap- getPointFieldNames_double() list[str]
- getPointFieldNames_float() list[str]
- getPointFieldNames_uint16() list[str]
- getPointFieldNames_uint32() list[str]
List all uint32 channel names (New in MRPT 3.0.0)
- getPointFieldNames_uint8() list[str]
- getPointField_double(index: int, fieldName: str) float
- getPointField_float(index: int, fieldName: str) float
- getPointField_uint16(index: int, fieldName: str) int
- 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
- hasPointField(fieldName: str) bool
- 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
- setPointField_double(index: int, fieldName: str, value: float) None
- setPointField_float(index: int, fieldName: str, value: float) None
- setPointField_uint16(index: int, fieldName: str, value: int) None
- 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
- 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- countObservedCells() int
- 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
- getSizeX() int
- getSizeY() int
- getXMin() float
- getYMin() float
- 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- genericMapParams: mrpt.obs.TMapGenericParams
- GetRuntimeClass() mrpt.rtti.TRuntimeClassId
- boundingBox() mrpt.math.TBoundingBox
Bounding box of the map contents
- canComputeObservationLikelihood(obs: mrpt.obs.CObservation) bool
- clear() None
- 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
- 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- 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
- push_back(map: CMetricMap) None
- setListOfMaps(initializers: mrpt.obs.TSetOfMetricMapInitializers) None
Replaces all maps with the ones described by a TSetOfMetricMapInitializers
- size() int
- class mrpt.maps.CObservationPointCloud
- class mrpt.maps.CObservationPointCloud(scan: mrpt.obs.CObservation3DRangeScan)
Bases:
mrpt.obs.CObservation- property pointcloud: CPointsMap
The point cloud (a CPointsMap)
- sensorPose: mrpt.poses.CPose3D
- getExternalStorageFile() str
- isExternallyStored() bool
- 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- 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
- getSizeX() int
- getSizeY() int
- getXMax() float
- getXMin() float
- getYMax() float
- getYMin() float
- idx2x(arg0: int) float
- idx2y(arg0: int) float
- isEmpty() bool
- loadFromBitmapFile(file: str, resolution: float) bool
- loadFromROSMapServerYAML(yamlFilePath: str) bool
Load a ROS map_server YAML + PNG/PGM file pair
- saveAsBitmapFile(arg0: str) bool
- setCell(x: int, y: int, value: float) None
Set occupancy probability [0,1] at cell (x,y)
- setPos(x: float, y: float, value: float) None
Set occupancy probability at metric position (x,y)
- x2idx(x: float) int
- y2idx(y: float) int
- 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- 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)
- 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- getMetricMax() mrpt.math.TPoint3D
- getMetricMin() mrpt.math.TPoint3D
- 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
- 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
- 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- getPoint(i: int) tuple
Returns (x, y, z) tuple for point i
- getPointsAsNumpy() numpy.ndarray
Returns all points as an Nx3 float32 numpy array
- insertPoint(x: float, y: float, z: float = 0.0) None
- isEmpty() bool
- load2D_from_text_file(arg0: str) bool
- load3D_from_text_file(arg0: str) bool
- reserve(arg0: int) None
- save2D_to_text_file(arg0: str) bool
- save3D_to_text_file(arg0: str) bool
- setPointsFromNumpy(arr: numpy.ndarray) None
Load an Nx3 float32 numpy array into this point cloud
- size() int
- class mrpt.maps.CSimpleMap
C++ API: class mrpt::maps::CSimpleMap
Bases:
mrpt.serialization.CSerializable- class Keyframe
- class Keyframe(pose: mrpt.poses.CPose3DPDF, sf: CSensoryFrame, localTwist: mrpt.math.TTwist3D | None = None)
- 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
- empty() bool
- get(index: int) CSimpleMap
- insert(pose: mrpt.poses.CPose3DPDF, sf: CSensoryFrame, localTwist: mrpt.math.TTwist3D | None = None) None
- insert(keyframe: CSimpleMap) None
- loadFromFile(fileName: str) bool
Loads a .simplemap file (possibly compressed). Returns False on error.
- remove(index: int) None
- saveToFile(fileName: str) bool
Saves to a .simplemap file. Returns False on error.
- size() int
- class mrpt.maps.CSimplePointsMap
C++ API: class mrpt::maps::CSimplePointsMap
Bases:
CPointsMap
- class mrpt.maps.CVoxelMap(resolution: float = 0.05, inner_bits: int = 2, leaf_bits: int = 3)
C++ API: class mrpt::maps::CVoxelMap
Bases:
CMetricMap- 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- 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
- 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- enableObservationInsertion: bool
- enableObservationLikelihood: bool
- enableSaveAs3DObject: bool
- class mrpt.maps.TMetricMapInitializer
C++ API: struct mrpt::maps::TMetricMapInitializer
Bases:
mrpt.config.CLoadableOptions- 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- clear() None
- push_back(mapDefinition: TMetricMapInitializer) None
- size() int
- class mrpt.maps.VisualizationParameters
- 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