mrpt.poses

mrpt-poses Python API.

Package Contents

class mrpt.poses.CPoint2D

C++ API: class mrpt::poses::CPoint2D

CPoint2D(x: float, y: float) CPoint2D(other: CPoint2D)

Bases: mrpt.serialization.CSerializable

A class used to store a 2D point.

x: float
y: float
asString() → str

Returns a text representation, e.g. “[0.02 1.04]”.

asTPoint() → mrpt.math.TPoint2D

Convert to lightweight mrpt.math.TPoint2D

static fromTPoint(arg0: mrpt.math.TPoint2D) → CPoint2D

Construct CPoint2D from a lightweight mrpt.math.TPoint2D

class mrpt.poses.CPoint3D

C++ API: class mrpt::poses::CPoint3D

CPoint3D(x: float, y: float, z: float) CPoint3D(other: CPoint3D)

Bases: mrpt.serialization.CSerializable

A class used to store a 3D point.

x: float
y: float
z: float
asString() → str

Returns a text representation, e.g. “[0.02 1.04 -0.80]”.

asTPoint() → mrpt.math.TPoint3D

Convert to lightweight mrpt.math.TPoint3D

static fromTPoint(arg0: mrpt.math.TPoint3D) → CPoint3D

Construct CPoint3D from a lightweight mrpt.math.TPoint3D

class mrpt.poses.CPose2D

C++ API: class mrpt::poses::CPose2D

CPose2D(x: float, y: float, phi: float) CPose2D(p: CPose3D) CPose2D(p: mrpt.math.TPose2D) CPose2D(other: CPose2D)

Bases: mrpt.serialization.CSerializable

SE(2) rigid-body pose (x, y, phi).

property phi: float

Phi orientation (radians)

property x: float

X coordinate

property y: float

Y coordinate

asString() → str

Returns human-readable string [x y phi]

asTPose() → mrpt.math.TPose2D

Convert to lightweight mrpt.math.TPose2D

composePoint(l: mrpt.math.TPoint2D) → mrpt.math.TPoint2D
composePoint(lx: float, ly: float) → mrpt.math.TPoint2D
composePoint(l: mrpt.math.TPoint3D) → mrpt.math.TPoint3D

Transforms a 3D point from the local frame of this pose into the global frame (z is not modified).

fromString(arg0: str) → None

Set value from string

static fromTPose(arg0: mrpt.math.TPose2D) → CPose2D

Construct CPose2D from a lightweight mrpt.math.TPose2D

inverse() → CPose2D

Returns the inverse pose as a new object (same as -p), without modifying this one. Note that CPose3D.inverse() works in place instead.

inverseComposePoint(g: mrpt.math.TPoint2D) → mrpt.math.TPoint2D
inverseComposePoint(gx: float, gy: float) → mrpt.math.TPoint2D

Transforms a point (x, y) from the global frame into the local frame of this pose.

norm() → float

Returns the norm of the (x,y) vector

normalizePhi() → None

Forces phi to be in [-pi,pi]

class mrpt.poses.CPose2DInterpolator

C++ API: class mrpt::poses::CPose2DInterpolator

CPose2DInterpolator(other: CPose2DInterpolator)

Bases: mrpt.serialization.CSerializable

A time-stamped trajectory in SE(2), with interpolation between poses.

clear() → None

Clears the current sequence of poses.

empty() → bool

Returns true if the trajectory has no poses.

getInterpolationMethod() → TInterpolatorMethod

Returns the current interpolation method.

insert(arg0: datetime.timedelta, arg1: mrpt.math.TPose2D) → None

Inserts a new pose in the sequence. It overwrites any previously existing pose at exactly the same time.

interpolate(arg0: datetime.timedelta) → tuple

Returns (TPose2D, valid): interpolated pose at given time

setInterpolationMethod(method: TInterpolatorMethod) → None

Sets the interpolation method (default: imLinearSlerp).

size() → int

Returns the number of poses in the trajectory.

class mrpt.poses.CPose3D

C++ API: class mrpt::poses::CPose3D

CPose3D(x: float, y: float, z: float, yaw: float = 0, pitch: float = 0, roll: float = 0) CPose3D(arg0: CPose2D) CPose3D(p: mrpt.math.TPose3D) CPose3D(other: CPose3D)

Bases: mrpt.serialization.CSerializable

SE(3) rigid-body pose (x, y, z, yaw, pitch, roll), with a cached rotation matrix.

