You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix Python 3.11 compatibility and shared DualShock defaults - #4025
Fixes#4023. Use dataclass factories and a fresh default teleop configuration to prevent import errors and shared controller mappings. Order the teleoperation bases so the ROS Node comes before ABC, preserving import compatibility with newer ROS 2.
Checklist
Formatting and pre-commit checks
Regression tests for independent default configurations
Migration note for ROS Node inheritance
Tutorials and GUI screenshots (not applicable)
Review another open PR
Validation: two Python 3.12 tests pass after the fix; both previously failed at import. ROS imports were stubbed locally and the teleop initialization was mocked. Full ROS integration remains pending CI.
Rolling CI follow-up
The Rolling test job exposed an existing incompatible MRO: rclpy Node now derives from BaseNode, which derives from ABC. With ABC first, importing TeleopDevice fails before the new tests can run. Commit ee05ca5 puts Node first in the implementation and stub and tests that TeleopDevice remains abstract and its concrete DualShock subclass does not. The two original tests fail at import with the ABC-derived Node stand-in before this change; afterward all three tests pass with each of the ordinary and ABC-derived Node stand-ins (six passes). Changed-file pre-commit checks pass. Real ROS integration requires hosted CI.
The three Lyrical jobs in run 46210307095 fail earlier while linking moveit_msgs because libfastcdr.so.2.3.7 is absent from the ROS installation. No dependency or workflow changes are included.
Summary by CodeRabbit
Bug Fixes
Fixed DualShock configuration defaults so separate controllers and teleoperation instances no longer share mutable settings.
Improved compatibility for Python teleoperation devices with newer ROS 2 versions.
Documentation
Added guidance for custom teleoperation devices on ROS 2 versions where rclpy.Node inherits from ABC.
No actionable comments were generated in the recent review.
Walkthrough
The PS4 DualShock client now creates independent default mappings and teleoperation configurations. The TeleopDevice base-class order is updated for ROS Rolling compatibility, with a migration note and unit test coverage.
DualShock mappings use default factories, and PS4DualShockTeleop creates a fresh configuration when none is supplied. Type stubs reflect the optional defaults. Unit tests cover independent mappings and configurations, explicit configuration handling, and CMake registers the test.
Teleoperation inheritance compatibility
Layer / File(s)
Summary
Node and ABC base-class order moveit_py/moveit/servo_client/teleop.py, moveit_py/moveit/servo_client/teleop.pyi, moveit_py/test/unit/test_dualshock_defaults.py, MIGRATION.md
TeleopDevice lists Node before ABC in its implementation and type stub. A unit test checks its abstract status, and the migration notes describe the ordering for custom devices.
This change fixes the Python 3.11+ import failure in the PS4 DualShock client and stops default mappings and teleoperation configurations from being shared between instances. It also reorders the TeleopDevice base classes for ROS Rolling compatibility. No merge-blocking risk is evident; full ROS integration still depends on CI.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names two changes that the changeset does make: Python 3.11 compatibility fixes (the mutable dataclass defaults are replaced with field(default_factory=...), and the TeleopDevice base-class …
Linked Issues check
[#4023] Requirement 1: the module imports on Python 3.11+. At the reviewed head, PS4DualShock.Axes and PS4DualShock.Buttons use field(default_factory=DualShockAxes) and `field(default_factory=Du…
Out of Scope Changes check
Changes at the reviewed head against merge base 5399d29: - ps4_dualshock.py and ps4_dualshock.pyi: directly implement the #4023 default-sharing fix. In scope. - `test/unit/test_dualshock_defaults.…
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title names two changes that the changeset does make: Python 3.11 compatibility fixes (the mutable dataclass defaults are replaced with field(default_factory=...), and the TeleopDevice base-class order is changed to Node before ABC) and independent DualShock defaults (the Axes/Buttons defaults are no longer shared, and PS4DualShockTeleop builds a fresh PS4DualShock when device_config is None). The title covers the main intent of PR #4025 and the linked issue #4023. It is a single, specific sentence and does not use vague terms.
Full details: Linked Issues check
Explanation
[#4023] Requirement 1: the module imports on Python 3.11+. At the reviewed head, PS4DualShock.Axes and PS4DualShock.Buttons use field(default_factory=DualShockAxes) and field(default_factory=DualShockButtons) in moveit_py/moveit/servo_client/devices/ps4_dualshock.py. This removes the mutable dataclass default that raised the ValueError. Static inspection supports this. The PR reports two Python 3.12 tests passing, but ROS imports were stubbed and CI integration is pending.
[#4023] Requirement 2: each default configuration owns its mappings. test_dualshock_mappings_are_independent checks that two default PS4DualShock() instances do not share Axes or Buttons. PS4DualShockTeleop.__init__ now defaults device_config to None and builds PS4DualShock() per instance. test_default_teleop_configs_are_independent checks distinct default configs and pass-through of an explicit config. The .pyi stub matches the new signature.
The issue describes the teleop constructor's shared default as a problem. That default is now fresh per call. No unmet coding requirement was found.
Full details: Out of Scope Changes check
Explanation
Changes at the reviewed head against merge base 5399d29:
ps4_dualshock.py and ps4_dualshock.pyi: directly implement the #4023 default-sharing fix. In scope.
test/unit/test_dualshock_defaults.py and the moveit_py/CMakeLists.txt registration: regression tests for #4023. In scope.
teleop.py and teleop.pyi: TeleopDevice base order changes from (ABC, Node) to (Node, ABC). The issue does not mention this change. It is an import-compatibility change. With rclpy.Node inheriting from ABC, the original order yields an inconsistent MRO at import time, so the change is connected to the requirement that the module imports. The test test_teleop_device_remains_abstract checks that the abstract status is kept.
MIGRATION.md: documents the base-order change for ROS Rolling. It is documentation for that change, so it is connected to it.
The base-order change and its migration note are only weakly tied to the issue text. They do not conflict with it. No demonstrated unrelated change was found.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.
Queue this pull request once it meets the queue conditions
The Rolling job exposed an MRO error importing TeleopDevice because the current rclpy Node already inherits ABC. I fixed the base-class order in ee05ca5, synchronized the type stub, and retained the abstract interface. The two original tests reproduced the import failure with an ABC-derived Node stand-in; all three tests now pass with both Node hierarchies, and scoped pre-commit checks pass. The three Lyrical failures are separate: moveit_msgs cannot link the missing libfastcdr.so.2.3.7. Fresh ROS CI is needed.
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
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.
[written by AI]
Description
Fixes #4023. Use dataclass factories and a fresh default teleop configuration to prevent import errors and shared controller mappings. Order the teleoperation bases so the ROS Node comes before ABC, preserving import compatibility with newer ROS 2.
Checklist
Validation: two Python 3.12 tests pass after the fix; both previously failed at import. ROS imports were stubbed locally and the teleop initialization was mocked. Full ROS integration remains pending CI.
Rolling CI follow-up
The Rolling test job exposed an existing incompatible MRO: rclpy Node now derives from BaseNode, which derives from ABC. With ABC first, importing TeleopDevice fails before the new tests can run. Commit ee05ca5 puts Node first in the implementation and stub and tests that TeleopDevice remains abstract and its concrete DualShock subclass does not. The two original tests fail at import with the ABC-derived Node stand-in before this change; afterward all three tests pass with each of the ordinary and ABC-derived Node stand-ins (six passes). Changed-file pre-commit checks pass. Real ROS integration requires hosted CI.
The three Lyrical jobs in run 46210307095 fail earlier while linking moveit_msgs because libfastcdr.so.2.3.7 is absent from the ROS installation. No dependency or workflow changes are included.
Summary by CodeRabbit
rclpy.Nodeinherits fromABC.