-
Notifications
You must be signed in to change notification settings - Fork 687
feat: xarm manipulator adapter improvement #2425
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
Open
TomCC7
wants to merge
7
commits into
main
Choose a base branch
from
cc/feat/xarm-manipulator-updates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
321724f
fix: align keyboard teleop with live arm state
TomCC7 245583c
feat: add xarm adapter lifecycle
TomCC7 126ac0e
fix: xarm initial joints in degrees and motion enable on stop
TomCC7 d33a471
refactor: simplify activate/deactivate calls in coordinator
TomCC7 7be05cd
fix: address lifecycle review feedback
TomCC7 2488b08
Merge branch 'main' into cc/feat/xarm-manipulator-updates
TomCC7 2d87547
fix: add manipulator adapter lifecycle methods
TomCC7 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
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 |
|---|---|---|
|
|
@@ -64,6 +64,7 @@ yolo11n.pt | |
| .envrc | ||
| .claude | ||
| **/CLAUDE.md | ||
| .omo/ | ||
| .direnv/ | ||
|
|
||
| /logs | ||
|
|
||
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| # Copyright 2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing_extensions import override | ||
|
|
||
| from dimos.hardware.manipulators.a750.adapter import A750Adapter | ||
| from dimos.hardware.manipulators.openarm.adapter import OpenArmAdapter | ||
| from dimos.hardware.manipulators.piper.adapter import PiperAdapter | ||
|
|
||
|
|
||
| class _PiperSdk: | ||
| def __init__(self) -> None: | ||
| self.actions: list[str] = [] | ||
|
|
||
| def EnablePiper(self) -> bool: | ||
| self.actions.append("enable") | ||
| return True | ||
|
|
||
| def MotionCtrl_2(self, **_: object) -> None: | ||
| self.actions.append("position_mode") | ||
|
|
||
| def EmergencyStop(self) -> None: | ||
| self.actions.append("stop") | ||
|
|
||
| def DisablePiper(self) -> None: | ||
| self.actions.append("disable") | ||
|
|
||
|
|
||
| class _LifecyclePiperAdapter(PiperAdapter): | ||
| def use_sdk(self, sdk: _PiperSdk) -> None: | ||
| self._sdk: _PiperSdk | None | ||
| self._sdk = sdk | ||
|
|
||
|
|
||
| def test_piper_lifecycle_enables_then_stops_and_disables() -> None: | ||
| sdk = _PiperSdk() | ||
| adapter = _LifecyclePiperAdapter() | ||
| adapter.use_sdk(sdk) | ||
|
|
||
| assert adapter.activate() | ||
| assert adapter.deactivate() | ||
| assert sdk.actions == ["enable", "position_mode", "stop", "disable"] | ||
|
|
||
|
|
||
| class _OpenArmLifecycle: | ||
| def __init__(self) -> None: | ||
| self.actions: list[str] = [] | ||
|
|
||
| def enable_all(self) -> None: | ||
| self.actions.append("enable") | ||
|
|
||
| def disable_all(self) -> None: | ||
| self.actions.append("disable") | ||
|
|
||
|
|
||
| class _LifecycleOpenArmAdapter(OpenArmAdapter): | ||
| def __init__(self, lifecycle: _OpenArmLifecycle) -> None: | ||
| super().__init__() | ||
| self._lifecycle: _OpenArmLifecycle | ||
| self._lifecycle = lifecycle | ||
|
|
||
| @override | ||
| def read_joint_positions(self) -> list[float]: | ||
| return [0.0] * 7 | ||
|
|
||
| @override | ||
| def _compute_gravity_torques(self, q: list[float]) -> list[float]: | ||
| return [0.0] * len(q) | ||
|
|
||
| @override | ||
| def write_enable(self, enable: bool) -> bool: | ||
| if enable: | ||
| self._lifecycle.enable_all() | ||
| else: | ||
| self._lifecycle.disable_all() | ||
| return True | ||
|
|
||
| @override | ||
| def write_stop(self) -> bool: | ||
| self._lifecycle.actions.append("hold") | ||
| return True | ||
|
|
||
|
|
||
| def test_openarm_lifecycle_enables_then_holds_and_disables() -> None: | ||
| lifecycle = _OpenArmLifecycle() | ||
| adapter = _LifecycleOpenArmAdapter(lifecycle) | ||
|
|
||
| assert adapter.activate() | ||
| assert adapter.deactivate() | ||
| assert lifecycle.actions == ["enable", "hold", "disable"] | ||
|
|
||
|
|
||
| class _A750Robot: | ||
| def __init__(self) -> None: | ||
| self.actions: list[str] = [] | ||
|
|
||
| def start_control_loop(self) -> None: | ||
| self.actions.append("start") | ||
|
|
||
| def stop_control_loop(self) -> None: | ||
| self.actions.append("stop") | ||
|
|
||
|
|
||
| class _LifecycleA750Adapter(A750Adapter): | ||
| def use_robot(self, robot: _A750Robot) -> None: | ||
| self._robot: _A750Robot | None | ||
| self._connected: bool | ||
| self._robot = robot | ||
| self._connected = True | ||
|
|
||
|
|
||
| def test_a750_lifecycle_starts_then_stops_control_loop() -> None: | ||
| robot = _A750Robot() | ||
| adapter = _LifecycleA750Adapter() | ||
| adapter.use_robot(robot) | ||
|
|
||
| assert adapter.activate() | ||
| assert adapter.deactivate() | ||
| assert robot.actions == ["start", "stop"] |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventsclass variable is shared across all instancesevents: list[str] = []is a class-level mutable attribute. Every instance ofLifecycleAdapterappends to the same list. In this particular test only one instance is created, so it passes today, but if a second adapter instance were ever created (e.g., in a retry path inside the coordinator), the assertion on line 230 would see duplicate entries and fail unexpectedly. Prefer initialising it in__init__to make the list per-instance.