property x: float

X coordinate

property y: float

Y coordinate

property z: float

Z coordinate

pitch: float
roll: float
yaw: float
static FromTranslation(arg0: float, arg1: float, arg2: float) → CPose3D

Builds a pose with a translation without rotation.

static FromXYZYawPitchRoll(arg0: float, arg1: float, arg2: float, arg3: float, arg4: float, arg5: float) → CPose3D

Builds a pose from a translation (x,y,z) in meters and (yaw,pitch,roll) angles in radians.

static FromYawPitchRoll(arg0: float, arg1: float, arg2: float) → CPose3D

Builds a pose with a null translation and (yaw,pitch,roll) angles in radians.

asString() → str

Returns a human-readable textual representation of the object (eg: “[x y z yaw pitch roll]”, angles in degrees.)

asTPose() → mrpt.math.TPose3D

Convert to lightweight mrpt.math.TPose3D

composePoint(arg0: mrpt.math.TPoint3D) → mrpt.math.TPoint3D
composePoint(arg0: float, arg1: float, arg2: float) → mrpt.math.TPoint3D

Transforms a point (x, y, z) from the local frame of this pose into the global frame.

static fromTPose(arg0: mrpt.math.TPose3D) → CPose3D

Construct CPose3D from a lightweight mrpt.math.TPose3D

getHomogeneousMatrix() → mrpt.math.CMatrixDouble44

Returns the 4x4 homogeneous transformation matrix

getInverseHomogeneousMatrix() → mrpt.math.CMatrixDouble44

Returns the corresponding 4x4 inverse homogeneous transformation matrix for this point or pose.

getOppositeScalar() → CPose3D

Return the opposite of the current pose instance by taking the negative of all its components individually.

getRotationMatrix() → mrpt.math.CMatrixDouble33

Returns the 3x3 Rotation Matrix

getYawPitchRoll() → tuple[float, float, float]

Returns (yaw, pitch, roll) as a tuple in radians

inverse() → None

Inverts this pose in place and returns None. Use -p to get the inverse as a new pose instead (note that CPose2D.inverse() returns a new pose).

inverseComposePoint(arg0: mrpt.math.TPoint3D) → mrpt.math.TPoint3D
inverseComposePoint(arg0: float, arg1: float, arg2: float) → mrpt.math.TPoint3D

Transforms a point (x, y, z) from the global frame into the local frame of this pose.

setFromValues(arg0: float, arg1: float, arg2: float, arg3: float, arg4: float, arg5: float) → None

Sets the pose from a position (meters) and yaw, pitch, roll angles (radians).

setRotationMatrix(arg0: mrpt.math.CMatrixDouble33) → None

Sets the 3x3 rotation matrix.

setYawPitchRoll(arg0: float, arg1: float, arg2: float) → None

Sets the three rotation angles, in radians.

class mrpt.poses.CPose3DInterpolator

C++ API: class mrpt::poses::CPose3DInterpolator

CPose3DInterpolator(other: CPose3DInterpolator)

Bases: mrpt.serialization.CSerializable

A time-stamped trajectory in SE(3), with interpolation between poses.

clear() → None

Clears the current sequence of poses.

empty() → bool

Returns true if the trajectory has no poses.

getInterpolationMethod() → TInterpolatorMethod

Returns the current interpolation method.

insert(arg0: datetime.timedelta, arg1: mrpt.math.TPose3D) → None

Inserts a new pose in the sequence. It overwrites any previously existing pose at exactly the same time.

interpolate(arg0: datetime.timedelta) → tuple

Returns (TPose3D, valid): interpolated pose at given time

setInterpolationMethod(method: TInterpolatorMethod) → None

Sets the interpolation method (default: imLinearSlerp).

size() → int

Returns the number of poses in the trajectory.

class mrpt.poses.CPose3DPDF

C++ API: class mrpt::poses::CPose3DPDF

Bases: mrpt.serialization.CSerializable

Base class of probability density functions (PDFs) of a 3D pose.

getCovariance() → mrpt.math.CMatrixDouble66

Returns the 6x6 covariance matrix

getCovarianceAndMean() → tuple

Returns the tuple (cov: CMatrixDouble66, mean: CPose3D)

getMean() → CPose3D

Returns the mean (expected value) of the distribution

saveToTextFile(file: str) → bool

Saves the distribution to a text file. Returns False on error.

class mrpt.poses.CPose3DPDFGaussian

