Skip to main content

A Python library for robotic education and research

Project description

Robotics Toolbox for Python

PyPI version PyPI - Python Version License: MIT Binder QUT Centre for Robotics Open Source

Build Status Coverage Language grade: Python PyPI - Downloads

A Python implementation of the Robotics Toolbox for MATLAB®

Synopsis

This toolbox brings robotics-specific functionality to Python, and leverages Python's advantages of portability, ubiquity and support, and the capability of the open-source ecosystem for linear algebra (numpy, scipy), graphics (matplotlib, three.js, WebGL), interactive development (jupyter, jupyterlab, mybinder.org), and documentation (sphinx).

The Toolbox provides tools for representing the kinematics and dynamics of serial-link manipulators - you can easily create your own in Denavit-Hartenberg form, import a URDF file, or use over 30 supplied models for well-known contemporary robots from Franka-Emika, Kinova, Universal Robotics, Rethink as well as classical robots such as the Puma 560 and the Stanford arm.

The toolbox will also support mobile robots with functions for robot motion models (unicycle, bicycle), path planning algorithms (bug, distance transform, D*, PRM), kinodynamic planning (lattice, RRT), localization (EKF, particle filter), map building (EKF) and simultaneous localization and mapping (EKF).

The Toolbox provides:

  • code that is mature and provides a point of comparison for other implementations of the same algorithms;
  • routines which are generally written in a straightforward manner which allows for easy understanding, perhaps at the expense of computational efficiency;
  • source code which can be read for learning and teaching;
  • backward compatability with the Robotics Toolbox for MATLAB

The Toolbox leverages the Spatial Maths Toolbox for Python to provide support for data types such as SO(n) and SE(n) matrices, quaternions, twists and spatial vectors.

Code Example

