Skip to content

Adding strafe and arrow control to keyboard telop#2028

Open
Mly9 wants to merge 3 commits into
dimensionalOS:mainfrom
Mly9:mo/keyboard-strafing
Open

Adding strafe and arrow control to keyboard telop#2028
Mly9 wants to merge 3 commits into
dimensionalOS:mainfrom
Mly9:mo/keyboard-strafing

Conversation

@Mly9
Copy link
Copy Markdown

@Mly9 Mly9 commented May 9, 2026

Description

Added strafing and arrow key support to keyboard teleop across
the Python pygame module, the twist base example, and the web
command center extension

How to Test

python -m dimos.control.examples.twist_base_keyboard_teleop

Verify:

Contributor License Agreement

  • I have read and approved the CLA.

Closes #1957

@Mly9 Mly9 changed the base branch from main to dev May 9, 2026 01:45
@Mly9 Mly9 force-pushed the mo/keyboard-strafing branch from ddb9d49 to 01e8fe8 Compare May 9, 2026 02:30
@Mly9 Mly9 changed the base branch from legacy-dev-dont-merge to main May 9, 2026 02:34
@Mly9 Mly9 marked this pull request as ready for review May 9, 2026 02:44
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 9, 2026

Greptile Summary

This PR adds arrow key support for movement and replaces the old Q/E strafe with an Alt-modifier scheme (Alt+A/D or Alt+←/→) across the pygame KeyboardTeleop module and the React KeyboardControlPanel web extension.

  • keyboard_teleop.py: W/S and ↑/↓ now both drive linear.x; A/D and ←/→ default to yaw; holding Alt flips them to strafe (linear.y). The key display is updated to show all held keys using sorted() without the old < 256 filter, which is safe.
  • KeyboardControlPanel.tsx: Mirrors the Python binding changes; adds "Alt" to controlKeys and restructures calculateVelocities. On macOS browsers, Alt+letter generates a different event.key (e.g. "å" for Alt+A), which falls outside controlKeys and is silently dropped — breaking the Alt+A/D half of strafe on that platform.
  • Documentation (README.md files, twist_base_keyboard_teleop.py docstring): updated to reflect the new bindings; no logic changes.

Confidence Score: 3/5

The Python side is safe to merge; the web component has a real cross-platform defect that should be addressed before merging.

The Python pygame implementation is clean and correct. The web component mirrors it faithfully on Windows/Linux, but the Alt+letter handling breaks on macOS because the browser produces composed characters (e.g. "å", "∂") instead of "a"/"d" when Alt is held, causing the strafe condition to never fire for those keys.

dimos/web/command-center-extension/src/KeyboardControlPanel.tsx — the Alt key normalisation needs attention for cross-platform correctness.

Important Files Changed

Filename Overview
dimos/robot/unitree/keyboard_teleop.py Replaces Q/E strafe with Alt+A/D and adds Up/Down arrow support; logic is correct. Removes the k < 256 guard in the key display (safe since pygame.key.name handles all key codes). Adds all.
dimos/web/command-center-extension/src/KeyboardControlPanel.tsx Adds "Alt" to controlKeys and mirrors the Python strafe-via-Alt logic. Alt+A/D strafe is silently broken on macOS browsers because Alt+letter produces a different event.key. Also contains a now-dead angularY variable.
dimos/control/examples/twist_base_keyboard_teleop.py Docstring-only update; the file imports and delegates to KeyboardTeleop so the updated control descriptions are accurate.
dimos/web/command-center-extension/README.md Adds a one-line keyboard controls summary at the top of the README; content matches the implemented bindings.
dimos/web/websocket_vis/README.md Updates the keyboard teleop bullet to describe the new arrow/Alt bindings; documentation-only change.

Comments Outside Diff (1)

  1. dimos/web/command-center-extension/src/KeyboardControlPanel.tsx, line 39-42 (link)

    P2 angularY is declared and returned but is never assigned a non-zero value now that arrow keys drive linearX instead of pitch. It can be removed to avoid confusion about whether pitch is still being controlled.

Reviews (1): Last reviewed commit: "Merge branch 'main' into mo/keyboard-str..." | Re-trigger Greptile

Comment on lines +66 to 90
const altStrafe =
keys.has("Alt") &&
(keys.has("a") ||
keys.has("d") ||
keys.has("ArrowLeft") ||
keys.has("ArrowRight"));

// Alt + A/D or ←/→: strafe (linear Y). Otherwise those keys turn (yaw).
if (altStrafe) {
const strafeLeft = keys.has("a") || keys.has("ArrowLeft");
const strafeRight = keys.has("d") || keys.has("ArrowRight");
if (strafeLeft && !strafeRight) {
linearY = linearSpeed * speedMultiplier;
} else if (strafeRight && !strafeLeft) {
linearY = -linearSpeed * speedMultiplier;
}
} else {
const turnLeft = keys.has("a") || keys.has("ArrowLeft");
const turnRight = keys.has("d") || keys.has("ArrowRight");
if (turnLeft && !turnRight) {
angularZ = angularSpeed * speedMultiplier;
} else if (turnRight && !turnLeft) {
angularZ = -angularSpeed * speedMultiplier;
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Alt+A/D strafe silently broken on macOS browsers

On macOS, holding Alt and pressing A generates event.key === "å" (not "a"), and Alt+D generates "∂" instead of "d". Because neither character is in controlKeys, the KEYDOWN handler filters them out before they reach keysPressed. The result is that keys.has("a") is always false while Alt is held on macOS, so altStrafe only becomes true via ArrowLeft/ArrowRight — the A/D half of the advertised "Alt+A strafe left, Alt+D strafe right" feature never fires on macOS Chrome/Safari.


// Linear X (forward/backward) - W/S
if (keys.has("w")) {
const forward = keys.has("w") || keys.has("ArrowUp");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This control center extension is deprecated so no need to change it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard Teleop Should support strafing

2 participants