RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
rtabmap::Transform Class Reference

Represents a 3D rigid body transformation (rotation + translation). More...

#include <Transform.h>

Public Member Functions

 Transform ()
 Default constructor. Initializes to a null (all zeros) transform.
 
 Transform (float r11, float r12, float r13, float o14, float r21, float r22, float r23, float o24, float r31, float r32, float r33, float o34)
 Constructor from rotation matrix elements and translation components.
 
 Transform (const cv::Mat &transformationMatrix)
 Constructs a Transform from a 3x4 OpenCV matrix.
 
 Transform (float x, float y, float z, float roll, float pitch, float yaw)
 Constructs a Transform from position and Euler angles (in radians).
 
 Transform (float x, float y, float z, float qx, float qy, float qz, float qw)
 Constructs a Transform from position and quaternion.
 
 Transform (float x, float y, float theta)
 Constructs a 2D Transform (x, y, theta).
 
Transform clone () const
 Returns a deep copy of the transform.
 
float r11 () const
 Rotation matrix element at row 1, col 1.
 
float r12 () const
 
float r13 () const
 
float r21 () const
 
float r22 () const
 
float r23 () const
 
float r31 () const
 
float r32 () const
 
float r33 () const
 
float o14 () const
 Translation x.
 
float o24 () const
 Translation y.
 
float o34 () const
 Translation z.
 
float & operator[] (int index)
 
const float & operator[] (int index) const
 
float & operator() (int row, int col)
 
const float & operator() (int row, int col) const
 
bool isNull () const
 Checks whether the transform is null (all zeros).
 
bool isIdentity () const
 Checks whether the transform is identity.
 
void setNull ()
 Sets the transform to null (zero matrix).
 
void setIdentity ()
 Sets the transform to the identity transform.
 
const cv::Mat & dataMatrix () const
 Returns the internal OpenCV matrix (3x4).
 
const float * data () const
 Returns a pointer to the raw data (12 floats).
 
float * data ()
 
int size () const
 Returns the number of float elements (always 12).
 
float & x ()
 Translation getters/setters.
 
float & y ()
 Translation y.
 
float & z ()
 Translation z.
 
const float & x () const
 
const float & y () const
 
const float & z () const
 
float theta () const
 Returns 2D orientation (theta) in radians.
 
bool isInvertible () const
 Returns whether the transform is invertible.
 
Transform inverse () const
 Returns the inverse of the transform.
 
Transform rotation () const
 Returns only the rotation component.
 
Transform translation () const
 Returns only the translation component.
 
Transform to3DoF () const
 Converts to 3 DoF (x, y, theta).
 
Transform to4DoF () const
 Converts to 4 DoF (x, y, z, yaw).
 
bool is3DoF () const
 Checks if the transform is 3 DoF (no pitch/roll).
 
bool is4DoF () const
 Checks if the transform is 4 DoF (no pitch).
 
cv::Mat rotationMatrix () const
 Returns the 3x3 rotation matrix (cv::Mat).
 
cv::Mat translationMatrix () const
 Returns the 3x1 translation matrix (cv::Mat).
 
void getTranslationAndEulerAngles (float &x, float &y, float &z, float &roll, float &pitch, float &yaw) const
 Extracts translation and Euler angles (radians).
 
void getEulerAngles (float &roll, float &pitch, float &yaw) const
 Extracts Euler angles (roll, pitch, yaw).
 
void getTranslation (float &x, float &y, float &z) const
 Extracts translation only.
 
float getAngle (const Transform &t) const
 Returns angular difference (in radians) with another transform.
 
float getNorm () const
 Returns the Euclidean norm of the translation vector.
 
float getNormSquared () const
 Returns the squared norm of the translation vector.
 
float getDistance (const Transform &t) const
 Returns the Euclidean distance to another transform.
 
float getDistanceSquared (const Transform &t) const
 Returns the squared distance to another transform.
 
Transform interpolate (float t, const Transform &other) const
 Interpolates between this and another transform.
 
void normalizeRotation ()
 Normalizes the rotation matrix.
 
std::string prettyPrint () const
 Returns a string representation of the transform.
 
Transform operator* (const Transform &t) const
 Operator overloads.
 
Transformoperator*= (const Transform &t)
 
bool operator== (const Transform &t) const
 
bool operator!= (const Transform &t) const
 
Eigen::Matrix4f toEigen4f () const
 
Eigen::Matrix4d toEigen4d () const
 
Eigen::Affine3f toEigen3f () const
 
Eigen::Affine3d toEigen3d () const
 
Eigen::Quaternionf getQuaternionf () const
 
Eigen::Quaterniond getQuaterniond () const
 

Static Public Member Functions