C++ API: class mrpt::poses::CPose3DPDFGaussian

CPose3DPDFGaussian(arg0: CPose3D) CPose3DPDFGaussian(arg0: CPose3D, arg1: mrpt.math.CMatrixDouble66) CPose3DPDFGaussian(other: CPose3DPDFGaussian)

Bases: CPose3DPDF

A PDF of a 3D pose as a Gaussian with a mean and a 6x6 covariance matrix.

cov: mrpt.math.CMatrixDouble66
mean: CPose3D
changeCoordinatesReference(newReferenceBase: CPose3D) → None

Makes this = newReferenceBase (+) this, for a reference pose without uncertainty.

drawSingleSample() → CPose3D

Draws a single sample from the Gaussian distribution and returns it as a CPose3D.

evaluateNormalizedPDF(arg0: CPose3D) → float

Evaluates the ratio PDF(x) / PDF(MEAN), that is, the normalized PDF in the range [0,1].

evaluatePDF(arg0: CPose3D) → float

Evaluates the PDF at a given point.

inverse() → CPose3DPDFGaussian

Returns the PDF of the inverse pose, (0,0,0) (-) this, as a new object (same as -pdf). This PDF is not modified.

saveToTextFile(arg0: str) → bool

Saves the mean and covariance to a text file.

class mrpt.poses.CPose3DPDFGaussianInf

C++ API: class mrpt::poses::CPose3DPDFGaussianInf

CPose3DPDFGaussianInf(arg0: CPose3D) CPose3DPDFGaussianInf(mean: CPose3D, inf_matrix: mrpt.math.CMatrixDouble66) CPose3DPDFGaussianInf(other: CPose3DPDFGaussianInf)

Bases: CPose3DPDF

A PDF of a 3D pose as a Gaussian with a mean and a 6x6 information (inverse covariance) matrix.

cov_inv: mrpt.math.CMatrixDouble66
mean: CPose3D
drawSingleSample() → CPose3D

Draws a single sample from the distribution and returns it as a CPose3D.

isInfType() → bool

Returns whether the class instance holds the uncertainty in covariance or information form.

class mrpt.poses.CPose3DPDFParticles(M: int = 1)

C++ API: class mrpt::poses::CPose3DPDFParticles

CPose3DPDFParticles(other: CPose3DPDFParticles)

Bases: CPose3DPDF, mrpt.bayes.CParticleFilterCapable

A PDF of a 3D pose, as a set of weighted samples (particles).

drawSingleSample() → CPose3D

Draws one sample from the distribution (weights must be normalized).

getMostLikelyParticle() → mrpt.math.TPose3D

Returns the particle with the highest weight.

getParticlePose(i: int) → mrpt.math.TPose3D

Returns the pose of the i’th particle.

getParticlesAsNumpy() → numpy.ndarray

Returns all particles as an Nx7 array with columns (x, y, z, yaw, pitch, roll, log_weight)

resetDeterministic(location: mrpt.math.TPose3D, particlesCount: int = 0) → None

Sets all particles to the given pose (particlesCount=0 keeps the count)

resetUniform(corner_min: mrpt.math.TPose3D, corner_max: mrpt.math.TPose3D, particlesCount: int = -1) → None

Spreads particles uniformly between two TPose3D corners

size() → int

Returns the number of particles.

class mrpt.poses.CPose3DQuat

C++ API: class mrpt::poses::CPose3DQuat

CPose3DQuat(arg0: CPose3D) CPose3DQuat(p: mrpt.math.TPose3DQuat) CPose3DQuat(other: CPose3DQuat)

Bases: mrpt.serialization.CSerializable

A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).

quat: mrpt.math.CQuaternionDouble
x: float
y: float
z: float
asString() → str

Returns a human-readable textual representation of the object as: “[x y z qw qx qy qz]”.

asTPose() → mrpt.math.TPose3DQuat

Convert to lightweight mrpt.math.TPose3DQuat

static fromTPose(arg0: mrpt.math.TPose3DQuat) → CPose3DQuat

Construct CPose3DQuat from a lightweight mrpt.math.TPose3DQuat

norm() → float

Returns the Euclidean norm of the translation part.

class mrpt.poses.CPosePDF

C++ API: class mrpt::poses::CPosePDF

Bases: mrpt.serialization.CSerializable

Base class of probability density functions (PDFs) of a 2D pose (x, y, phi).

getCovariance() → mrpt.math.CMatrixDouble33

