robot_msgs

Quaternion

Unit quaternions are rotations; the fields are stored exactly as given.

Full docstring
WHY not normalised at construction: a stored property must read back as authored. Every
operation that needs a rotation (`rotate`, `to_matrix`, `multiply`, ...) normalises first;
`normalized()` and `is_unit()` are there when you want the unit value yourself.
Import
from robot_msgs.geometry import Quaternion
ROS 2geometry_msgs/msg/Quaternion

Fields

NameTypeDefault
xfloat0.0
yfloat0.0
zfloat0.0
wfloat1.0

Example

One instance from the package's own test catalog; the output is its real repr().

Quaternion(x=0.034270798550482096, y=0.10602051106179562, z=0.1435721750273919, w=0.9833474432563558)
to_dict() as JSON
{
  "_type": "geometry/Quaternion",
  "x": 0.034270798550482096,
  "y": 0.10602051106179562,
  "z": 0.1435721750273919,
  "w": 0.9833474432563558
}

Long arrays are cut after 16 values and say so with “…”.

Functions

Constructors

Classmethods and staticmethods: ways to build one.

from_array(array: Any) -> Quaternion

No docstring.

from_axis_angle(axis: Any, angle: float) -> Quaternion

axis need not be unit length, but must be non-zero. Radians.

from_euler(roll: float, pitch: float, yaw: float) -> Quaternion

ROS RPY: fixed axes X, then Y, then Z (R = Rz·Ry·Rx).

from_matrix(matrix: Any) -> Quaternion

From a (3, 3) rotation matrix.

from_rotvec(rotvec: Any) -> Quaternion

From axis × angle (radians).

from_wxyz(array: Any) -> Quaternion

From MuJoCo / viser order.

identity() -> Quaternion

No docstring.

from_dict

from Msg
from_dict(data: Mapping[str, Any]) -> M

No docstring.

Methods

Return new values; messages are never mutated.

angle_to(other: Quaternion) -> float

Radians in [0, π] of the rotation that takes self to other.

as_array() -> np.ndarray

(4,) in x, y, z, w order.

conjugate() -> Quaternion

Negated vector part, fields otherwise as stored.

inverse() -> Quaternion

The unit quaternion of the opposite rotation.

is_unit(tol: float = 1e-09) -> bool

No docstring.

multiply(other: Quaternion) -> Quaternion

Hamilton product of the unit rotations: apply other first, then self.

normalized() -> Quaternion

No docstring.

rotate(vector: V) -> V

Rotate a Vector3, Point or (..., 3) array; returns the same kind.

slerp(other: Quaternion, alpha: float) -> Quaternion

Along the shorter arc; 0 gives self, 1 gives other, outside [0, 1] extrapolates.

to_euler() -> tuple[float, float, float]

(roll, pitch, yaw); pitch in [-π/2, π/2].

to_matrix() -> np.ndarray

No docstring.

to_rotvec() -> np.ndarray

Axis × angle for the shorter rotation, angle in [0, π].

to_wxyz() -> np.ndarray

No docstring.

replace

from Msg
replace(**changes: Any) -> M

A copy with some fields changed. Validation runs again.

to_dict

from Msg
to_dict() -> dict[str, Any]

JSON-safe dict with a "_type" key; arrays keep their dtype and shape.

Operators

Python operators and protocols the type supports.

__iter__() -> Iterator[float]

No docstring.

__mul__(other: object) -> Quaternion

No docstring.

Used by

Types whose fields refer to it.

Pose Transform Imu

robot_msgs 0.1.0 @ 2dc6666GitHub · MIT license · generated from the package, not written per type