static Transform getIdentity ()
 Returns identity transform.
 
static Transform fromEigen4f (const Eigen::Matrix4f &matrix)
 Converts from Eigen representations.
 
static Transform fromEigen4d (const Eigen::Matrix4d &matrix)
 
static Transform fromEigen3f (const Eigen::Affine3f &matrix)
 
static Transform fromEigen3d (const Eigen::Affine3d &matrix)
 
static Transform fromEigen3f (const Eigen::Isometry3f &matrix)
 
static Transform fromEigen3d (const Eigen::Isometry3d &matrix)
 
static Transform fromEigen3f (const Eigen::Matrix< float, 3, 4 > &matrix)
 
static Transform fromEigen3d (const Eigen::Matrix< double, 3, 4 > &matrix)
 
static Transform opengl_T_rtabmap ()
 Returns the transform from RTAB-Map to OpenGL coordinate system.
 
static Transform rtabmap_T_opengl ()
 Returns the transform from OpenGL to RTAB-Map coordinate system.
 
static Transform fromString (const std::string &string)
 Parses a transform from a string representation. Supported formats:
 
static bool canParseString (const std::string &string)
 Checks if a string can be parsed into a transform.
 
static Transform getTransform (const std::map< double, Transform > &tfBuffer, const double &stamp)
 Retrieves the transform to a given timestamp.
 
static RTABMAP_DEPRECATED Transform getClosestTransform (const std::map< double, Transform > &tfBuffer, const double &stamp, double *stampDiff)
 

Detailed Description

Represents a 3D rigid body transformation (rotation + translation).

This class provides an abstraction over 3D transformations using a 3x4 matrix representation, with utilities for conversion to/from Eigen and OpenCV formats, interpolation, inversion, DoF reduction, and distance calculations. It is fundamental to pose estimation and motion handling within the RTAB-Map framework.

The underlying data is stored in a cv::Mat (3x4, CV_32FC1), representing a rotation matrix and translation vector.

Definition at line 52 of file Transform.h.

Constructor & Destructor Documentation

◆ Transform() [1/4]

rtabmap::Transform::Transform ( float  r11,
float  r12,
float  r13,
float  o14,
float  r21,
float  r22,
float  r23,
float  o24,
float  r31,
float  r32,
float  r33,
float  o34 
)

Constructor from rotation matrix elements and translation components.

Parameters
r11...r33Rotation matrix components.
o14,o24,o34Translation vector components.

◆ Transform() [2/4]

rtabmap::Transform::Transform ( const cv::Mat &  transformationMatrix)

Constructs a Transform from a 3x4 OpenCV matrix.

Parameters
transformationMatrixA 3x4 CV_32FC1 matrix.

◆ Transform() [3/4]

rtabmap::Transform::Transform ( float  x,
float  y,
float  z,
float  roll,
float  pitch,
float  yaw 
)

Constructs a Transform from position and Euler angles (in radians).

Parameters
x,y,zTranslation components.
roll,pitch,yawEuler rotation angles (ZYX-convention).

◆ Transform() [4/4]

rtabmap::Transform::Transform ( float  x,
float  y,
float  z,
float  qx,
float  qy,
float  qz,
float  qw 
)

Constructs a Transform from position and quaternion.

Parameters
x,y,zTranslation components.
qx,qy,qz,qwQuaternion rotation components.

Member Function Documentation

◆ r11()

float rtabmap::Transform::r11 ( ) const
inline

Rotation matrix element at row 1, col 1.

Definition at line 96 of file Transform.h.

◆ r12()

float rtabmap::Transform::r12 ( ) const
inline

Definition at line 97 of file Transform.h.

◆ r13()

float rtabmap::Transform::r13 ( ) const
inline

Definition at line 98 of file Transform.h.

◆ r21()

float rtabmap::Transform::r21 ( ) const
inline

Definition at line 99 of file Transform.h.

◆ r22()

float rtabmap::Transform::r22 ( ) const
inline

Definition at line 100 of file Transform.h.

◆ r23()

float rtabmap::Transform::r23 ( ) const
inline

Definition at line 101 of file Transform.h.

◆ r31()

float rtabmap::Transform::r31 ( ) const
inline

Definition at line 102 of file Transform.h.

◆ r32()

float rtabmap::Transform::r32 ( ) const
inline

Definition at line 103 of file Transform.h.

◆ r33()

float rtabmap::Transform::r33 ( ) const
inline

Definition at line 104 of file Transform.h.

◆ o14()

float rtabmap::Transform::o14 ( ) const
inline

Translation x.

Definition at line 106 of file Transform.h.

◆ o24()

float rtabmap::Transform::o24 ( ) const
inline

