-
-
Notifications
You must be signed in to change notification settings - Fork 621
Backends
The Toolbox supports a number of backends to display a robot animation or to control a physical robot.
By default, only the PyPlot backend is included in the Toolbox install. Swift requires the swift optional extra (pip install roboticstoolbox-python[swift]).
This backend displays the robot as a noodle using matplotlib graphics. matplotlib is the most ubiquitous graphics library for Python and runs on all platforms.
>>> import roboticstoolbox as rtb
>>> p560 = rtb.models.DH.Puma560()
>>> qt = rtb.tools.trajectory.jtraj(p560.qz, p560.qr, 50)
>>> p560.plot(qt.q)

Options exist to:
- attach a velocity or force ellipsoid,
- display link frames and joint axes,
- save the animation to a file as an animated GIF
Swift displays in a web browser tab using three.js. At the moment it only works with models defined using URDF and can use STL or Collada meshes.
>>> import roboticstoolbox as rtb
>>> p560 = rtb.models.URDF.Puma560()
>>> qt = rtb.tools.trajectory.jtraj(p560.qz, p560.qr, 50)
>>> p560.plot(qt.q)
See docs/source/intro.rst for a worked Panda example and a rendered screenshot.
pip install roboticstoolbox-python[swift], or follow the instructions on the Swift home page to install the bleeding-edge version from GitHub.
There's a ROS Connector backend (roboticstoolbox/backends/ROS/ROS.py) — see the separate ROS wiki page (self-labeled work-in-progress).
CoppeliaSim is a mature and capable cross-platform robot simulation environment with a free licence to use for education. There is currently no Connector backend for it in roboticstoolbox/backends/ — this remains a documented gap/TODO, not a hidden feature; if you need it, you'd be writing it from scratch against the Connector API below.
The simplest way is using plot with a backend option as shown above. The alternative is to create a backend environment
from roboticstoolbox.backends.BACKEND import BACKEND
env = BACKEND()
# where BACKEND is PyPlot or Swift
env.launch() # start the backend
env.add(robot) # add a robot to the backend
for ...:
robot.q = some value
env.step()
The backend supports a simple API defined in backends/Connector.py
-
launch()launch the external program with an empty or specific scene as defined by args -
step(dt)requests the external program to make a time step of defined time updating the state of the environment, including all robots, as defined by the robot's actions. -
id = add(object)adds an object to the external environment. If object is a robot, it must be of an appropriate class. This adds the object to a list of which will act upon the step() method being called. This method returns the id of the object. -
remove(id)removes the specified object from the external environment. -
reset()triggers the external program to reset to the original state defined by launch -
restart()request the external program to close and relaunch to the state defined by launch -
close()requests that the external program to gracefully close -
hold()requests that the external program stays open, will prevent Python from exiting the script. Is blocking
- tidy up objects that can be added, they should have a common superclass with abstract methods that addables must have
- teach panel, this is still an underscore function.
-
getframemethod, to return a PIL image for the current frame — not currently implemented onConnectorat all (removed from this page's API list above, it doesn't exist yet). Would need a unified approach across backends if added. - CoppeliaSim backend — still just a placeholder, see above.
- Frequently asked questions (FAQ)
- Documentation Style Guide
- Background
- Key concepts
- Introduction to robot and link classes
- Working with Jupyter
- Working from the command line
- What about Simulink?
- How to contribute
- Contributors