rai-opensource/spatialmath-python

Create, manipulate and convert representations of position and orientation in 2D or 3D using Python

What it solves

This package provides the essential mathematical tools needed to describe the position, orientation, and movement of objects in 2D and 3D space. It is specifically designed to handle the complex calculations required for robotics and robotic vision, ensuring that spatial data remains valid and easy to manipulate.

How it works

The library offers two primary ways to perform spatial math. First, it provides high-level classes (like SE3, SO3, and UnitQuaternion) that act as wrappers around standard data. These classes enforce mathematical rules, providing type safety and preventing common errors—such as accidentally mixing different types of coordinate systems. Second, it includes a low-level library of functions that operate directly on standard numpy arrays for those who prefer a more direct, functional approach.

Who it’s for

It is built for researchers, engineers, and students working in robotics, computer vision, or any field requiring precise 3D spatial transformations. It is particularly useful for those transitioning from MATLAB-based robotics workflows to Python.

Highlights

  • Provides dedicated classes for 2D and 3D poses, rotations, and twists.
  • Ensures type safety by preventing invalid mathematical operations on spatial objects.
  • Supports intuitive operator overloading, such as using * for composition and point transformation.
  • Includes built-in support for visualizing coordinate frames and creating animations.
  • Offers symbolic math support through integration with sympy.
  • Mirrors the semantics and naming conventions of the widely used Spatial Math Toolbox for MATLAB.

Related

  • Project
  • Project
  • Project
  • Project
  • Project