mrpt.slam

mrpt.slam — SLAM and localization algorithms for MRPT.

Provides:
  • CICP : Iterative Closest Point algorithm for map alignment

  • CICPOptions : Parameters for the CICP algorithm

  • TICPReturnInfo : Result information from CICP.AlignPDF()

  • CMetricMapBuilder : Abstract base for SLAM map builders

  • CMetricMapBuilderICP : Simple ICP-based SLAM map builder

  • CMetricMapBuilderICPOptions : Options for CMetricMapBuilderICP

  • TICPAlgorithm : Enum: icpClassic, icpLevenbergMarquardt

  • TICPCovarianceMethod : Enum: icpCovLinealMSE, icpCovFiniteDifferences

  • CMonteCarloLocalization2D/3D, TMonteCarloLocalizationParams, TKLDParams :

    particle filter localization (run it with mrpt.bayes.CParticleFilter.executeOn())

  • CMetricMapBuilderRBPF : Rao-Blackwellized particle filter SLAM

Basic ICP-SLAM usage:

import mrpt.slam as slam
import mrpt.obs as obs
import mrpt.maps

builder = slam.CMetricMapBuilderICP()
builder.ICP_options.insertionLinDistance = 0.5
builder.initialize()

# In a loop:
builder.processObservation(my_scan_obs)
pose_pdf = builder.getCurrentPoseEstimation()

Package Contents

class mrpt.slam.CICP

C++ API: class mrpt::slam::CICP

CICP(options: CICPOptions)

Several implementations of ICP (Iterative closest point) algorithms for aligning two point maps or a point map wrt a grid map.

options: CICPOptions
AlignPDF(m1: mrpt.maps.CMetricMap, m2: mrpt.maps.CMetricMap, initialEstimationPDF: mrpt.poses.CPosePDFGaussian) → tuple

Align two maps. Returns (CPosePDF, TICPReturnInfo) tuple.

class mrpt.slam.CICPOptions

Bases: mrpt.config.CLoadableOptions

The ICP algorithm configuration data.

ALFA: float
ICP_algorithm: TICPAlgorithm
ICP_covariance_method: TICPCovarianceMethod
corresponding_points_decimation: int
doRANSAC: bool
maxIterations: int
skip_cov_calculation: bool
skip_quality_calculation: bool
smallestThresholdDist: float
thresholdAng: float
thresholdDist: float
class mrpt.slam.CMetricMapBuilder

C++ API: class mrpt::slam::CMetricMapBuilder

Base class of the SLAM map builders.

getCurrentPoseEstimation() → mrpt.poses.CPose3DPDF

Returns a copy of the current best pose estimation as a pose PDF.

getCurrentlyBuiltMapSize() → int

Returns just how many sensory-frames are stored in the currently build map.

initialize() → None
initialize(initialMap: mrpt.obs.CSimpleMap) → None

Initialize the builder with a given initial map.

processActionObservation(action: mrpt.obs.CActionCollection, sf: mrpt.obs.CSensoryFrame) → None

Updates the map and pose estimate with a new action and sensory frame.

saveCurrentMapToFile(fileName: str, compressGZ: bool = True) → None

Saves the current map (a CSimpleMap) to a .simplemap file.

class mrpt.slam.CMetricMapBuilderICP

C++ API: class mrpt::slam::CMetricMapBuilderICP

Bases: CMetricMapBuilder

A class for very simple 2D SLAM based on ICP. This is a non-probabilistic pose tracking algorithm.

ICP_options: CMetricMapBuilderICPOptions
ICP_params: CICPOptions
getCurrentMapPoints() → tuple

Returns (xs, ys) float lists of current point-map coordinates.

getCurrentPoseEstimation() → mrpt.poses.CPose3DPDF

Returns a copy of the current best pose estimation as a pose PDF.

getCurrentlyBuiltMapSize() → int

Returns just how many sensory-frames are stored in the currently build map.

initialize() → None
initialize(initialMap: mrpt.obs.CSimpleMap) → None

Starts from a given initial map.

processActionObservation(action: mrpt.obs.CActionCollection, sf: mrpt.obs.CSensoryFrame) → None

Process action+sensoryframe pair (classic API).

processObservation(obs: mrpt.obs.CObservation) → None

Process a single observation (new-style API).

saveCurrentMapToFile(fileName: str, compressGZ: bool = True) → None

Saves the current map (a CSimpleMap) to a .simplemap file.

useSimplePointsMap() → None

Configure the builder to use a single CSimplePointsMap. Call before initialize().

class mrpt.slam.CMetricMapBuilderICPOptions

Bases: mrpt.config.CLoadableOptions

Options of CMetricMapBuilderICP.

insertionAngDistance: float
insertionLinDistance: float
localizationAngDistance: float
localizationLinDistance: float
matchAgainstTheGrid: bool
minICPgoodnessToAccept: float
loadFromConfigFile(iniContent: str, section: str) → None
loadFromConfigFile(source: mrpt.config.CConfigFileBase, section: str) → None

Load options (including mapInitializers) from a config file.

class mrpt.slam.CMetricMapBuilderRBPF

C++ API: class mrpt::slam::CMetricMapBuilderRBPF

CMetricMapBuilderRBPF(options: CMetricMapBuilderRBPF)

Bases: CMetricMapBuilder

