项目作者: rock-learning

项目描述 :
3D transformations for Python
高级语言: Python
项目地址: git://github.com/rock-learning/pytransform3d.git
创建时间: 2017-05-19T13:35:08Z
项目社区:https://github.com/rock-learning/pytransform3d

开源协议:BSD 3-Clause "New" or "Revised" License

下载


CircleCI
codecov
Paper DOI
Release DOI

pytransform3d

A Python library for transformations in three dimensions.

pytransform3d offers…

  • operations like concatenation and inversion for most common representations
    of rotation (orientation) and translation (position)
  • conversions between those representations
  • clear documentation of transformation conventions
  • tight coupling with matplotlib to quickly visualize (or animate)
    transformations
  • the TransformManager which manages complex chains of transformations
    (with export to graph visualization as PNG, additionally requires pydot)
  • the TransformEditor which allows to modify transformations graphically
    (additionally requires PyQt4/5)
  • the UrdfTransformManager which is able to load transformations from
    URDF files (additionally requires lxml)
  • a matplotlib-like interface to Open3D’s visualizer to display and animate
    geometries and transformations (additionally requires Open3D)

pytransform3d is used in various domains, for example:

  • specifying motions of a robot
  • learning robot movements from human demonstration
  • sensor fusion for human pose estimation
  • collision detection for robots

The API documentation can be found
here.

I gave a talk at EuroSciPy 2023 about pytransform3d. Slides are available
here.

Installation

Use pip to install the package from PyPI:

  1. pip install 'pytransform3d[all]'

or conda:

  1. conda install -c conda-forge pytransform3d

Take a look at the
installation instructions
in the documentation for more details.

The following plots and visualizations have been generated with pytransform3d.
The code for most examples can be found in
the documentation.

Left: Nao robot with URDF
from Bullet3.
Right: Kuka iiwa.
The animation is based on pytransform3d’s visualization interface to
Open3D.

Visualizations based on Open3D.

Various plots based on Matplotlib.

Transformation editor based on Qt.

Example

This is just one simple example. You can find more examples in the subfolder
examples/.

  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from pytransform3d import rotations as pr
  4. from pytransform3d import transformations as pt
  5. from pytransform3d.transform_manager import TransformManager
  6. rng = np.random.default_rng(0)
  7. ee2robot = pt.transform_from_pq(
  8. np.hstack((np.array([0.4, -0.3, 0.5]),
  9. pr.random_quaternion(rng))))
  10. cam2robot = pt.transform_from_pq(
  11. np.hstack((np.array([0.0, 0.0, 0.8]), pr.q_id)))
  12. object2cam = pt.transform_from(
  13. pr.active_matrix_from_intrinsic_euler_xyz(np.array([0.0, 0.0, -0.5])),
  14. np.array([0.5, 0.1, 0.1]))
  15. tm = TransformManager()
  16. tm.add_transform("end-effector", "robot", ee2robot)
  17. tm.add_transform("camera", "robot", cam2robot)
  18. tm.add_transform("object", "camera", object2cam)
  19. ee2object = tm.get_transform("end-effector", "object")
  20. ax = tm.plot_frames_in("robot", s=0.1)
  21. ax.set_xlim((-0.25, 0.75))
  22. ax.set_ylim((-0.5, 0.5))
  23. ax.set_zlim((0.0, 1.0))
  24. plt.show()

output

Documentation

The API documentation can be found
here.

The documentation can be found in the directory doc.
To build the documentation, run e.g. (on linux):

  1. cd doc
  2. make html

The HTML documentation is now located at doc/build/html/index.html.
Execute the following command in the main folder of the repository
to install the dependencies:

  1. pip install -e '.[doc]'

Tests

You can use pytest to run the tests of this project in the root directory:

  1. pytest

A coverage report will be located at htmlcov/index.html.
Note that you have to install pytest to run the tests and pytest-cov to
obtain the code coverage report.

Contributing

If you wish to report bugs, please use the
issue tracker at
Github. If you would like to contribute to pytransform3d, just open an issue
or a pull request.
The target branch for pull requests is the develop branch.
The development branch will be merged to main for new releases.
If you have questions about the software, you should ask them in the
discussion section.

The recommended workflow to add a new feature, add documentation, or fix a bug
is the following:

  • Push your changes to a branch (e.g. feature/x, doc/y, or fix/z) of your
    fork of the pytransform3d repository.
  • Open a pull request to the latest development branch. There is usually an
    open merge request from the latest development branch to the main branch.
  • When the latest development branch is merged to the main branch, a new
    release will be made.

Note that there is a
checklist
for new features.

It is forbidden to directly push to the main branch. Each new version
has its own development branch from which a pull request will be opened to the
main branch. Only the maintainer of the software is allowed to merge a
development branch to the main branch.

License

The library is distributed under the
3-Clause BSD license.

Citation

If you use pytransform3d for a scientific publication, I would appreciate
citation of the following paper:

Fabisch, A. (2019). pytransform3d: 3D Transformations for Python.
Journal of Open Source Software, 4(33), 1159,
Paper DOI

Bibtex entry:

  1. @article{Fabisch2019,
  2. doi = {10.21105/joss.01159},
  3. url = {https://doi.org/10.21105/joss.01159},
  4. year = {2019},
  5. publisher = {The Open Journal},
  6. volume = {4},
  7. number = {33},
  8. pages = {1159},
  9. author = {Alexander Fabisch},
  10. title = {pytransform3d: 3D Transformations for Python},
  11. journal = {Journal of Open Source Software}
  12. }