Skip to content

Commit b6d66d6

Browse files
committed
Add abort_fn to TeleopPanel, check in loop instead of controller
1 parent b649049 commit b6d66d6

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/mj_viser/teleop_panel.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,15 @@ def __init__(
202202
data: mujoco.MjData,
203203
gripper_body_prefix: str,
204204
arm_label: str = "Arm",
205+
abort_fn: object | None = None,
205206
):
206207
self._arm = arm
207208
self._controller = controller
208209
self._model = model
209210
self._data = data
210211
self._gripper_prefix = gripper_body_prefix
211212
self._arm_label = arm_label
213+
self._abort_fn = abort_fn # callable → bool, checked in teleop loop
212214
self._gizmo = None
213215
self._ghost = None
214216
self._is_teleop_active = False
@@ -348,6 +350,10 @@ def _teleop_loop(self) -> None:
348350
"""Background loop: step controller + sync viewer at ~30 Hz."""
349351
dt = 1.0 / 30.0
350352
while self._is_teleop_active and self._controller.is_active:
353+
# Check abort (Stop button / reset)
354+
if self._abort_fn is not None and self._abort_fn():
355+
self._controller.deactivate()
356+
break
351357
t0 = time.monotonic()
352358
try:
353359
self._controller.step()

0 commit comments

Comments
 (0)