Returns the 3x3 covariance matrix

getCovarianceAndMean() → tuple

Returns the tuple (cov: CMatrixDouble33, mean: CPose2D)

getMean() → CPose2D

Returns the mean (expected value) of the distribution

saveToTextFile(file: str) → bool

Saves the distribution to a text file. Returns False on error.

class mrpt.poses.CPosePDFGaussian

C++ API: class mrpt::poses::CPosePDFGaussian

CPosePDFGaussian(arg0: CPose2D) CPosePDFGaussian(arg0: CPose2D, arg1: mrpt.math.CMatrixDouble33) CPosePDFGaussian(other: CPosePDFGaussian)

Bases: CPosePDF

A PDF of a 2D pose as a Gaussian with a mean and a 3x3 covariance matrix.

cov: mrpt.math.CMatrixDouble33
mean: CPose2D
changeCoordinatesReference(newReferenceBase: CPose2D) → None
changeCoordinatesReference(newReferenceBase: CPose3D) → None

Makes this = newReferenceBase (+) this, using the 2D part of a 3D reference pose.

drawSingleSample() → CPose2D

Draw a single sample from the Gaussian distribution

evaluateNormalizedPDF(arg0: CPose2D) → float

Evaluates the ratio PDF(x) / PDF(MEAN), that is, the normalized PDF in the range [0,1].

evaluatePDF(arg0: CPose2D) → float

Evaluates the PDF at a given point.

inverse() → CPosePDFGaussian

Returns the PDF of the inverse pose, (0,0,0) (-) this, as a new object. This PDF is not modified.

inverseComposition(x: CPosePDFGaussian, ref: CPosePDFGaussian) → None
inverseComposition(x1: CPosePDFGaussian, x0: CPosePDFGaussian, COV_01: mrpt.math.CMatrixDouble33) → None

Sets this = x1 (-) x0, given the 3x3 cross-covariance COV_01 = E[(x0-m0)(x1-m1)^T].

class mrpt.poses.CPosePDFGaussianInf

C++ API: class mrpt::poses::CPosePDFGaussianInf

CPosePDFGaussianInf(arg0: CPose2D) CPosePDFGaussianInf(mean: CPose2D, inf_matrix: mrpt.math.CMatrixDouble33) CPosePDFGaussianInf(other: CPosePDFGaussianInf)

Bases: CPosePDF

A PDF of a 2D pose as a Gaussian with a mean and a 3x3 information (inverse covariance) matrix.

cov_inv: mrpt.math.CMatrixDouble33
mean: CPose2D
drawSingleSample() → CPose2D

Draws a single sample from the distribution.

class mrpt.poses.CPosePDFParticles(M: int = 1)

C++ API: class mrpt::poses::CPosePDFParticles

CPosePDFParticles(other: CPosePDFParticles)

Bases: CPosePDF, mrpt.bayes.CParticleFilterCapable

A PDF of a 2D pose, as a set of weighted samples (particles).

clear() → None

Removes all particles.

drawSingleSample() → CPose2D

Draws one sample from the distribution (weights must be normalized).

getMostLikelyParticle() → mrpt.math.TPose2D

Returns the particle with the highest weight.

getParticlePose(i: int) → mrpt.math.TPose2D

Returns the pose of the i’th particle.

getParticlesAsNumpy() → numpy.ndarray

Returns all particles as an Nx4 array with columns (x, y, phi, log_weight)

resetAroundSetOfPoses(list_poses: list[mrpt.math.TPose2D], num_particles_per_pose: int, spread_x: float, spread_y: float, spread_phi_rad: float) → None

Resets the particles around a set of poses (x, y, phi), with a given number of particles per pose and spread.

resetDeterministic(location: mrpt.math.TPose2D, particlesCount: int = 0) → None

Sets all particles to the given pose (particlesCount=0 keeps the count)

resetUniform(x_min: float, x_max: float, y_min: float, y_max: float, phi_min: float = -3.141592653589793, phi_max: float = 3.141592653589793, particlesCount: int = -1) → None

Spreads particles uniformly in [x_min,x_max]x[y_min,y_max]x[phi_min,phi_max]

size() → int

Returns the number of particles.

class mrpt.poses.CPosePDFSOG(nModes: int = 1)

C++ API: class mrpt::poses::CPosePDFSOG

CPosePDFSOG(other: CPosePDFSOG)

Bases: CPosePDF

