Skip to content

Commit 6412cfa

Browse files
committed
pyplot name change
1 parent d5fce27 commit 6412cfa

File tree

2 files changed

+45
-17
lines changed

2 files changed

+45
-17
lines changed

examples/RRMC_swift.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
"""
3+
@author Jesse Haviland
4+
"""
5+
6+
import roboticstoolbox as rp
7+
import spatialmath as sm
8+
import numpy as np
9+
10+
env = rp.backends.Swift()
11+
env.launch()
12+
13+
panda = rp.models.Panda()
14+
panda.q = panda.qr
15+
16+
Tep = panda.fkine() * sm.SE3.Tx(-0.2) * sm.SE3.Ty(0.2) * sm.SE3.Tz(0.2)
17+
18+
arrived = False
19+
env.add(panda)
20+
21+
dt = 0.05
22+
23+
while not arrived:
24+
25+
v, arrived = rp.p_servo(panda.fkine(), Tep, 1)
26+
panda.qd = np.linalg.pinv(panda.jacobe()) @ v
27+
env.step(dt)

roboticstoolbox/backends/PyPlot/PyPlot.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from roboticstoolbox.backends.Connector import Connector
99
import matplotlib
1010
import matplotlib.pyplot as plt
11-
import signal
1211
from roboticstoolbox.backends.PyPlot.RobotPlot import RobotPlot
1312
from roboticstoolbox.backends.PyPlot.EllipsePlot import EllipsePlot
1413
from spatialmath.base.argcheck import getvector
@@ -30,7 +29,7 @@ class PyPlot(Connector):
3029
Graphical backend using matplotlib
3130
3231
matplotlib is a common and highly portable graphics library for Python,
33-
but has relatively limited 3D capability.
32+
but has relatively limited 3D capability.
3433
3534
Example:
3635
@@ -48,7 +47,7 @@ class PyPlot(Connector):
4847
4948
.. note:: PyPlot is the default backend, and ``robot.plot(q)`` effectively
5049
performs lines 7-8 above.
51-
50+
5251
"""
5352

5453
def __init__(self):
@@ -75,9 +74,9 @@ def launch(self, name=None, limits=None):
7574
labels = ['X', 'Y', 'Z']
7675

7776
if name is not None:
78-
self.fig = plt.figure()
77+
self.fig = plt.figure(name)
7978
else:
80-
self.fig = plt.figure()
79+
self.fig = plt.figure('Robotics Toolbox for Python')
8180

8281
self.fig.subplots_adjust(left=-0.09, bottom=0, top=1, right=0.99)
8382

@@ -113,18 +112,18 @@ def step(self, dt=50):
113112
114113
:param dt: time step in milliseconds, defaults to 50
115114
:type dt: int, optional
116-
115+
117116
``env.step(args)`` triggers an update of the 3D scene in the matplotlib
118117
window referenced by ``env``.
119118
120-
.. note::
119+
.. note::
121120
122121
- Each robot in the scene is updated based on
123122
their control type (position, velocity, acceleration, or torque).
124123
- Upon acting, the other three of the four control types will be
125-
updated in the internal state of the robot object.
126-
- The control type is defined by the robot object, and not all robot
127-
objects support all control types.
124+
updated in the internal state of the robot object.
125+
- The control type is defined by the robot object, and not all
126+
robot objects support all control types.
128127
- Execution is blocked for the specified interval
129128
130129
"""
@@ -160,8 +159,8 @@ def restart(self):
160159
Restart the graphics display
161160
162161
``env.restart()`` triggers a restart of the matplotlib view referenced
163-
by ``env``. It is closed and relaunched to the original state defined by
164-
``launch()``.
162+
by ``env``. It is closed and relaunched to the original state defined
163+
by ``launch()``.
165164
166165
"""
167166
# TODO what does this actually do for matplotlib??
@@ -205,11 +204,12 @@ def add(
205204
:param name: [description], defaults to True
206205
:type name: bool, optional
207206
208-
``id = env.add(robot)`` adds the ``robot`` to the graphical environment.
207+
``id = env.add(robot)`` adds the ``robot`` to the graphical
208+
environment.
209209
210210
.. note::
211211
212-
- ``robot`` must be of an appropriate class.
212+
- ``robot`` must be of an appropriate class.
213213
- Adds the robot object to a list of robots which will be updated
214214
when the ``step()`` method is called.
215215
@@ -239,18 +239,19 @@ def remove(self):
239239
"""
240240
Remove a robot to the graphical scene
241241
242-
:param id: The id of the robot to remove. Can be either the DHLink or
242+
:param id: The id of the robot to remove. Can be either the DHLink or
243243
GraphicalRobot
244244
:type id: class:`~roboticstoolbox.robot.DHRobot.DHRobot`,
245245
class:`roboticstoolbox.backends.VPython.graphics_robot.GraphicalRobot`
246246
:param fig_num: The canvas index to delete the robot from, defaults to
247247
the initial one
248248
:type fig_num: int, optional
249-
:raises ValueError: Figure number must be between 0 and total number
249+
:raises ValueError: Figure number must be between 0 and total number
250250
of canvases
251251
:raises TypeError: Input must be a DHLink or GraphicalRobot
252252
253-
``env.remove(robot)`` removes the ``robot`` from the graphical environment.
253+
``env.remove(robot)`` removes the ``robot`` from the graphical
254+
environment.
254255
"""
255256
# TODO should be an id to remove?
256257

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy