# What is the best SE3 library for python?

I am currently googling on this topic but I would like to hear your opinion.

What is the best self-contained SE3 library that offers interconversion between quaternion, rotation vector, transformation matrix?

Those are the functions that I often use for my projects and all implemented in Matlab. And I am looking for an alternative to avoid re-implementing them all in python.

Quaternion2RotVector and its inverse

Quaternion2RotMatrix and its inverse

RotMatrix2RotVector and its inverse

SE3 inverse, the inverse function of each rotation representation

ROS's tf.transformations.py has self-contained code for doing these functions and can be used without installing ros. In fact, the python code only depends on numpy!

Writing your own package is always the best way to learn. If you want to try something premade here are a few packages to choose from:

• Spatial Math Toolbox for Python Python3+numpy+scipy, also available from PyPy, with classes and functions. This is a Python port of my Robotics/Spatial Math Toolbox for MATLAB
• Sophus C++/Eigen with Python wrappers

I wrote my own and learned useful things about numpy and python object initialization in the process. I don't regret it.

Klampt Library by Kris Hauser is very good and implement a lot of distances functions including SE3 (R3 + SO3). I use Klampt for some robotic arms applications

– Ben
Commented May 13, 2021 at 14:59

I'm surpised nobody mentioned Scipy. Easy to use, mature, great docs, huge community.

You should decide whether you would like built-in visualization tools or a coordinate frame management system, or something a little more bare-bones.

As stated, transformations.py is bundled with ROS tf and therefore is commonly used around the ROS community. It is primarily useful for constructing raw rotation matrices and homogeneous transformation matrices, from various rotation representations and translation vectors. It's only external dependency is numpy, and it can also be installed through PyPI if you are not using ROS.

When you introduce the concept of coordinate systems / frames, I recommend you study active vs. passive transformations (if you are not already familiar) and seek out a package which makes this distinction in the API. Anytime you interact with raw transformation matrices (create, multiply with a vector, etc.), you will need to know which paradigm you are dealing with.

For the above distinction and for visualization options, I would recommend looking at pytransform3d, which also uses numpy, but provides some ROS-like transform tree management, visualization with matplotlib and open3d, as well as excellent documentation (IMO).

• The link to pytransform3d's documentation is broken since the project moved. It is now at dfki-ric.github.io/pytransform3d
– alfa
Commented Dec 23, 2022 at 9:44
• Thanks. Updated Commented Dec 24, 2022 at 18:07