The high-level classes (SO3, SE3, etc.) abstract numpy arrays into objects that obey the rules of their respective mathematical groups. This ensures that operations like mixing 2D and 3D transformations are prevented by type safety.
Creating Rotations
You can create rotations around specific axes using methods like .Rx(), .Ry(), and .Rz(). You can specify units using strings like 'deg'.
Composition and Euler Angles
Use the * operator to compose rotations or transform points. You can extract Euler angles using the .eul() method.
Trajectories and Lists
Pose classes inherit from the Python list class, allowing you to treat a sequence of poses as a list. You can use .append(), list comprehensions, or pass a list directly to the constructor.
Vectorization
Constructors and operators support vectorization. For example, passing a numpy array to a constructor creates a list of matrices, and multiplying a list of matrices by a single matrix applies the operation element-wise.
from spatialmath import SO3, SE3
import numpy as np
# Create rotations
R1 = SO3.Rx(0.3)
R2 = SO3.Rz(30, 'deg')
# Composition
R = R1 * R2
# Euler angles (radians)
euler = R.eul()
# Trajectories (list-like behavior)
seq = SO3()
seq.append(R1)
seq.append(R2)
# Vectorized construction
vec_R = SO3.Rx(np.arange(0, 2*np.pi, 0.2))
# Vectorized operator (element-wise product)
vec_A = vec_R * SO3.Ry(0.5)