This class implements a Rao-Blackwelized Particle Filter (RBPF) approach to map building (SLAM).

class TConstructionOptions

Bases: mrpt.config.CLoadableOptions

Options of CMetricMapBuilderRBPF.

PF_options: mrpt.bayes.TParticleFilterOptions
insertionAngDistance: float
insertionLinDistance: float
localizeAngDistance: float
localizeLinDistance: float
mapsInitializers: mrpt.obs.TSetOfMetricMapInitializers
predictionOptions: TPredictionParams
clear() → None

Clears all maps and resets the filter

getCurrentJointEntropy() → float

Returns the joint entropy of the map and path estimate.

getCurrentMostLikelyPath() → list[mrpt.math.TPose3D]

Returns the robot path of the most likely particle, as a list of TPose3D

getCurrentPoseEstimation() → mrpt.poses.CPose3DPDF

Returns the current robot pose estimation (a CPose3DPDF)

getCurrentlyBuiltMap() → mrpt.obs.CSimpleMap

Returns the keyframes of the most likely particle as a CSimpleMap

getCurrentlyBuiltMapSize() → int

Returns just how many sensory-frames are stored in the currently build map.

getCurrentlyBuiltMetricMap() → mrpt.maps.CMultiMetricMap

Returns a copy of the map of the most likely particle (the particles are replaced as the filter runs, so a reference would not stay valid)

initialize(initialMap: mrpt.obs.CSimpleMap = ...) → None

Resets the filter, optionally starting from a given map

processActionObservation(action: mrpt.obs.CActionCollection, sf: mrpt.obs.CSensoryFrame) → None

Processes one (action, sensory frame) pair

saveCurrentPathEstimationToTextFile(fileName: str) → None

A logging utility: saves the current path estimation for each particle in a text file (a row per particle, each 3-column-entry is a set [x,y,phi], respectively).

class mrpt.slam.CMonteCarloLocalization2D(M: int = 1)

C++ API: class mrpt::slam::CMonteCarloLocalization2D

Bases: mrpt.poses.CPosePDFParticles

Particle filter for 2D robot localization (x, y, phi) on a known map.

options: TMonteCarloLocalizationParams
getVisualization() → mrpt.viz.CSetOfObjects

Returns a 3D representation of the particles

resetUniformFreeSpace(theMap: mrpt.maps.COccupancyGridMap2D, freeCellsThreshold: float = 0.7, particlesCount: int = -1, x_min: float = -10000000000.0, x_max: float = 10000000000.0, y_min: float = -10000000000.0, y_max: float = 10000000000.0, phi_min: float = -3.141592653589793, phi_max: float = 3.141592653589793) → None

Spreads particles uniformly over the free space of an occupancy grid (global localization)

class mrpt.slam.CMonteCarloLocalization3D(M: int = 1)

C++ API: class mrpt::slam::CMonteCarloLocalization3D

Bases: mrpt.poses.CPose3DPDFParticles

Particle filter for 3D robot localization on a known map.

options: TMonteCarloLocalizationParams
getVisualization() → mrpt.viz.CSetOfObjects

Returns a 3D representation of the particles

class mrpt.slam.TICPAlgorithm(value: int)

Members:

icpClassic

icpLevenbergMarquardt

property name: str
property value: int
icpClassic: ClassVar[TICPAlgorithm]
icpLevenbergMarquardt: ClassVar[TICPAlgorithm]
class mrpt.slam.TICPCovarianceMethod(value: int)

Members:

icpCovLinealMSE

icpCovFiniteDifferences

property name: str
property value: int
icpCovFiniteDifferences: ClassVar[TICPCovarianceMethod]
icpCovLinealMSE: ClassVar[TICPCovarianceMethod]
class mrpt.slam.TICPReturnInfo

The ICP algorithm return information.

goodness: float
nIterations: int
quality: float
class mrpt.slam.TKLDParams

C++ API: class mrpt::slam::TKLDParams

Bases: mrpt.config.CLoadableOptions

Option set for KLD algorithm.

KLD_binSize_PHI: float
KLD_binSize_XY: float
KLD_delta: float
KLD_epsilon: float
KLD_maxSampleSize: int
KLD_minSampleSize: int
KLD_minSamplesPerBin: float
class mrpt.slam.TMonteCarloLocalizationParams

C++ API: struct mrpt::slam::TMonteCarloLocalizationParams

Parameters of the prediction and update stages of Monte Carlo localization.

property metricMap: mrpt.maps.CMetricMap

The map used to evaluate observation likelihoods (e.g. a CMultiMetricMap)

property metricMaps: list[mrpt.maps.CMetricMap]

Alternative to metricMap: one map per particle (rarely used)

KLD_params: TKLDParams
class mrpt.slam.TPredictionParams

Bases: mrpt.config.CLoadableOptions

Parameters of the prediction and update stages of RBPF-SLAM.

ICPGlobalAlign_MinQuality: float
KLD_params: TKLDParams
icp_params: CICPOptions
pfOptimalProposal_mapSelection: int
mrpt.slam.icpClassic: _bindings.TICPAlgorithm
mrpt.slam.icpCovFiniteDifferences: _bindings.TICPCovarianceMethod
mrpt.slam.icpCovLinealMSE: _bindings.TICPCovarianceMethod
mrpt.slam.icpLevenbergMarquardt: _bindings.TICPAlgorithm