A PDF of a 2D pose as a Sum of Gaussians (SOG): a set of weighted Gaussian modes.

class TGaussianMode

One mode of a CPosePDFSOG.

property cov: mrpt.math.CMatrixDouble33

3x3 covariance matrix.

property log_w: float

Logarithm of the weight of the mode.

property mean: CPose2D

Mean of the mode (CPose2D).

clear() → None

Removes all the modes.

empty() → bool

Returns true if there are no modes.

evaluateNormalizedPDF(x: CPose2D) → float

Evaluates the ratio PDF(x) / max(PDF), in the range [0,1].

evaluatePDF(x: CPose2D, sumOverAllPhis: bool = False) → float

Evaluates the PDF at a given pose.

get(i: int) → CPosePDFSOG

Returns a reference to the i’th mode.

getMostLikelyCovarianceAndMean() → tuple

Returns the tuple (cov: CMatrixDouble33, mean: CPose2D) of the mode with the highest weight.

mergeModes(max_KLd: float = 0.5, verbose: bool = False) → None

Merges very close modes, up to a maximum Kullback-Leibler distance.

normalizeWeights() → None

Normalizes the weights of the modes, so that they sum up to one.

push_back(mode: CPosePDFSOG) → None

Appends a mode (TGaussianMode).

resize(N: int) → None

Sets the number of modes.

size() → int

Returns the number of modes.

class mrpt.poses.CPoseRandomSampler

C++ API: class mrpt::poses::CPoseRandomSampler

An efficient generator of random samples drawn from a given 2D (CPosePDF) or 3D (CPose3DPDF) pose probability density function (pdf).

drawSample2D() → CPose2D

Draw a 2D pose sample

drawSample3D() → CPose3D

Draw a 3D pose sample

setPosePDF(arg0: CPosePDF) → None
setPosePDF(arg0: CPose3DPDF) → None

Sets the 3D pose PDF to draw samples from.

class mrpt.poses.SE_average2

Computes the (optionally weighted) average of a set of SE(2) poses.

append(arg0: CPose2D) → None
append(arg0: CPose2D, arg1: float) → None

Adds a pose with the given weight.

clear() → None

Resets the accumulated poses.

get_average() → CPose2D

Returns the calculated average pose.

class mrpt.poses.SE_average3

Computes the (optionally weighted) average of a set of SE(3) poses.

append(arg0: CPose3D) → None
append(arg0: CPose3D, arg1: float) → None

Adds a pose with the given weight.

clear() → None

Resets the accumulated poses.

get_average() → CPose3D

Returns the calculated average pose.

class mrpt.poses.TInterpolatorMethod(value: int)

Interpolation method of CPose2DInterpolator and CPose3DInterpolator. In 3D, all methods but the Slerp ones interpolate yaw, pitch and roll independently.

Members:

imSpline : Spline interpolation using 4 points (2 before and 2 after the query time).

imLinear2Neig : Linear interpolation between the previous and next neighbors.

imLinear4Neig : Linear fit of the 4 closest points (2 before and 2 after the query time).

imSSLLLL : Spline for x and y, linear least squares for z, yaw, pitch and roll.

imSSLSLL : Spline for x, y and yaw, linear least squares for z, pitch and roll.

imLinearSlerp : Linear for x, y and z, Slerp for the rotation (the default).

imSplineSlerp : Spline for x, y and z (as imSpline), Slerp for the rotation.

property name: str
property value: int
imLinear2Neig: ClassVar[TInterpolatorMethod]
imLinear4Neig: ClassVar[TInterpolatorMethod]
imLinearSlerp: ClassVar[TInterpolatorMethod]
imSSLLLL: ClassVar[TInterpolatorMethod]
imSSLSLL: ClassVar[TInterpolatorMethod]
imSpline: ClassVar[TInterpolatorMethod]
imSplineSlerp: ClassVar[TInterpolatorMethod]
mrpt.poses.imLinear2Neig: _bindings.TInterpolatorMethod
mrpt.poses.imLinear4Neig: _bindings.TInterpolatorMethod
mrpt.poses.imLinearSlerp: _bindings.TInterpolatorMethod
mrpt.poses.imSSLLLL: _bindings.TInterpolatorMethod
mrpt.poses.imSSLSLL: _bindings.TInterpolatorMethod
mrpt.poses.imSpline: _bindings.TInterpolatorMethod
mrpt.poses.imSplineSlerp: _bindings.TInterpolatorMethod