Translation y.

Definition at line 107 of file Transform.h.

◆ o34()

float rtabmap::Transform::o34 ( ) const
inline

Translation z.

Definition at line 108 of file Transform.h.

◆ operator[]() [1/2]

float & rtabmap::Transform::operator[] ( int  index)
inline

Definition at line 110 of file Transform.h.

◆ operator[]() [2/2]

const float & rtabmap::Transform::operator[] ( int  index) const
inline

Definition at line 111 of file Transform.h.

◆ operator()() [1/2]

float & rtabmap::Transform::operator() ( int  row,
int  col 
)
inline

Definition at line 112 of file Transform.h.

◆ operator()() [2/2]

const float & rtabmap::Transform::operator() ( int  row,
int  col 
) const
inline

Definition at line 113 of file Transform.h.

◆ dataMatrix()

const cv::Mat & rtabmap::Transform::dataMatrix ( ) const
inline

Returns the internal OpenCV matrix (3x4).

Definition at line 136 of file Transform.h.

◆ data() [1/2]

const float * rtabmap::Transform::data ( ) const
inline

Returns a pointer to the raw data (12 floats).

Definition at line 140 of file Transform.h.

◆ data() [2/2]

float * rtabmap::Transform::data ( )
inline

Definition at line 141 of file Transform.h.

◆ size()

int rtabmap::Transform::size ( ) const
inline

Returns the number of float elements (always 12).

Definition at line 146 of file Transform.h.

◆ x() [1/2]

float & rtabmap::Transform::x ( )
inline

Translation getters/setters.

Translation x

Definition at line 149 of file Transform.h.

◆ y() [1/2]

float & rtabmap::Transform::y ( )
inline

Translation y.

Definition at line 150 of file Transform.h.

◆ z() [1/2]

float & rtabmap::Transform::z ( )
inline

Translation z.

Definition at line 151 of file Transform.h.

◆ x() [2/2]

const float & rtabmap::Transform::x ( ) const
inline

Definition at line 152 of file Transform.h.

◆ y() [2/2]

const float & rtabmap::Transform::y ( ) const
inline

Definition at line 153 of file Transform.h.

◆ z() [2/2]

const float & rtabmap::Transform::z ( ) const
inline

Definition at line 154 of file Transform.h.

◆ interpolate()

Transform rtabmap::Transform::interpolate ( float  t,
const Transform other 
) const

Interpolates between this and another transform.

Parameters
tInterpolation factor [0, 1].
otherTarget transform.

◆ opengl_T_rtabmap()

static Transform rtabmap::Transform::opengl_T_rtabmap ( )
inlinestatic

Returns the transform from RTAB-Map to OpenGL coordinate system.

Note
Coordinate systems:
  • OpenGL: x → right, y → up, z → out of the screen (toward viewer).
  • RTAB-Map: x → forward, y → left, z → up.

Definition at line 289 of file Transform.h.

◆ rtabmap_T_opengl()

static Transform rtabmap::Transform::rtabmap_T_opengl ( )
inlinestatic

Returns the transform from OpenGL to RTAB-Map coordinate system.

Note
Coordinate systems:
  • OpenGL: x → right, y → up, z → out of the screen (toward viewer).
  • RTAB-Map: x → forward, y → left, z → up.

Definition at line 299 of file Transform.h.

◆ fromString()

static Transform rtabmap::Transform::fromString ( const std::string &  string)
static

Parses a transform from a string representation. Supported formats:

  • (3 values) "x y z"
  • (6 values) "x y z roll pitch yaw" (ZYX-Euler convention)
  • (7 values) "x y z qx qy qz qw"
  • (9 values, 3x3 rotation) "r11 r12 r13 r21 r22 r23 r31 r32 r33"

(12 values, 3x4 rotation) "r11 r12 r13 tx r21 r22 r23 ty r31 r32 r33 tz"

◆ getTransform()

static Transform rtabmap::Transform::getTransform ( const std::map< double, Transform > &  tfBuffer,
const double &  stamp 
)
static

Retrieves the transform to a given timestamp.

Parameters
tfBufferBuffer of timestamped transforms.
stampRequested timestamp.
Returns
transform at the requested timestamp, interpolated if it doesn't fall on a transform with the exact same timestamp in the buffer. If the timestamp is older than the oldest timestamp or newer than the latest timestamp in the buffer, a null transform is returned and a warning message is generated.

◆ getClosestTransform()

static RTABMAP_DEPRECATED Transform rtabmap::Transform::getClosestTransform ( const std::map< double, Transform > &  tfBuffer,
const double &  stamp,
double *  stampDiff 
)
static

The documentation for this class was generated from the following file: