- Notifications
You must be signed in to change notification settings - Fork512
Robotics Toolbox for Python
License
petercorke/robotics-toolbox-python
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
![]() | A Python implementation of theRobotics Toolbox for MATLAB® |
- Synopsis
- Getting going
- Tutorials
- Code Examples
- Toolbox Research Applications
- Toolbox ICRA Paper and Citation Info
- Using the Toolbox in your Open Source Code?
- Common Issues and Solutions
This toolbox brings robotics-specific functionality to Python, and leveragesPython's advantages of portability, ubiquity and support, and the capability ofthe 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 ofserial-link manipulators - you can easily create your own in Denavit-Hartenbergform, import a URDF file, or use over 30 supplied models for well-knowncontemporary robots from Franka-Emika, Kinova, Universal Robotics, Rethink aswell as classical robots such as the Puma 560 and the Stanford arm.
The Toolbox contains fast implementations of kinematic operations. The forwardkinematics and the manipulator Jacobian can be computed in less than 1 microsecondwhile numerical inverse kinematics can be solved in as little as 4 microseconds.
The toolbox also supports 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 otherimplementations of the same algorithms;
- routines which are generally written in a straightforward manner whichallows for easy understanding, perhaps at the expense of computationalefficiency;
- source code which can be read for learning and teaching;
- backward compatability with the Robotics Toolbox for MATLAB
The Toolbox leverages theSpatial Maths Toolbox for Python toprovide support for data types such as SO(n) and SE(n) matrices, quaternions, twists and spatial vectors.
You will need Python >= 3.6
Install a snapshot from PyPI
pip3 install roboticstoolbox-python
Available options are:
collision
install collision checking withpybullet
Put the options in a comma separated list like
pip3 install roboticstoolbox-python[optionlist]
Swift, a web-based visualizer, isinstalled as part of Robotics Toolbox.
To install the bleeding-edge version from GitHub
git clone https://github.com/petercorke/robotics-toolbox-python.gitcd robotics-toolbox-pythonpip3 install -e.
![]() | ![]() | Do you want to learn about manipulator kinematics, differential kinematics, inverse-kinematics and motion control? Have a look at ourtutorial.This tutorial comes with two articles to cover the theory and 12 Jupyter Notebooks providing full code implementations and examples. Most of the Notebooks are also Google Colab compatible allowing them to run online. |
We will load a model of the Franka-Emika Panda robot defined by a URDF file
importroboticstoolboxasrtbrobot=rtb.models.Panda()print(robot)ERobot:panda (byFrankaEmika),7joints (RRRRRRR),1gripper,geometry,collision┌─────┬──────────────┬───────┬─────────────┬────────────────────────────────────────────────┐│link │link │joint │parent │ETS:parenttolink │├─────┼──────────────┼───────┼─────────────┼────────────────────────────────────────────────┤│0 │panda_link0 │ │BASE │ ││1 │panda_link1 │0 │panda_link0 │SE3(0,0,0.333) ⊕Rz(q0) ││2 │panda_link2 │1 │panda_link1 │SE3(-90°,-0°,0°) ⊕Rz(q1) ││3 │panda_link3 │2 │panda_link2 │SE3(0,-0.316,0;90°,-0°,0°) ⊕Rz(q2) ││4 │panda_link4 │3 │panda_link3 │SE3(0.0825,0,0;90°,-0°,0°) ⊕Rz(q3) ││5 │panda_link5 │4 │panda_link4 │SE3(-0.0825,0.384,0;-90°,-0°,0°) ⊕Rz(q4) ││6 │panda_link6 │5 │panda_link5 │SE3(90°,-0°,0°) ⊕Rz(q5) ││7 │panda_link7 │6 │panda_link6 │SE3(0.088,0,0;90°,-0°,0°) ⊕Rz(q6) ││8 │ @panda_link8 │ │panda_link7 │SE3(0,0,0.107) │└─────┴──────────────┴───────┴─────────────┴────────────────────────────────────────────────┘┌─────┬─────┬────────┬─────┬───────┬─────┬───────┬──────┐│name │q0 │q1 │q2 │q3 │q4 │q5 │q6 │├─────┼─────┼────────┼─────┼───────┼─────┼───────┼──────┤│qr │0° │-17.2° │0° │-126° │0° │115° │45° ││qz │0° │0° │0° │0° │0° │0° │0° │└─────┴─────┴────────┴─────┴───────┴─────┴───────┴──────┘
The symbol@
indicates the link as an end-effector, a leaf node in the rigid-bodytree (Python prompts are not shown to make it easy to copy+paste the code, console output is indented).We will compute the forward kinematics next
Te = robot.fkine(robot.qr) # forward kinematicsprint(Te)0.995 0 0.09983 0.4840 -1 0 00.09983 0 -0.995 0.41260 0 0 1
We can solve inverse kinematics very easily. We first choose an SE(3) posedefined in terms of position and orientation (end-effector z-axis down (A=-Z) and fingerorientation parallel to y-axis (O=+Y)).
fromspatialmathimportSE3Tep=SE3.Trans(0.6,-0.3,0.1)*SE3.OA([0,1,0], [0,0,-1])sol=robot.ik_LM(Tep)# solve IKprint(sol)(array([0.20592815,0.86609481,-0.79473206,-1.68254794,0.74872915,2.21764746,-0.10255606]),1,114,7,2.890164057230228e-07)q_pickup=sol[0]print(robot.fkine(q_pickup))# FK shows that desired end-effector pose was achieved1-8.913e-05-0.00033340.5996-8.929e-05-1-0.0004912-0.2998-0.00033340.0004912-10.10010001
We can animate a path from the ready poseqr
configuration to this pickup configuration
qt=rtb.jtraj(robot.qr,q_pickup,50)robot.plot(qt.q,backend='pyplot',movie='panda1.gif')
where we have specified the matplotlibpyplot
backend. Blue arrows show the joint axes and the coloured frame shows the end-effector pose.
We can also plot the trajectory in the Swift simulator (a browser-based 3d-simulation environment built to work with the Toolbox)
robot.plot(qt.q)
We can also experiment with velocity controllers in Swift. Here is a resolved-rate motion control example
importswiftimportroboticstoolboxasrtbimportspatialmathassmimportnumpyasnpenv=swift.Swift()env.launch(realtime=True)panda=rtb.models.Panda()panda.q=panda.qrTep=panda.fkine(panda.q)*sm.SE3.Trans(0.2,0.2,0.45)arrived=Falseenv.add(panda)dt=0.05whilenotarrived:v,arrived=rtb.p_servo(panda.fkine(panda.q),Tep,1)panda.qd=np.linalg.pinv(panda.jacobe(panda.q)) @venv.step(dt)# Uncomment to stop the browser tab from closing# env.hold()
Thenotebooks
folder contains some tutorial Jupyter notebooks which you can browse on GitHub. Additionally, have a look in theexamples
folder for many ready to run examples.
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.
J. Haviland, N. Sünderhauf and P. Corke, "A Holistic Approach to Reactive Mobile Manipulation," inIEEE Robotics and Automation Letters, doi: 10.1109/LRA.2022.3146554. In the video, the robot is controlled using the Robotics toolbox for Python and features a recording from theSwift Simulator.
[Arxiv Paper] [IEEE Xplore] [Project Website] [Video] [Code Example]
J. Haviland and P. Corke, "NEO: A Novel Expeditious Optimisation Algorithm for Reactive Motion Control of Manipulators," inIEEE 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 theSwift 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]
Check out our ICRA 2021 paper onIEEE Xplore or get the PDF fromPeter's website.
If the toolbox helped you in your research, please cite
@inproceedings{rtb, title={Not your grandmother’s toolbox--the Robotics Toolbox reinvented for Python}, author={Corke, Peter and Haviland, Jesse}, booktitle={2021 IEEE International Conference on Robotics and Automation (ICRA)}, pages={11357--11363}, year={2021}, organization={IEEE}}
If you are using the Toolbox in your open source code, feel free to add our badge to your readme!
For the powered by robotics toolbox badge
copy the following
[](https://github.com/petercorke/robotics-toolbox-python)
For the powered by python robotics badge
copy the following
[](https://github.com/petercorke/robotics-toolbox-python)
See the common issues with fixeshere.
About
Robotics Toolbox for Python
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.