Repository navigation
Conversation
Se3Keyboard added a key's delta on every press event and subtracted it on every release event, so a release without its press, or a press without its release, left a constant motion command until the next reset. Both happen in teleoperation: a key still held when R resets the device (reset() zeroes the deltas, the later release subtracts again), and key events Kit does not deliver. In Kit, a key press right after a viewport click reached no keyboard subscriber while the keyboard state recorded it, so "R, click the viewport, drive" left the arm drifting opposite to the first key. Track the motion keys whose press was applied: a press of a held key adds nothing, a release only removes a delta its key added, reset() forgets keys still held, and advance() drops keys the keyboard reports as released. Signed-off-by: Jack Nelson <jinelson@andrew.cmu.edu>
[Medium impact] The change affects robot-arm teleoperation that uses Se3Keyboard. The fix appears safe to merge, with a non-blocking improvement needed to run the mocked tests without Kit. Findings
Summary
Reviews (1) · Last reviewed commit: "Keep Se3Keyboard motion consistent with ..." · Reviewed by Greptile |
| from isaaclab.devices import Se3Keyboard, Se3KeyboardCfg | ||
| from isaaclab.devices.keyboard import se3_keyboard |
There was a problem hiding this comment.
Mocked tests still require Kit
These imports load the real carb and omni modules before the fixture installs its mocks. If those modules are unavailable, collection fails before any test runs. Install temporary module stubs before importing Se3Keyboard so contributors can run these mocked tests without Kit.
There was a problem hiding this comment.
Addressed in 0abbc34: missing carb and omni modules are temporarily stubbed during import; the fixture replaces the input interfaces.
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Implementation (1), Style consistency (7), Test quality (2). Other reviewed categories look good.
- PR description: The title and four-file scope match the diff, and the reported baseline failures and GUI drift comparison address correctness without making a performance claim.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: No over-engineering issues.
- API: API changes look good.
- Compatibility and deprecation: No breaking changes identified.
- Implementation: advance() allocates a reconciliation list even with no held keys; guard reconciliation with
if self._held_keysto avoid the idle allocation. - Style consistency: Added production and test signatures omit required annotations; add concrete parameter types and
-> Nonefor functions that return no value. - Test quality: Direct private-handler calls couple event tests to implementation and bypass subscription; invoke the registered callback and trim unused mock enum entries while retaining distinct motion and gripper contracts.
Minor fixes needed. Posted 10 inline findings.
Automated review; human maintainers own approval decisions.
| self._close_gripper = False | ||
| self._delta_pos = np.zeros(3) # (x, y, z) | ||
| self._delta_rot = np.zeros(3) # (roll, pitch, yaw) | ||
| # Forget keys that are still physically held (e.g. a pull key held while the reset key is |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Name the reset key consistently
The comment calls a held motion key a “pull key,” which the bindings never define. Use “motion key” to make the reset constraint identifiable.
There was a problem hiding this comment.
Addressed in 0abbc34: the reset comment now says motion keys and explains the cleared-delta invariant.
| """ | ||
| # A release that never reached this device (Kit can consume key events, e.g. in the frame of a | ||
| # viewport click) would keep its key's motion forever: drop keys the keyboard reports as up. | ||
| for key in [ |
There was a problem hiding this comment.
🟡 Warning · Implementation — Avoid idle command allocations
The list comprehension allocates on every advance(), including when no motion key is held. Guard reconciliation with if self._held_keys so idle commands avoid that per-step allocation.
There was a problem hiding this comment.
Addressed in 0abbc34: reconciliation is guarded when no keys are held.
| https://docs.omniverse.nvidia.com/dev-guide/latest/programmer_ref/input-devices/keyboard.html | ||
| """ | ||
| # apply the command when pressed | ||
| # apply the command when pressed (once per press: a key already held adds nothing) |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Remove narrated press condition
This comment repeats the KEY_PRESS branch and held-key guard without explaining a further constraint. Remove it.
There was a problem hiding this comment.
Addressed in 0abbc34: removed the redundant held-key narration.
| self._delta_pos -= self._INPUT_KEY_MAPPING[event.input.name] | ||
| elif event.input.name in ["Z", "X", "T", "G", "C", "V"]: | ||
| self._delta_rot -= self._INPUT_KEY_MAPPING[event.input.name] | ||
| # remove the command when un-pressed. A release whose press was not applied (the key was |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Shorten the release rationale
Three lines narrate the release branch and repeat the drift outcome. Keep only the non-obvious invariant: never subtract a delta whose press was not applied.
There was a problem hiding this comment.
Addressed in 0abbc34: the release comment states the unmatched-press invariant concisely.
| # since no error, we are fine :) | ||
| return True | ||
|
|
||
| def _release(self, key: str): |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Annotate the release helper
_release has no return annotation, contrary to the signature guidance for no-value methods. Add -> None.
There was a problem hiding this comment.
Addressed in 0abbc34: _release now returns None in its annotation.
|
|
||
| PRESS, RELEASE = "KEY_PRESS", "KEY_RELEASE" | ||
| STEP = 0.05 | ||
| KEYS = ["W", "S", "A", "D", "Q", "E", "Z", "X", "T", "G", "C", "V", "K", "R", "L"] |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Trim unused mock key entries
Only W, A, Z, E, Q, and X reach keyboard-value polling. The other enum assignments maintain an unused key inventory; initialize only entries queried by these tests.
There was a problem hiding this comment.
Addressed in 0abbc34: only the six polled test keys are configured.
| KEYS = ["W", "S", "A", "D", "Q", "E", "Z", "X", "T", "G", "C", "V", "K", "R", "L"] | ||
|
|
||
|
|
||
| class Keyboard: |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Keep test support private
Keyboard is file-local fixture support but has a public name and precedes public test functions. Rename it _Keyboard and place the private class after the functions.
There was a problem hiding this comment.
Addressed in 0abbc34: renamed _Keyboard and moved it after the tests.
| deliver the event, ``drop_*`` change it without delivering the event (an event Kit consumed). | ||
| """ | ||
|
|
||
| def __init__(self, monkeypatch): |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Annotate new test signatures
The fixture, tests, and most Keyboard methods omit parameter or return annotations required by the type-hint guidance. Add concrete annotations, including -> None for no-value functions.
There was a problem hiding this comment.
Addressed in 0abbc34: fixture, test, and helper signatures have concrete annotations.
| monkeypatch.setattr(se3_keyboard, "omni", mock.MagicMock()) | ||
| self.device = Se3Keyboard(Se3KeyboardCfg(pos_sensitivity=STEP, rot_sensitivity=STEP, sim_device="cpu")) | ||
|
|
||
| def _send(self, kind: str, key: str): |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Order private methods last
_send precedes the fixture's public press and release methods, contrary to the prescribed class-member order. Move it below the public methods.
There was a problem hiding this comment.
Addressed in 0abbc34: _send follows the public helper methods.
| self.device = Se3Keyboard(Se3KeyboardCfg(pos_sensitivity=STEP, rot_sensitivity=STEP, sim_device="cpu")) | ||
|
|
||
| def _send(self, kind: str, key: str): | ||
| self.device._on_keyboard_event(SimpleNamespace(type=kind, input=SimpleNamespace(name=key))) |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Exercise the subscribed callback
Calling _on_keyboard_event directly bypasses the callback registered at construction, so subscription regressions pass and a behavior-preserving handler rename breaks every event test. Capture and invoke the registered callback.
There was a problem hiding this comment.
Addressed in 0abbc34: the fixture captures and invokes the subscribed callback.
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Style consistency (6), Test quality (3). Other reviewed categories look good.
- PR description: The title and release-branch scope match the diff, and reported baseline failures and GUI drift checks support correctness; bounded keyboard polling introduces no material scaling change requiring performance measurements.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: No over-engineering issues.
- API: API changes look good.
- Compatibility and deprecation: No breaking changes identified.
- Implementation: Implementation looks good.
- Style consistency: Added narration repeats nearby guards and assertions, increasing maintenance noise; shorten the changelog and comments, correct binding vocabulary, and apply private naming and concrete signature annotations.
- Test quality: Direct private-handler invocation couples regressions to implementation rather than registered input delivery; use the subscribed callback and remove unused key inventory and unobservable dropped-press setup.
Minor fixes needed. Posted 9 inline findings.
Automated review; human maintainers own approval decisions.
| @@ -0,0 +1,5 @@ | |||
| * Fixed :class:`~isaaclab.devices.keyboard.se3_keyboard.Se3Keyboard` leaving a constant motion command when a | |||
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Condense the changelog entry
Five lines replay event examples and internal bookkeeping for one user-visible fix. State that unmatched key events no longer leave persistent motion.
There was a problem hiding this comment.
Addressed in 0abbc34: the fragment now states the user-visible fix concisely.
| self._close_gripper = False | ||
| self._delta_pos = np.zeros(3) # (x, y, z) | ||
| self._delta_rot = np.zeros(3) # (roll, pitch, yaw) | ||
| # Forget keys that are still physically held (e.g. a pull key held while the reset key is |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Name the reset key accurately
“Pull key” is not this device's binding vocabulary and obscures which deltas reset clears. Say “motion key” and keep the reset invariant concise.
There was a problem hiding this comment.
Addressed in 0abbc34: the reset comment uses motion-key terminology.
| https://docs.omniverse.nvidia.com/dev-guide/latest/programmer_ref/input-devices/keyboard.html | ||
| """ | ||
| # apply the command when pressed | ||
| # apply the command when pressed (once per press: a key already held adds nothing) |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Remove press-branch narration
The parenthetical repeats the held-key guard immediately below and adds no constraint. Remove it.
There was a problem hiding this comment.
Addressed in 0abbc34: removed the redundant held-key narration.
|
|
||
| PRESS, RELEASE = "KEY_PRESS", "KEY_RELEASE" | ||
| STEP = 0.05 | ||
| KEYS = ["W", "S", "A", "D", "Q", "E", "Z", "X", "T", "G", "C", "V", "K", "R", "L"] |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Trim the fixture key inventory
Several listed bindings are never sent or polled. This copied inventory adds maintenance without testing them; configure only keys exercised by the cases.
There was a problem hiding this comment.
Addressed in 0abbc34: only the six keys exercised by polling are configured.
| KEYS = ["W", "S", "A", "D", "Q", "E", "Z", "X", "T", "G", "C", "V", "K", "R", "L"] | ||
|
|
||
|
|
||
| class Keyboard: |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Keep the fixture class private
Keyboard is test-only support, but its public name conflicts with the repository's private-class convention. Rename it _Keyboard and place it with private declarations.
There was a problem hiding this comment.
Addressed in 0abbc34: renamed _Keyboard and moved it below the tests.
| deliver the event, ``drop_*`` change it without delivering the event (an event Kit consumed). | ||
| """ | ||
|
|
||
| def __init__(self, monkeypatch): |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Annotate new function signatures
The fixture, test functions, and event helpers omit available parameter or return types; the new Se3Keyboard._release also lacks -> None. Add concrete annotations as required by the guide.
There was a problem hiding this comment.
Addressed in 0abbc34: added annotations to the test helpers and _release.
| self.device = Se3Keyboard(Se3KeyboardCfg(pos_sensitivity=STEP, rot_sensitivity=STEP, sim_device="cpu")) | ||
|
|
||
| def _send(self, kind: str, key: str): | ||
| self.device._on_keyboard_event(SimpleNamespace(type=kind, input=SimpleNamespace(name=key))) |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Use the subscribed callback
Directly calling the private handler bypasses the event subscription used by real input. Capture the callback registered during construction and send test events through it.
There was a problem hiding this comment.
Addressed in 0abbc34: events are delivered through the captured subscription callback.
| np.testing.assert_array_equal(keyboard.motion(), np.zeros(6)) | ||
| keyboard.release("R", "E") | ||
| np.testing.assert_array_equal(keyboard.motion(), np.zeros(6)) | ||
| # the next episode drives normally |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Remove episode narration
The test has no episode boundary, and the comment only narrates the following press and assertions. Remove it.
There was a problem hiding this comment.
Addressed in 0abbc34: removed the episode narration.
| @pytest.mark.parametrize("key", ["Q", "X"]) | ||
| def test_release_of_undelivered_press_is_ignored(keyboard, key): | ||
| """A release whose press never reached the device must not leave a constant motion command.""" | ||
| keyboard.drop_press(key) |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Remove unobservable dropped-press setup
drop_press() changes fake state that release() clears before the device reads it. It cannot affect the assertion; send the unmatched release directly and remove the helper.
There was a problem hiding this comment.
Addressed in 0abbc34: the test sends an unmatched release directly and the unobservable helper is gone.
Skip reconciliation when no motion key is held, tighten comments, annotate _release, and condense the changelog fragment. Drive the tests through the subscribed callback, stub carb/omni for import so they collect without Kit, trim the mocked key inventory, and make the fixture class private. Signed-off-by: Jack Nelson <jack@jackn.org>
Description
Se3Keyboard(release/3.0.0) adds a key's delta on everyKEY_PRESSand subtracts it on everyKEY_RELEASE. A release without a matching press therefore leaves a constant motion command until the nextreset():E, pressR(the teleop script callsreset(), which zeroes the deltas), releaseE. The release subtractsEagain, and the end effector keeps moving up (+z, 0.05 per step at default sensitivity) until the next reset.Fix (
Se3Keyboardonly):reset()forgets held keys.advance()drops held keys thatIInput.get_keyboard_valuereports as released, so a lost release stops at the next command. Keys are never added from the polled state.mainreplaced this device in #8797; its held-key set (_ControlKeyListener) does not have this defect, so this targetsrelease/3.0.0only.Type of change
Checklist
pre-commitchecks withuv run isaaclab --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bump package versions — CI handles that)CONTRIBUTORS.mdor my name already exists thereNew
source/isaaclab/test/devices/test_se3_keyboard.pymocks carb/omni (no Kit). Onrelease/3.0.0(223feed) 6 of 8 cases fail; with the fix 8 pass. Also verified in a Kit GUI session with real X11 key events: before, holdingEacrossRdrifted the arm 0.29 m in 100 steps; after, 0 m. Pre-commit hooks were run on the changed files.