Class SpatialInertia#

Class Documentation#

class SpatialInertia#

Represents the spatial inertia. This is a 6x6 matrix with 10 independent quantities. These are given by the mass (scalar), center of mass offset (3-vector), and inertia 3x3 symmetric matrix (6 independent values).

They are used to define the relative pose of pairs for frames. See structure of a spatial inertia for the definition of a spatial inertia.

Public Functions

SpatialInertia()#

Default constructor. Initializes all members to zero.

void uninitialize()#

Mark this SpatialInertia as uninitialized.

bool isInitialized() const#

Check whether this SpatialInertia is initialized.

Returns:

True if initialized, false otherwise.

SpatialInertia(double mass, const Vec3 &body_to_cm, const Mat33 &inertia, bool validate = true)#

Constructor that sets mass, center of mass offset, and inertia matrix.

Parameters:
  • mass – Mass of the object.

  • body_to_cm – Vector from the body frame to the center of mass.

  • inertia – Inertia matrix in the body frame.

  • validate – Verify that the values lead to a symmetric, positive semi-definite CM inertia

SpatialInertia(const SpatialInertia &other)#

Copy constructor.

Parameters:

other – Other SpatialInertia to copy from.

void setZero()#

Zero out the spatial inertia.

SpatialInertia &operator=(const SpatialInertia &other)#

Copy assignment operator.

Parameters:

other – Other SpatialInertia to copy from.

Returns:

Reference to this object.

SpatialInertia(SpatialInertia &&other) noexcept#

Move constructor.

Parameters:

otherSpatialInertia to move from.

SpatialInertia &operator=(SpatialInertia &&other) noexcept#

Move assignment operator.

Parameters:

otherSpatialInertia to move from.

Returns:

Reference to this object.

SpatialInertia operator+(const SpatialInertia &other) const#

Add SpatialInertias. The two SpatialInertias are assumed to be about a common frame.

Parameters:

other – The SpatialInertia to add to this one.

Returns:

Resultant SpatialInertia.

SpatialInertia operator-(const SpatialInertia &other) const#

Subtract SpatialInertias. The two SpatialInertias are assumed to be about a common frame.

Parameters:

other – The SpatialInertia to subtract from this one.

Returns:

Resultant SpatialInertia.

SpatialInertia &operator+=(const SpatialInertia &other)#

Add another SpatialInertia to this one in-place. The two SpatialInertias are assumed to be about a common frame.

Parameters:

other – The SpatialInertia to add to this one.

Returns:

Reference to this SpatialInertia.

SpatialInertia &operator-=(const SpatialInertia &other)#

Subtract another SpatialInertia from this one in-place. The two SpatialInertias are assumed to be about a common frame.

Parameters:

other – The SpatialInertia to subtract from this one.

Returns:

Reference to this SpatialInertia.

bool operator==(const SpatialInertia &other) const#

Equality operator.

Parameters:

otherSpatialInertia to compare with.

Returns:

True if equal, false otherwise.

bool isApprox(const SpatialInertia &other, double prec = MATH_EPSILON)#

Approximate equality check.

Parameters:
  • otherSpatialInertia to compare with.

  • prec – Precision threshold.

Returns:

True if approximately equal, false otherwise.

std::string_view typeString() const#

Returns the type name of the object.

Returns:

A string representing the type name of the object.

double mass() const#

Returns the mass of the object.

Returns:

The mass of the object.

const Vec3 &bodyToCm() const#

Returns the vector from the body frame to the center of mass.

Returns:

The vector from the body frame to the center of mass.

const Vec3 &mp() const#

Returns the body_to_cm * mass.

Returns:

The mass * body_to_cm.

const Mat33 &inertia() const#

Returns the inertia matrix in the body frame.

Returns:

The inertia matrix in the body frame.

const Mat33 &cmInertia() const#

Returns the inertia matrix about the center of mass.

Returns:

The inertia matrix about the center of mass.

std::string dumpString(std::string_view prefix = "", unsigned int precision = 10, bool exponential = false) const#

Get a string representation of this SpatialInertia.

Parameters:
  • prefix – String prefix for each line.

  • precision – Number of digits to use for floating point values.

  • exponential – Use exponential notation if true.

Returns:

String with information about this SpatialInertia.

void dump(std::string_view prefix = "", unsigned int precision = 10, bool exponential = false) const#

Print dumpString to std::cout.

Parameters:
  • prefix – String prefix for each line.

  • precision – Number of digits to use for floating point values.

  • exponential – Use exponential notation if true.

SpatialVector operator*(const SpatialVector &vec) const#

Multiplies the spatial inertia with a spatial vector.

Parameters:

vec – The spatial vector to multiply.

Returns:

The resulting spatial vector after multiplication.

const Mat66 &matrix() const#

Returns the 6x6 matrix representation of the spatial inertia.

Returns:

The 6x6 matrix representation of the spatial inertia.

const SpatialInertia parallelAxis(const HomTran &T) const#

Calculates the a new spatial inertia using the parallel axis theorem.

This method computes spI(x) = \phi(x,y) * spI(y) * \phi^*(x,y) where \phi(x,y) is associated with the T(x,y) homogeneous transform

Parameters:

T – Homogeneous transformation T(x,y) to apply, where x is new, and y orig location

Returns:

The SpatialInertia at x transformed by T.

Protected Functions

void _setInertia(double mass, const Vec3 &body_to_cm, const Mat33 &inertia, bool at_cm, bool validate)#

Set the values of this SpatialInertia.

Parameters:
  • mass – The mass of the SpatialInertia.

  • body_to_cm – The body-to-center-of-mass of the SpatialInertia.

  • inertia – The inertia of the SpatialInertia.

  • at_cmtrue if the given inertia is about the center of mass, false otherwise.

  • validate – Verify that the values lead to a symmetric, positive semi-definite CM inertia

void _validateInertia(const Mat33 &inertia) const#

Check that the 3x3 inertia matrix is positive semi-definite.

Parameters:

inertia – - The 3x3 inertia matrix to check.

Mat33 _parallelAxisCmInertiaOffset(const Vec3 &offset) const#

Return delta inertia for the 3x3 CM inertia for parallel axis transformation.

Note that the returned delta value is the same for offset and -offset.

Parameters:

offset – The 3-vector offset

Returns:

Returned value is (- mass * tilde(offset) * tilde(offset