Skip to main content

Overview

RigidBodyKinematics (RBK) is a pure-Python library with over 200 functions for converting between attitude representations and composing rotations. All angle arguments and return values are in radians.
from Basilisk.utilities import RigidBodyKinematics as rbk
import numpy as np

Module-level constants

ConstantValue
D2Rπ / 180
R2D180 / π
M_PIπ

Utility

Picheck(x)
function
Wraps angle x into (-π, π].
x_wrapped = rbk.Picheck(x)

Direction cosine matrix (DCM) → other representations

C2EP(C)
function
Converts a 3×3 DCM to a 4×1 Euler parameter (quaternion) vector [β₀, β₁, β₂, β₃] with β₀ >= 0. Uses the Stanley method.
q = rbk.C2EP(C)  # shape (4,)
C2MRP(C)
function
Converts a 3×3 DCM to a 3×1 Modified Rodrigues Parameter (MRP) vector with |σ| <= 1.
sigma = rbk.C2MRP(C)  # shape (3,)
C2Gibbs(C)
function
Converts a 3×3 DCM to a 3×1 Gibbs (classical Rodrigues) vector.
q = rbk.C2Gibbs(C)  # shape (3,)
C2PRV(C)
function
Converts a 3×3 DCM to a 3×1 principal rotation vector (PRV). The magnitude of the returned vector is the principal rotation angle φ ∈ [0, π].
phi_hat = rbk.C2PRV(C)  # shape (3,)

Euler angle sets from DCM

All functions follow the pattern C2Euler<seq>(C) -> ndarray(3,) and return the three Euler angles in radians. Available sequences:
FunctionSequence
C2Euler121(C)1-2-1
C2Euler123(C)1-2-3
C2Euler131(C)1-3-1
C2Euler132(C)1-3-2
C2Euler212(C)2-1-2
C2Euler213(C)2-1-3
C2Euler231(C)2-3-1
C2Euler232(C)2-3-2
C2Euler312(C)3-1-2
C2Euler313(C)3-1-3
C2Euler321(C)3-2-1
C2Euler323(C)3-2-3
angles_321 = rbk.C2Euler321(C)  # [roll, pitch, yaw] in rad

Rotation composition

addEP(b1, b2)
function
Composes two Euler parameter (quaternion) rotations. Returns the quaternion for the combined rotation B1 followed by B2.
b_combined = rbk.addEP(b1, b2)  # shape (4,)

Common usage patterns

Convert MRP to DCM

Several inverse functions are available (e.g., MRP2C, EP2C, PRV2C) following the naming convention <repr>2C.
import numpy as np
from Basilisk.utilities import RigidBodyKinematics as rbk

# Define attitude as MRP
sigma_BN = np.array([0.1, -0.2, 0.05])

# Convert to DCM
C_BN = rbk.MRP2C(sigma_BN)  # 3x3 ndarray

# Compose two MRP rotations
sigma_combined = rbk.addMRP(sigma_BN, np.array([0.0, 0.0, 0.1]))

Convert DCM to Euler 3-2-1

angles = rbk.C2Euler321(C_BN)
yaw, pitch, roll = angles  # all in rad

Build docs developers (and LLMs) love