armnet-runtime 0.3.2__tar.gz → 0.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/PKG-INFO +2 -2
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/pyproject.toml +2 -2
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/context.py +187 -36
- armnet_runtime-0.3.4/src/armnet_runtime/depth_view.py +280 -0
- armnet_runtime-0.3.4/src/armnet_runtime/lerobot/__init__.py +52 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/_remote_protocol.py +81 -5
- armnet_runtime-0.3.4/src/armnet_runtime/lerobot/_robot_link.py +256 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/remote_camera.py +19 -0
- armnet_runtime-0.3.4/src/armnet_runtime/lerobot/so101.py +330 -0
- armnet_runtime-0.3.4/src/armnet_runtime/lerobot/yam.py +321 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/variation.py +100 -11
- armnet_runtime-0.3.4/tests/test_armnet_robots.py +583 -0
- armnet_runtime-0.3.4/tests/test_completion.py +134 -0
- armnet_runtime-0.3.4/tests/test_confirm_scene_reset.py +107 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_context_arms.py +21 -1
- armnet_runtime-0.3.4/tests/test_context_camera_mounts.py +61 -0
- armnet_runtime-0.3.4/tests/test_depth_view.py +275 -0
- armnet_runtime-0.3.4/tests/test_persistent_connection.py +213 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_remote_yam.py +6 -2
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_variation.py +65 -10
- armnet_runtime-0.3.2/src/armnet_runtime/lerobot/__init__.py +0 -15
- armnet_runtime-0.3.2/tests/test_completion.py +0 -37
- armnet_runtime-0.3.2/tests/test_persistent_connection.py +0 -113
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/.gitignore +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/LICENSE +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/README.md +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/proto/rerun.proto +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/scripts/gen_proto.sh +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/__init__.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/_rerun_pb2.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/cli.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/decorator.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/env.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/leaderboard.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/import_swap.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/remote_arx5.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/remote_feetech.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/remote_yam.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/markers.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/rerun.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/src/armnet_runtime/volume_sync.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_cell_instrument.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_edge_goal_clamp.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_embodiment.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_leaderboard.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_proxy_method_cache.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_rail_recovery.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_rail_reset_restore.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_robot_telemetry.py +0 -0
- {armnet_runtime-0.3.2 → armnet_runtime-0.3.4}/tests/test_scene_calibration_context.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: armnet-runtime
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: armnet runtime SDK — used by code running inside customer containers on a cell.
|
|
5
5
|
Project-URL: Homepage, https://armnet.dev
|
|
6
6
|
Project-URL: Documentation, https://docs.armnet.dev/packages/runtime/
|
|
@@ -8,7 +8,7 @@ Author: Ville Kuosmanen
|
|
|
8
8
|
License-Expression: Apache-2.0
|
|
9
9
|
License-File: LICENSE
|
|
10
10
|
Requires-Python: <3.13,>=3.12
|
|
11
|
-
Requires-Dist: armnet-core>=0.3.
|
|
11
|
+
Requires-Dist: armnet-core>=0.3.3
|
|
12
12
|
Requires-Dist: protobuf<7,>=5
|
|
13
13
|
Requires-Dist: pydantic<3,>=2.6
|
|
14
14
|
Provides-Extra: dev
|
|
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
|
|
|
6
6
|
name = "armnet-runtime"
|
|
7
7
|
# 0.2.0 follows armnet-core: ctx.cell now carries an environment and hands
|
|
8
8
|
# reset/scoring to it, and CompletionStatus moved to armnet-core.
|
|
9
|
-
version = "0.3.
|
|
9
|
+
version = "0.3.4"
|
|
10
10
|
description = "armnet runtime SDK \u2014 used by code running inside customer containers on a cell."
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
requires-python = ">=3.12,<3.13"
|
|
@@ -15,7 +15,7 @@ license-files = ["LICENSE"]
|
|
|
15
15
|
authors = [{ name = "Ville Kuosmanen" }]
|
|
16
16
|
|
|
17
17
|
dependencies = [
|
|
18
|
-
"armnet-core>=0.3.
|
|
18
|
+
"armnet-core>=0.3.3",
|
|
19
19
|
"pydantic>=2.6,<3",
|
|
20
20
|
# Wire format for Rerun visualization packets (armnet_runtime.rerun).
|
|
21
21
|
"protobuf>=5,<7",
|
|
@@ -69,6 +69,29 @@ _RESET_RAIL_APPROACH_IF_WITHIN = 0.03
|
|
|
69
69
|
_RESET_RAIL_APPROACH_DISTANCE = 0.04
|
|
70
70
|
|
|
71
71
|
|
|
72
|
+
def is_command_safety_violation(exc: BaseException) -> bool:
|
|
73
|
+
"""Whether ``exc`` is the edge rejecting an unsafe commanded motion.
|
|
74
|
+
|
|
75
|
+
That lock lasts until :meth:`Cell.reset` is called with ``unlock=True``.
|
|
76
|
+
A physical stall, an over-current, or a reset timeout is a different trip
|
|
77
|
+
and stays latched.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
pending: list[BaseException | None] = [exc]
|
|
81
|
+
seen: set[int] = set()
|
|
82
|
+
while pending:
|
|
83
|
+
current = pending.pop()
|
|
84
|
+
if current is None or id(current) in seen:
|
|
85
|
+
continue
|
|
86
|
+
seen.add(id(current))
|
|
87
|
+
if "unsafe commanded motion" in str(current):
|
|
88
|
+
return True
|
|
89
|
+
pending.append(current.__cause__)
|
|
90
|
+
if not current.__suppress_context__:
|
|
91
|
+
pending.append(current.__context__)
|
|
92
|
+
return False
|
|
93
|
+
|
|
94
|
+
|
|
72
95
|
class ResetTimeoutException(RuntimeError):
|
|
73
96
|
"""Raised by ``ctx.cell.reset()`` when a manual reset is not actioned in time.
|
|
74
97
|
|
|
@@ -99,6 +122,15 @@ _ROBOT_TELEMETRY_READ_TIMEOUT_S = 1.0
|
|
|
99
122
|
# Throttle interval for teleop-channel error logs (they'd otherwise repeat at
|
|
100
123
|
# the control-loop rate while the channel is down).
|
|
101
124
|
_TELEOP_ERROR_LOG_INTERVAL_S = 5.0
|
|
125
|
+
# The monitor's verdict is in memory on the connector, so a per-tick poll that
|
|
126
|
+
# takes longer than this is treated as "not decided yet" rather than stalling
|
|
127
|
+
# the control loop.
|
|
128
|
+
_COMPLETION_READ_TIMEOUT_S = 1.0
|
|
129
|
+
# The final, blocking completion check is the episode's score, so a transient
|
|
130
|
+
# network failure (a slow name lookup, a dropped connection) is retried rather
|
|
131
|
+
# than failing the episode.
|
|
132
|
+
_FINAL_COMPLETION_ATTEMPTS = 3
|
|
133
|
+
_FINAL_COMPLETION_RETRY_DELAY_S = 1.0
|
|
102
134
|
|
|
103
135
|
|
|
104
136
|
@dataclass
|
|
@@ -195,6 +227,14 @@ class RuntimeRail(_CellDevice):
|
|
|
195
227
|
# job may be running somewhere else entirely (job_position), so keep both:
|
|
196
228
|
# this one is what a varied position is measured against.
|
|
197
229
|
default_position: float = 0.5
|
|
230
|
+
# The last 0-1 position commanded to this carriage through
|
|
231
|
+
# ``_set_rail_targets`` — job start, between-episode reset, or per-episode
|
|
232
|
+
# variation. Every positioning path funnels through that one call, and reset
|
|
233
|
+
# runs before variation, so this is the per-episode "commanded truth"
|
|
234
|
+
# recorded beside the episode. Initialised to ``job_position`` in
|
|
235
|
+
# ``_build_runtime_rails`` so a rail positioned only at job start (no runtime
|
|
236
|
+
# move yet) still reports correctly; updated on every move.
|
|
237
|
+
last_commanded_position: float = 0.5
|
|
198
238
|
|
|
199
239
|
def set(self, position: float) -> None:
|
|
200
240
|
"""Move this rail alone to ``position`` (0..1) and wait until settled.
|
|
@@ -224,20 +264,23 @@ class RuntimeLightbox(_CellDevice):
|
|
|
224
264
|
class RuntimeCameraMount(_CellDevice):
|
|
225
265
|
"""One camera's pan/tilt mount.
|
|
226
266
|
|
|
227
|
-
Only cameras with
|
|
267
|
+
Only cameras with a ``servo_mount`` block have one; a wrist camera rides
|
|
228
268
|
on the arm and does not appear here.
|
|
229
269
|
"""
|
|
230
270
|
|
|
231
271
|
camera: str
|
|
232
272
|
default_pan: float = 90.0
|
|
233
273
|
default_tilt: float = 90.0
|
|
234
|
-
# The cell's
|
|
235
|
-
# Forwarded so the edge can build the mount on
|
|
236
|
-
# not driven yet in this job.
|
|
274
|
+
# The cell's servo_mount block verbatim: serial port, servo ids and
|
|
275
|
+
# measured step ranges. Forwarded so the edge can build the mount on
|
|
276
|
+
# demand for a camera it has not driven yet in this job.
|
|
237
277
|
mount_config: dict[str, Any] = field(default_factory=dict, repr=False)
|
|
238
278
|
|
|
239
279
|
def set(self, pan: float, tilt: float) -> None:
|
|
240
|
-
"""Aim the mount,
|
|
280
|
+
"""Aim the mount, without disturbing its calibrated pose.
|
|
281
|
+
|
|
282
|
+
``pan`` and ``tilt`` are encoder steps.
|
|
283
|
+
"""
|
|
241
284
|
self._owner()._set_camera_mount(self, pan, tilt)
|
|
242
285
|
|
|
243
286
|
|
|
@@ -319,9 +362,8 @@ class Cell:
|
|
|
319
362
|
camera_mounts: dict[str, RuntimeCameraMount] = field(default_factory=dict)
|
|
320
363
|
"""Pan/tilt mounts keyed by camera name.
|
|
321
364
|
|
|
322
|
-
Only cameras the cell config gives
|
|
323
|
-
|
|
324
|
-
immovable.
|
|
365
|
+
Only cameras the cell config gives a mount block appear here, so a wrist
|
|
366
|
+
camera riding on the arm is absent rather than present and immovable.
|
|
325
367
|
"""
|
|
326
368
|
|
|
327
369
|
scene_calibration: Optional[SceneCalibration] = None
|
|
@@ -358,6 +400,10 @@ class Cell:
|
|
|
358
400
|
# the cell program's operator-call endpoint (see is_complete).
|
|
359
401
|
_completion_conn: Any = field(default=None, init=False, repr=False, compare=False)
|
|
360
402
|
_completion_last_error_log: float = field(default=0.0, init=False, repr=False, compare=False)
|
|
403
|
+
# Reused connection for polling the automated completion monitor on the
|
|
404
|
+
# robot connector (see is_complete).
|
|
405
|
+
_monitor_conn: Any = field(default=None, init=False, repr=False, compare=False)
|
|
406
|
+
_monitor_last_error_log: float = field(default=0.0, init=False, repr=False, compare=False)
|
|
361
407
|
# Most-recent completion outcome seen during the current rollout, plus an
|
|
362
408
|
# optional sink (installed by Context.init_leaderboard) that records each
|
|
363
409
|
# rollout's cell-scored outcome. Kept here so rollout_end can record the
|
|
@@ -582,7 +628,7 @@ class Cell:
|
|
|
582
628
|
self._instrumented.close()
|
|
583
629
|
self._instrumented = None
|
|
584
630
|
|
|
585
|
-
def reset(self, *, confirm: Optional[bool] = None) -> None:
|
|
631
|
+
def reset(self, *, confirm: Optional[bool] = None, unlock: bool = False) -> None:
|
|
586
632
|
"""Restore the workspace to the state this task starts from.
|
|
587
633
|
|
|
588
634
|
The default asks the cell's environment what that takes. A BusyBox
|
|
@@ -594,6 +640,12 @@ class Cell:
|
|
|
594
640
|
a job's own setup needs checking — or ``confirm=False`` to forbid one on
|
|
595
641
|
an uninstrumented cell.
|
|
596
642
|
|
|
643
|
+
Pass ``unlock=True`` after a command-safety trip (the edge rejected an
|
|
644
|
+
unsafe goal and stopped accepting motion). The lock is released before
|
|
645
|
+
the arm is returned to rest, so the same job can drive the next
|
|
646
|
+
rollout. Other trips — a stalled joint, an over-current, a reset
|
|
647
|
+
timeout — are not cleared this way.
|
|
648
|
+
|
|
597
649
|
The job's ``disable_automated_reset`` argument forces the confirmation on
|
|
598
650
|
for every reset, so a caller that passes nothing still gets an operator.
|
|
599
651
|
|
|
@@ -602,6 +654,8 @@ class Cell:
|
|
|
602
654
|
to the position selected for this job's episodes.
|
|
603
655
|
"""
|
|
604
656
|
|
|
657
|
+
if unlock:
|
|
658
|
+
self._clear_safety_interlock()
|
|
605
659
|
if self.disable_automated_reset and confirm is None:
|
|
606
660
|
confirm = True
|
|
607
661
|
if self._instrumented is not None:
|
|
@@ -765,6 +819,10 @@ class Cell:
|
|
|
765
819
|
raise RuntimeError("robot connector is unavailable; cannot position rail")
|
|
766
820
|
for rail, raw_target in targets:
|
|
767
821
|
target = max(0.0, min(1.0, float(raw_target)))
|
|
822
|
+
# Record the commanded position before the move so the episode saved
|
|
823
|
+
# after this carries the fraction the carriage was driven to, even if
|
|
824
|
+
# the move itself raises partway through.
|
|
825
|
+
rail.last_commanded_position = target
|
|
768
826
|
request: dict[str, Any] = {
|
|
769
827
|
"op": "rail_set",
|
|
770
828
|
"pos": target,
|
|
@@ -866,6 +924,17 @@ class Cell:
|
|
|
866
924
|
)
|
|
867
925
|
time.sleep(_RAIL_POLL_INTERVAL_S)
|
|
868
926
|
|
|
927
|
+
def _clear_safety_interlock(self) -> None:
|
|
928
|
+
"""Release a command-safety lock on the robot connector, if there is one."""
|
|
929
|
+
|
|
930
|
+
if not self.robot_port or not _looks_like_connector_endpoint(self.robot_port):
|
|
931
|
+
return
|
|
932
|
+
response = _connector_request(self.robot_port, {"op": "clear_interlock"})
|
|
933
|
+
if not response.get("ok"):
|
|
934
|
+
raise RuntimeError(
|
|
935
|
+
response.get("error", "could not clear the safety interlock")
|
|
936
|
+
)
|
|
937
|
+
|
|
869
938
|
def _reset_cell(self, confirm: bool = True) -> None:
|
|
870
939
|
"""Return the robot to rest, then block until the operator confirms.
|
|
871
940
|
|
|
@@ -901,17 +970,26 @@ class Cell:
|
|
|
901
970
|
if not confirm:
|
|
902
971
|
return
|
|
903
972
|
|
|
904
|
-
self.
|
|
973
|
+
self._await_operator_reset()
|
|
905
974
|
|
|
906
975
|
def confirm_scene_reset(self) -> None:
|
|
907
|
-
"""
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
976
|
+
"""Ask the operator to stage the scene and confirm, moving nothing.
|
|
977
|
+
|
|
978
|
+
:meth:`reset` always returns the arm to rest before any operator
|
|
979
|
+
confirmation. A job that has already moved the arms to a
|
|
980
|
+
policy-specific start pose wants the staging prompt alone: returning
|
|
981
|
+
to rest would undo that pose, and ramping to it only after staging
|
|
982
|
+
could sweep the arm through the objects the operator just placed.
|
|
983
|
+
Call :meth:`reset` with ``confirm=False`` first, command the start
|
|
984
|
+
pose, then call this.
|
|
914
985
|
"""
|
|
986
|
+
|
|
987
|
+
self._report_progress("Waiting for workspace reset...")
|
|
988
|
+
self._await_operator_reset()
|
|
989
|
+
|
|
990
|
+
def _await_operator_reset(self) -> None:
|
|
991
|
+
# Operator confirmation on the cell-served operator-call endpoint
|
|
992
|
+
# (fallback to the dev local-control endpoint).
|
|
915
993
|
request = {"op": "reset", "request": {"kind": "manual"}}
|
|
916
994
|
operator_endpoint = self.operator_call_endpoint or self.local_control_endpoint
|
|
917
995
|
if operator_endpoint:
|
|
@@ -968,12 +1046,45 @@ class Cell:
|
|
|
968
1046
|
raise RuntimeError(response.get("error", "local completion check failed"))
|
|
969
1047
|
return _completion_from_response(response)
|
|
970
1048
|
if self.robot_port and _looks_like_connector_endpoint(self.robot_port):
|
|
971
|
-
|
|
1049
|
+
if block:
|
|
1050
|
+
response = _final_completion_request(self.robot_port, request)
|
|
1051
|
+
else:
|
|
1052
|
+
response = self._poll_completion_monitor(request)
|
|
1053
|
+
if response is None:
|
|
1054
|
+
return CompletionStatus(complete=False, success=False)
|
|
972
1055
|
if not response.get("ok"):
|
|
973
1056
|
raise RuntimeError(response.get("error", "cell completion check failed"))
|
|
974
1057
|
return _completion_from_response(response)
|
|
975
1058
|
return CompletionStatus(complete=False, success=False)
|
|
976
1059
|
|
|
1060
|
+
def _poll_completion_monitor(self, request: dict[str, Any]) -> Optional[dict[str, Any]]:
|
|
1061
|
+
"""The monitor's current verdict, or None when it could not be read.
|
|
1062
|
+
|
|
1063
|
+
Polled every control tick, so it holds one connection open: opening one
|
|
1064
|
+
per tick looks the connector's host name up again each time, and a
|
|
1065
|
+
single failed lookup would end the episode. An unread verdict counts as
|
|
1066
|
+
"not decided yet", and the final blocking check asks again.
|
|
1067
|
+
"""
|
|
1068
|
+
|
|
1069
|
+
endpoint = self.robot_port
|
|
1070
|
+
if self._monitor_conn is None or self._monitor_conn.endpoint != endpoint:
|
|
1071
|
+
if self._monitor_conn is not None:
|
|
1072
|
+
self._monitor_conn.close()
|
|
1073
|
+
self._monitor_conn = _TeleopConnection(endpoint, timeout=_COMPLETION_READ_TIMEOUT_S)
|
|
1074
|
+
|
|
1075
|
+
try:
|
|
1076
|
+
return self._monitor_conn.request(request)
|
|
1077
|
+
except Exception as exc: # noqa: BLE001
|
|
1078
|
+
now = time.monotonic()
|
|
1079
|
+
if now - self._monitor_last_error_log >= _TELEOP_ERROR_LOG_INTERVAL_S:
|
|
1080
|
+
self._monitor_last_error_log = now
|
|
1081
|
+
logger.warning(
|
|
1082
|
+
"completion check on %s failed (treating as not complete): %r",
|
|
1083
|
+
endpoint,
|
|
1084
|
+
exc,
|
|
1085
|
+
)
|
|
1086
|
+
return None
|
|
1087
|
+
|
|
977
1088
|
def _human_completion(self) -> Optional[bool]:
|
|
978
1089
|
"""Return the operator's reported success/fail, or None if none pending.
|
|
979
1090
|
|
|
@@ -1302,6 +1413,22 @@ def _connector_request(
|
|
|
1302
1413
|
return json.loads(data.decode("utf-8"))
|
|
1303
1414
|
|
|
1304
1415
|
|
|
1416
|
+
def _final_completion_request(endpoint: str, request: dict[str, Any]) -> dict[str, Any]:
|
|
1417
|
+
for attempt in range(1, _FINAL_COMPLETION_ATTEMPTS):
|
|
1418
|
+
try:
|
|
1419
|
+
return _connector_request(endpoint, request)
|
|
1420
|
+
except OSError as exc:
|
|
1421
|
+
logger.warning(
|
|
1422
|
+
"final completion check on %s failed (attempt %d of %d), retrying: %r",
|
|
1423
|
+
endpoint,
|
|
1424
|
+
attempt,
|
|
1425
|
+
_FINAL_COMPLETION_ATTEMPTS,
|
|
1426
|
+
exc,
|
|
1427
|
+
)
|
|
1428
|
+
time.sleep(_FINAL_COMPLETION_RETRY_DELAY_S)
|
|
1429
|
+
return _connector_request(endpoint, request)
|
|
1430
|
+
|
|
1431
|
+
|
|
1305
1432
|
def _connect_connector(endpoint: str) -> socket.socket:
|
|
1306
1433
|
if endpoint.startswith("tcp://"):
|
|
1307
1434
|
parsed = urlparse(endpoint)
|
|
@@ -1829,6 +1956,11 @@ def _build_runtime_rails(
|
|
|
1829
1956
|
) from exc
|
|
1830
1957
|
if cell_config.rail is not None:
|
|
1831
1958
|
rail = cell_config.rail
|
|
1959
|
+
job_position = (
|
|
1960
|
+
override
|
|
1961
|
+
if override is not None
|
|
1962
|
+
else _rail_fraction(rail.default_position_percent)
|
|
1963
|
+
)
|
|
1832
1964
|
return (
|
|
1833
1965
|
RuntimeRail(
|
|
1834
1966
|
servo_id=int(rail.servo_id),
|
|
@@ -1836,11 +1968,8 @@ def _build_runtime_rails(
|
|
|
1836
1968
|
left_dir=int(rail.left_dir),
|
|
1837
1969
|
home_end=str(getattr(rail, "home_end", "right")),
|
|
1838
1970
|
default_position=_rail_fraction(rail.default_position_percent),
|
|
1839
|
-
job_position=
|
|
1840
|
-
|
|
1841
|
-
if override is not None
|
|
1842
|
-
else _rail_fraction(rail.default_position_percent)
|
|
1843
|
-
),
|
|
1971
|
+
job_position=job_position,
|
|
1972
|
+
last_commanded_position=job_position,
|
|
1844
1973
|
),
|
|
1845
1974
|
)
|
|
1846
1975
|
rails: list[RuntimeRail] = []
|
|
@@ -1848,6 +1977,11 @@ def _build_runtime_rails(
|
|
|
1848
1977
|
arm_rail = getattr(arm, "rail", None)
|
|
1849
1978
|
if arm_rail is None:
|
|
1850
1979
|
continue
|
|
1980
|
+
job_position = (
|
|
1981
|
+
override
|
|
1982
|
+
if override is not None
|
|
1983
|
+
else _rail_fraction(arm_rail.default_position_percent)
|
|
1984
|
+
)
|
|
1851
1985
|
rails.append(
|
|
1852
1986
|
RuntimeRail(
|
|
1853
1987
|
servo_id=int(arm_rail.servo_id),
|
|
@@ -1856,11 +1990,8 @@ def _build_runtime_rails(
|
|
|
1856
1990
|
home_end=str(getattr(arm_rail, "home_end", "right")),
|
|
1857
1991
|
arm=arm_name,
|
|
1858
1992
|
default_position=_rail_fraction(arm_rail.default_position_percent),
|
|
1859
|
-
job_position=
|
|
1860
|
-
|
|
1861
|
-
if override is not None
|
|
1862
|
-
else _rail_fraction(arm_rail.default_position_percent)
|
|
1863
|
-
),
|
|
1993
|
+
job_position=job_position,
|
|
1994
|
+
last_commanded_position=job_position,
|
|
1864
1995
|
)
|
|
1865
1996
|
)
|
|
1866
1997
|
return tuple(rails)
|
|
@@ -1892,13 +2023,21 @@ def _build_runtime_camera_mounts(
|
|
|
1892
2023
|
return {}
|
|
1893
2024
|
mounts: dict[str, RuntimeCameraMount] = {}
|
|
1894
2025
|
for name, camera in (cell_config.camera_configs or {}).items():
|
|
1895
|
-
|
|
2026
|
+
if not isinstance(camera, dict):
|
|
2027
|
+
continue
|
|
2028
|
+
mount = camera.get("arducam_mount")
|
|
2029
|
+
if not isinstance(mount, dict):
|
|
2030
|
+
mount = camera.get("servo_mount")
|
|
1896
2031
|
if not isinstance(mount, dict):
|
|
1897
2032
|
continue
|
|
2033
|
+
# Mid-travel differs by generation: 90 degrees on the hobby mount,
|
|
2034
|
+
# half an encoder turn on a serial one. Only reached by a mount block
|
|
2035
|
+
# that records no aim at all.
|
|
2036
|
+
centre = 2048.0 if mount.get("port") else 90.0
|
|
1898
2037
|
mounts[name] = RuntimeCameraMount(
|
|
1899
2038
|
camera=name,
|
|
1900
|
-
default_pan=float(mount.get("pan",
|
|
1901
|
-
default_tilt=float(mount.get("tilt",
|
|
2039
|
+
default_pan=float(mount.get("pan", centre)),
|
|
2040
|
+
default_tilt=float(mount.get("tilt", centre)),
|
|
1902
2041
|
mount_config=dict(mount),
|
|
1903
2042
|
)
|
|
1904
2043
|
return mounts
|
|
@@ -1974,12 +2113,24 @@ def _build_camera_config(config: Any) -> Any:
|
|
|
1974
2113
|
return config
|
|
1975
2114
|
|
|
1976
2115
|
camera_type = str(config.get("type", "opencv")).lower()
|
|
1977
|
-
# Strip keys that are not OpenCVCameraConfig params
|
|
1978
|
-
#
|
|
1979
|
-
#
|
|
1980
|
-
|
|
2116
|
+
# Strip keys that are not OpenCVCameraConfig params. Mount blocks are only
|
|
2117
|
+
# used by the edge connector; id_path is the USB port used at provisioning
|
|
2118
|
+
# time to create the /dev/video_<name> symlink. A Pi CSI camera is still
|
|
2119
|
+
# described to LeRobot as an OpenCV camera — the edge swaps in PiCamera
|
|
2120
|
+
# from the cell config's type. use_depth and serial_number tell the edge to
|
|
2121
|
+
# open a RealSense; the job camera is still an OpenCV config, and depth is
|
|
2122
|
+
# read from the remote camera object rather than from these fields.
|
|
2123
|
+
_NON_CAMERA_KEYS = {
|
|
2124
|
+
"type",
|
|
2125
|
+
"arducam_mount",
|
|
2126
|
+
"servo_mount",
|
|
2127
|
+
"id_path",
|
|
2128
|
+
"use_depth",
|
|
2129
|
+
"serial_number",
|
|
2130
|
+
}
|
|
2131
|
+
_OPENCV_SHAPED = {"opencv", "pi", "picam", "picamera", "picamera2", "csi"}
|
|
1981
2132
|
kwargs = {key: value for key, value in config.items() if key not in _NON_CAMERA_KEYS}
|
|
1982
|
-
if camera_type
|
|
2133
|
+
if camera_type not in _OPENCV_SHAPED:
|
|
1983
2134
|
return config
|
|
1984
2135
|
|
|
1985
2136
|
try:
|