Skip to content

Refactor whl-can to make the buttons more concise.#159

Merged
lykling merged 3 commits intomainfrom
whl-can_refactor
Mar 10, 2026
Merged

Refactor whl-can to make the buttons more concise.#159
lykling merged 3 commits intomainfrom
whl-can_refactor

Conversation

@daohu527
Copy link
Contributor

@daohu527 daohu527 commented Feb 15, 2026

Control Key Mapping

Category Key(s) Function Description Optimization Rationale
Driving W / S Increase / Decrease target (speed / throttle / accel, depends on mode) Matches common WASD forward/backward driving intuition
Steering A / D Turn left / right (adjust steering) Classic lateral control using A/D
Braking B / N Brake force (+ / -) Semantic: B increases, N decreases brake force (case-insensitive)
Emergency Space Emergency braking (sets brake to max) Most accessible key in emergencies; fastest reaction
Transmission G Cycle gears (P → R → N → D) Single-key cycle for quick gear change
Parking P Electronic Parking Brake (EPB toggle) Clear Parking semantics
Turn Signals Q / E / M Toggle Left / Right / Hazard turn signals Toggle behavior: press to enable, press again to cancel
Cancel Lights (none mapped) Note: UI help mentions c: Cancel but c is not mapped in the code
Warning / Hazard M Hazard lights (same as above) Easy index-finger access; mapped to m as toggle
Lighting L Cycle headlights (Off → Low → High) Lights semantic mapping; cyclic control
Horn O Horn (toggle) Placed away from main controls to reduce accidental activation
System — Engage Enter Toggle autonomous driving engage / takeover Enter implies confirm/engage
System — Quit Esc Quit program Standard escape-to-exit mapping
System — Help H Toggle help menu Quick access to help
Control Mode 1 / 2 / 3 Set control mode to SPEED / THROTTLE / ACCEL respectively Direct numeric mode selection for testing and control
EPB / Status (display-only) Status shown in UI (EPB, GEAR, SIGNAL, etc.) Read-only indicators in UI

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the whl-can keyboard controller to provide a more intuitive and ergonomic control mapping for Apollo autonomous vehicle control. The refactoring changes button mappings to be more consistent with gaming conventions (WASD for driving), adds a comprehensive UI with real-time visual feedback, introduces multiple control modes (SPEED/THROTTLE/ACCEL), and reorganizes the code architecture to make the controller more self-contained.

Changes:

  • Remapped keyboard controls to be more intuitive (e.g., V for brake decrease instead of B, Q/E for turn signals, L to cycle lights)
  • Added rich terminal UI with colored status display, progress bars, and visual steering indicator
  • Implemented three control modes (SPEED, THROTTLE, ACCEL) switchable via 1/2/3 keys
  • Refactored architecture so KeyboardController creates its own Cyber RT node and writer
  • Added help screen toggle and improved user feedback with timed message display

@daohu527 daohu527 requested a review from lykling March 10, 2026 11:30
Signed-off-by: Pride Leong <lykling.lyk@gmail.com>
Copy link
Member

@lykling lykling left a comment

Choose a reason for hiding this comment

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

lgtm

@lykling lykling merged commit 75ceddc into main Mar 10, 2026
@lykling lykling deleted the whl-can_refactor branch March 10, 2026 12:20
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.

3 participants