Skip to content

Commit efa25fb

Browse files
committed
update readme
1 parent da7881d commit efa25fb

File tree

1 file changed

+56
-3
lines changed

1 file changed

+56
-3
lines changed

README.md

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Swift
22

3+
[![A Python Robotics Package](https://raw.githubusercontent.com/petercorke/robotics-toolbox-python/master/.github/svg/py_collection.min.svg)](https://github.com/petercorke/robotics-toolbox-python)
4+
[![QUT Centre for Robotics Open Source](https://github.com/qcr/qcr.github.io/raw/master/misc/badge.svg)](https://qcr.github.io)
5+
36
[![PyPI version](https://badge.fury.io/py/swift-sim.svg)](https://badge.fury.io/py/swift-sim)
47
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/swift-sim)](https://img.shields.io/pypi/pyversions/swift-sim)
58
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6-
[![QUT Centre for Robotics Open Source](https://github.com/qcr/qcr.github.io/raw/master/misc/badge.svg)](https://qcr.github.io)
79

810
Swift is a light-weight browser-based simulator built on top of the [Robotics Toolbox for Python](https://github.com/petercorke/robotics-toolbox-python). This simulator provides robotics-specific functionality for rapid prototyping of algorithms, research, and education. Built using Python and Javascript, Swift is cross-platform (Linux, MacOS, and Windows) while also leveraging the ubiquity and support of these languages.
911

@@ -31,6 +33,17 @@ Otherwise, Swift can be install by
3133
pip3 install swift-sim
3234
```
3335

36+
Available options are:
37+
38+
- `nb` provides the ability for Swift to be embedded within a Jupyter Notebook
39+
- `vision` implements an RTC communication strategy allowing for visual feedback from Swift and allows Swift to be run on Google Colab
40+
41+
Put the options in a comma-separated list like
42+
43+
```shell script
44+
pip3 install swift-sim[optionlist]
45+
```
46+
3447
### From GitHub
3548

3649
To install the latest version from GitHub
@@ -63,10 +76,12 @@ We will load a model of the Franka-Emika Panda robot and make it travel towards
6376
import roboticstoolbox as rtb
6477
import spatialmath as sm
6578
import numpy as np
79+
from swift import Swift
80+
6681

6782
# Make and instance of the Swift simulator and open it
68-
env = rtb.backends.Swift()
69-
env.launch()
83+
env = Swift()
84+
env.launch(realtime=True)
7085

7186
# Make a panda model and set its joint angles to the ready joint configuration
7287
panda = rtb.models.Panda()
@@ -94,3 +109,41 @@ while not arrived:
94109
<p align="center">
95110
<img src="./.github/figures/panda.gif">
96111
</p>
112+
113+
### Embed within a Jupyter Notebook
114+
To embed within a Jupyter Notebook Cell, use the `browser="notebook"` option when launching the simulator.
115+
116+
```python
117+
# Try this example within a Jupyter Notebook Cell!
118+
import roboticstoolbox as rtb
119+
import spatialmath as sm
120+
import numpy as np
121+
from swift import Swift
122+
123+
# Make and instance of the Swift simulator and open it
124+
env = Swift()
125+
env.launch(realtime=True, browser="notebook")
126+
127+
# Make a panda model and set its joint angles to the ready joint configuration
128+
panda = rtb.models.Panda()
129+
panda.q = panda.qr
130+
131+
# Set a desired and effector pose an an offset from the current end-effector pose
132+
Tep = panda.fkine(panda.q) * sm.SE3.Tx(0.2) * sm.SE3.Ty(0.2) * sm.SE3.Tz(0.45)
133+
134+
# Add the robot to the simulator
135+
env.add(panda)
136+
137+
# Simulate the robot while it has not arrived at the goal
138+
arrived = False
139+
while not arrived:
140+
141+
# Work out the required end-effector velocity to go towards the goal
142+
v, arrived = rtb.p_servo(panda.fkine(panda.q), Tep, 1)
143+
144+
# Set the Panda's joint velocities
145+
panda.qd = np.linalg.pinv(panda.jacobe(panda.q)) @ v
146+
147+
# Step the simulator by 50 milliseconds
148+
env.step(0.05)
149+
```

0 commit comments

Comments
 (0)