-
Notifications
You must be signed in to change notification settings - Fork 35
fix(policies/lerobot_async): rename_map renames the camera it declares #3496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cagataycali
merged 3 commits into
strands-labs:main
from
shipitfast:fix/732-lerobot-async-rename-map-client-side
Sep 17, 2026
+81
−10
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
d6b0838
fix(policies/lerobot_async): rename_map renames the camera it declares
shipitfast 820ab5d
fix(policies/lerobot_async): changelog fragment for the camera rename
shipitfast f21c572
review(lerobot_async): R1 -- rename_map Args entry + docs describe cl…
strands-agent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
changelog.d/3496-lerobot-async-rename-map-renames-the-camera-it-declares.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ### Fixed: `lerobot_async` `rename_map` renames the camera it declares | ||
|
|
||
| Passing `rename_map={"observation.images.front": "observation.images.laptop"}` to `create_policy("lerobot_async", ...)` did not reach a stock lerobot `PolicyServer` as a rename: the client declared the camera under the robot's name and forwarded the map, but the server resizes every declared image by the checkpoint's own image features before its rename step runs, so the renamed camera was a `KeyError` on the server and every `get_actions` raised "server returned no actions". The client now applies an image rename itself, declaring and sending the camera under the model's name, so a checkpoint trained with `observation.images.laptop` is reachable from a robot whose camera is called `front`, as the docs describe. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
tests/policies/lerobot_async/test_rename_map_renames_the_camera_the_server_resizes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| """A ``rename_map`` camera entry is applied before the server resizes the image. | ||
|
|
||
| lerobot's ``PolicyServer`` runs ``prepare_raw_observation`` on every declared | ||
| ``observation.images.<key>`` and looks the key up in the checkpoint's own image | ||
| features to pick the resize target - BEFORE the ``RenameObservationsProcessorStep`` | ||
| that ``rename_map`` configures. A camera declared under the robot's name is a | ||
| ``KeyError`` there (``Error in StreamActions: 'observation.images.front'`` on a | ||
| stock server), and the client raises "server returned no actions". | ||
|
|
||
| So the client applies an image rename itself: the handshake declares the | ||
| model's feature name and the raw observation carries the image under the | ||
| matching wire key. Fails on pre-fix code, which declared and sent ``front``. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| pytest.importorskip("lerobot") | ||
|
|
||
| import numpy as np | ||
|
cagataycali marked this conversation as resolved.
|
||
|
|
||
| from strands_robots.policies.lerobot_async import LerobotAsyncPolicy | ||
|
|
||
| STATE_KEYS = ["j0", "j1"] | ||
|
|
||
|
|
||
| def _policy() -> LerobotAsyncPolicy: | ||
| policy = LerobotAsyncPolicy( | ||
| server_address="h:1", | ||
| policy_type="act", | ||
| pretrained_name_or_path="x/y", | ||
| rename_map={"observation.images.front": "observation.images.laptop"}, | ||
| ) | ||
| policy.set_robot_state_keys(STATE_KEYS) | ||
| return policy | ||
|
|
||
|
|
||
| def _observation() -> dict[str, object]: | ||
| obs: dict[str, object] = {k: 0.0 for k in STATE_KEYS} | ||
| obs["front"] = np.zeros((8, 8, 3), dtype=np.uint8) | ||
| obs["wrist"] = np.zeros((8, 8, 3), dtype=np.uint8) | ||
| return obs | ||
|
|
||
|
|
||
| def test_handshake_declares_the_model_camera_name() -> None: | ||
| features = _policy()._build_lerobot_features(_observation()) | ||
| image_keys = sorted(k for k in features if k.startswith("observation.images.")) | ||
| assert image_keys == ["observation.images.laptop", "observation.images.wrist"] | ||
|
|
||
|
|
||
| def test_raw_observation_carries_the_image_under_the_model_name() -> None: | ||
| raw = _policy()._to_raw_observation(_observation(), "") | ||
| assert "laptop" in raw and "front" not in raw | ||
| assert "wrist" in raw | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.