9
$\begingroup$

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

$\endgroup$

6 Answers 6

5
$\begingroup$

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!

transformations.py

$\endgroup$
6
$\begingroup$

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
$\endgroup$
3
$\begingroup$

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

$\endgroup$
3
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Welcome to Robotics hugosc. Thanks for your answer but we are looking for comprehensive answers that provide some explanation and context. Very short answers cannot do this, so please edit your answer to explain why it is right, ideally with citations. Answers that don't include explanations may be removed. See How to Answer for more info. $\endgroup$
    – Ben
    May 13, 2021 at 14:59
2
$\begingroup$

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

$\endgroup$
1
$\begingroup$

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).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.