8000 hold addded to mandatory backend api · A905275/robotics-toolbox-python@997cd34 · GitHub
[go: up one dir, main page]

Skip to content

Commit 997cd34

Browse files
committed
hold addded to mandatory backend api
1 parent b493902 commit 997cd34

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

examples/RRMC_swift.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@
2525
v, arrived = rp.p_servo(panda.fkine(), Tep, 1)
2626
panda.qd = np.linalg.pinv(panda.jacobe()) @ v
2727
env.step(dt)
28+
29+
# Uncomment to stop the browser tab from closing
30+
# env.hold()

roboticstoolbox/backends/Connector.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,14 @@ def remove(self):
9595
'''
9696

9797
pass
98+
99+
@abstractmethod
100+
def hold(self):
101+
'''
102+
hold() keeps the backend open i.e. stops the program from closing once
103+
the main script has finished. This method may need keep an even loop
104+
running for the backend to keep it responsive.
105+
106+
'''
107+
108+
pass

roboticstoolbox/backends/PyPlot/PyPlot.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ def remove(self):
258258
super().remove()
259259

260260
def hold(self): # pragma: no cover
261+
'''
262+
hold() keeps the plot open i.e. stops the plot from closing once
263+
the main script has finished.
264+
265+
'''
266+
261267
# signal.setitimer(signal.ITIMER_REAL, 0)
262268
plt.ioff()
263269

roboticstoolbox/backends/Swift/Swift.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,16 @@ def remove(self):
260260

261261
super().remove()
262262

263+
def hold(self): # pragma: no cover
264+
'''
265+
hold() keeps the browser tab open i.e. stops the browser tab from
266+
closing once the main script has finished.
267+
268+
'''
269+
270+
while True:
271+
time.sleep(1)
272+
263273
def start_recording(self, file_name, framerate):
264274
"""
265275
Start recording the canvas in the Swift simulator

roboticstoolbox/backends/VPython/VPython.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,16 @@ def remove(self, id, fig_num=0):
341341
else:
342342
raise TypeError("Input must be a DHLink or GraphicalRobot")
343343

344+
def hold(self): # pragma: no cover
345+
'''
346+
hold() keeps the tab open i.e. stops the tab from closing once
347+
the main script has finished.
348+
349+
'''
350+
351+
while True:
352+
pass
353+
344354
#
345355
# Private Methods
346356
#

0 commit comments

Comments
 (0)
0