We will load a model of the Franka-Emika Panda robot defined classically using modified (Craig's convention) Denavit-Hartenberg notation

import roboticstoolbox as rtb
robot = rtb.models.DH.Panda()
print(robot)

	┏━━━━━━━━┳━━━━━━━━┳━━━━━┳━━━━━━━┳━━━━━━━━━┳━━━━━━━━┓
	 aⱼ₋₁     ₋₁   θⱼ    dⱼ      q       q   
	┣━━━━━━━━╋━━━━━━━━╋━━━━━╋━━━━━━━╋━━━━━━━━━╋━━━━━━━━┫
	    0.0    0.0°   q1  0.333  -166.0°  166.0° 
	    0.0  -90.0°   q2    0.0  -101.0°  101.0° 
	    0.0   90.0°   q3  0.316  -166.0°  166.0° 
	 0.0825   90.0°   q4    0.0  -176.0°   -4.0° 
	-0.0825  -90.0°   q5  0.384  -166.0°  166.0° 
	    0.0   90.0°   q6    0.0    -1.0°  215.0° 
	  0.088   90.0°   q7  0.107  -166.0°  166.0° 
	┗━━━━━━━━┻━━━━━━━━┻━━━━━┻━━━━━━━┻━━━━━━━━━┻━━━━━━━━┛

	┌─────┬───────────────────────────────────────┐
	tool  t = 0, 0, 0.1; rpy/xyz = -45°, 0°, 0° 
	└─────┴───────────────────────────────────────┘

	┌─────┬─────┬────────┬─────┬───────┬─────┬───────┬──────┐
	name  q0   q1      q2   q3     q4   q5     q6   
	├─────┼─────┼────────┼─────┼───────┼─────┼───────┼──────┤
	  qz   0°   0°      0°   0°     0°   0°     0°  
	  qr   0°  -17.2°   0°  -126°   0°   115°   45° 
	└─────┴─────┴────────┴─────┴───────┴─────┴───────┴──────┘

T = robot.fkine(robot.qz)  # forward kinematics
print(T)

	   0.707107    0.707107    0           0.088        
	   0.707107   -0.707107    0           0            
	   0           0          -1           0.823        
	   0           0           0           1          

(Python prompts are not shown to make it easy to copy+paste the code, console output is indented)

We can solve inverse kinematics very easily. We first choose an SE(3) pose defined in terms of position and orientation (end-effector z-axis down (A=-Z) and finger orientation parallel to y-axis (O=+Y)).

from spatialmath import SE3

T = SE3(0.8, 0.2, 0.1) * SE3.OA([0, 1, 0], [0, 0, -1])
sol = robot.ikine_min(T)         # solve IK
print(sol.q)                     # display joint angles

	[-0.01044    7.876    1.557    -6.81    1.571    4.686   0.5169]

print(robot.fkine(sol.q))    # FK shows that desired end-effector pose was achieved

	Out[35]: 
	SE3:                                           
		-1         -4e-08      0.000521   0.615    
		 2.79e-08   1          0.00013    0.154    
		-0.000521   0.00013   -1          0.105    
		 0          0          0          1        
		                                           

Note that because this robot is redundant we don't have any control over the arm configuration apart from end-effector pose, ie. we can't control the elbow height.

We can animate a path from the upright qz configuration to this pickup configuration

qt = rtb.trajectory.jtraj(robot.qz, q_pickup, 50)
robot.plot(qt.q, movie='panda1.gif')

Panda trajectory animation

which uses the default matplotlib backend. Grey arrows show the joint axes and the colored frame shows the end-effector pose.

Let's now load a URDF model of the same robot. The kinematic representation is no longer based on Denavit-Hartenberg parameters, it is now a rigid-body tree.

robot = rtb.models.URDF.Panda()  # load URDF version of the Panda
print(robot)    # display the model

	┌───┬──────────────┬─────────────┬──────────────┬─────────────────────────────────────────────┐
	id      link        parent        joint                          ETS                     
	├───┼──────────────┼─────────────┼──────────────┼─────────────────────────────────────────────┤
	 0   panda_link0            -                                                            
	 1   panda_link1  panda_link0  panda_joint1                           tz(0.333) * Rz(q0) 
	 2   panda_link2  panda_link1  panda_joint2                            Rx(-90°) * Rz(q1) 
	 3   panda_link3  panda_link2  panda_joint3                ty(-0.316) * Rx(90°) * Rz(q2) 
	 4   panda_link4  panda_link3  panda_joint4                tx(0.0825) * Rx(90°) * Rz(q3) 
	 5   panda_link5  panda_link4  panda_joint5  tx(-0.0825) * ty(0.384) * Rx(-90°) * Rz(q4) 
	 6   panda_link6  panda_link5  panda_joint6                             Rx(90°) * Rz(q5) 
	 7   panda_link7  panda_link6  panda_joint7                 tx(0.088) * Rx(90°) * Rz(q6) 
	 8  @panda_link8  panda_link7  panda_joint8                                    tz(0.107) 
	└───┴──────────────┴─────────────┴──────────────┴─────────────────────────────────────────────┘

The symbol @ indicates the link as an end-effector, a leaf node in the rigid-body tree.

We can instantiate our robot inside a browser-based 3d-simulation environment.

env = rtb.backends.Swift()  # instantiate 3D browser-based visualizer
env.launch()                # activate it
env.add(robot)              # add robot to the 3D scene
for qk in qt.q:             # for each joint configuration on trajectory
      robot.q = qk          # update the robot state
      env.step()            # update visualization

Getting going

Installing

You will need Python >= 3.6

Using pip

Install a snapshot from PyPI

pip3 install roboticstoolbox-python

Available options are:

  • vpython install VPython backend
  • collision install collision checking with pybullet

Put the options in a comma separated list like

pip3 install roboticstoolbox-python[optionlist]

Swift, a web-based visualizer, is installed as part of Robotics Toolbox.

From GitHub

To install the bleeding-edge version from GitHub

git clone https://github.com/petercorke/robotics-toolbox-python.git
cd robotics-toolbox-python
pip3 install -e .

Run some examples

The notebooks folder contains some tutorial Jupyter notebooks which you can browse on GitHub.

Or you can run them, and experiment with them, at mybinder.org.

Toolbox Research Applications

The toolbox is incredibly useful for developing and prototyping algorithms for research, thanks to the exhaustive set of well documented and mature robotic functions exposed through clean and painless APIs. Additionally, the ease at which a user can visualize their algorithm supports a rapid prototyping paradigm.

Publication List

J. Haviland and P. Corke, "NEO: A Novel Expeditious Optimisation Algorithm for Reactive Motion Control of Manipulators," in IEEE Robotics and Automation Letters, doi: 10.1109/LRA.2021.3056060. In the video, the robot is controlled using the Robotics toolbox for Python and features a recording from the Swift Simulator.

[Arxiv Paper] [IEEE Xplore] [Project Website] [Video] [Code Example]

A Purely-Reactive Manipulability-Maximising Motion Controller, J. Haviland and P. Corke. In the video, the robot is controlled using the Robotics toolbox for Python.

[Paper] [Project Website] [Video] [Code Example]


Common Issues

See the common issues with fixes here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

roboticstoolbox-python-0.9.1.tar.gz (242.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

roboticstoolbox_python-0.9.1-cp38-cp38-win_amd64.whl (322.4 kB view details)

Uploaded CPython 3.8Windows x86-64

roboticstoolbox_python-0.9.1-cp38-cp38-manylinux2010_x86_64.whl (338.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

roboticstoolbox_python-0.9.1-cp38-cp38-macosx_10_14_x86_64.whl (314.4 kB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

roboticstoolbox_python-0.9.1-cp37-cp37m-win_amd64.whl (322.4 kB view details)

Uploaded CPython 3.7mWindows x86-64

roboticstoolbox_python-0.9.1-cp37-cp37m-manylinux2010_x86_64.whl (340.2 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

roboticstoolbox_python-0.9.1-cp37-cp37m-macosx_10_14_x86_64.whl (314.4 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

roboticstoolbox_python-0.9.1-cp36-cp36m-win_amd64.whl (322.4 kB view details)

Uploaded CPython 3.6mWindows x86-64

roboticstoolbox_python-0.9.1-cp36-cp36m-manylinux2010_x86_64.whl (338.9 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

roboticstoolbox_python-0.9.1-cp36-cp36m-macosx_10_14_x86_64.whl (314.4 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

Details for the file roboticstoolbox-python-0.9.1.tar.gz.

File metadata

  • Download URL: roboticstoolbox-python-0.9.1.tar.gz
  • Upload date:
  • Size: 242.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10

File hashes

Hashes for roboticstoolbox-python-0.9.1.tar.gz
Algorithm Hash digest
SHA256 efa9165125a07156097db5f6b6fc4990f7f8615d6a202c89f292a808da00aa26
MD5 0c9c24c0380dee5e22356f9a7267a87a
BLAKE2b-256 1980c8dff30c7913e6c7ea0befb3ec568ab0237b2c9f91b88404f60d72210f5d

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: roboticstoolbox_python-0.9.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 322.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.7

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b07e03bb7dfef042ba27a597c2ef9813864461a08ab0b3021a7bd8600b1ce078
MD5 4ffb1216e8d5e42502a34ab3386dbcd8
BLAKE2b-256 52ece506dd80e1d486165191f292aa6f21f8a63247cfa7cec30ddfe4c2433a59

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: roboticstoolbox_python-0.9.1-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 338.6 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 1d739d0c2ffd9d099243f2946ac1f7fecd522a27b3c193c5f6d1fb5c728019d3
MD5 7afdb6e07cd13fe2e16ae8a5887d4a9d
BLAKE2b-256 8a702dcb977cfbf5eea780c37697e724bd28e6648ae973557f0a928c95854ae8

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp38-cp38-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f188995c612861bd07a46ad3a5c66e151d2bf34a6d6ca93eb238ee2ccc22138e
MD5 11c6b4d8892c46bf41818ed0a947c678
BLAKE2b-256 340d3b59e1201838e2533e2d95dbcd8feb43c42b27b47616a6448f1d3eda17e1

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: roboticstoolbox_python-0.9.1-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 314.4 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 0a4f02f72913d3e74c80a99a0efed1cf71490e2f122d4dfc87faadcaf2eb0da3
MD5 c347ae4457804abe5456bef60661ef6a
BLAKE2b-256 f2788b9eebb6f2e5fd6acb779345a8a9bdc3eae65f237f8cde4cb998dd9c73e4

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: roboticstoolbox_python-0.9.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 322.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.9

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 91ad3a10b540d5bacecac069b7fdfebb9480d0753a90b6a5c1bfcd554a1b75b4
MD5 a664b48c689df9ec6bf4ec5d0d5c3d1c
BLAKE2b-256 b95fcf50d7931d0c116fb5af5a40bf9d09d547ff158fb45abc2d6161c8982807

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: roboticstoolbox_python-0.9.1-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 340.2 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 78369bc4f6f9065411e458055109dc918dccbf38ce7864babf7466ac04127960
MD5 72089603ec002917981fdea01c0bcf86
BLAKE2b-256 624089385cbd9756a20d6615073a7947e73255a81627a1ca820f02f2bf3ad55d

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e31cbd12e56bb1b04957880304ee2b790a8b6200cfc481d9281e7e53686c528f
MD5 fabd03e2103019729b4ff85ee78f4498
BLAKE2b-256 c57542bf73a5c13614277fa90fe5cd8adcff00c7dc90d104852e073f286949a5

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: roboticstoolbox_python-0.9.1-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 314.4 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ba8c57107a583a03fa466ff9d6ab12d67418db2b09bced0aadcdc0663139302f
MD5 4214181d1e2e1ba1e93503ca44d7d5da
BLAKE2b-256 dc892bddce6be3474729f5d707a30f7159e587f1a421547d2700595486307972

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: roboticstoolbox_python-0.9.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 322.4 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.8

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 bcc4a7fae517a2960431ab7c353fb23f22dcd4da9837dd385aee61aafe07071c
MD5 29c54e54b08c2f81cab95713599d5549
BLAKE2b-256 a74bb6b09870221ca9c1afc7ebcb5f30bbc005116cc729fcc42504cbbdbf1f13

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: roboticstoolbox_python-0.9.1-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 338.9 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2ac1d73686ec3e1c8a43736b47f152eebf8166c43cd886fd7348794a2edd938f
MD5 eb822d9a0202d6bb9370a17a3200676f
BLAKE2b-256 a39633755be009e5f907d3fe06e2a907098cbd38c54311fec021cc0e8468519f

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f8604d318b9097998bfddbd0882267639ae16d29278ce958c55865a6a19fb8a2
MD5 2927cadaa0697a26d31e55686a5818a6
BLAKE2b-256 827cc535973199eacb50ec087b55dbc187f7f209289f82249418da54c9440fae

See more details on using hashes here.

File details

Details for the file roboticstoolbox_python-0.9.1-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: roboticstoolbox_python-0.9.1-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 314.4 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.13

File hashes

Hashes for roboticstoolbox_python-0.9.1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 9b59001d088c34f3ece42270334720930d874c3e27f0fab94abf5161ec717380
MD5 d44ef951fa6215be9880f39f4a702d81
BLAKE2b-256 f1f07c5de88ef8240b0ce7ff2b4273c233bc4c3d08011a2bf8c687ac85535f65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page