Motion Tracking and Kinematic Planner with Keyboard Controls

March 24, 2026 · View on GitHub

In-the-wild navigation demo using the kinematic planner with keyboard controls.
:width: 100%

Video: Keyboard control walkthrough — starting the control system, playing reference motions, and using planner mode for real-time locomotion.

Control the robot using keyboard commands for reference motion playback and planner-based locomotion (using --input-type keyboard).

:class: note
Complete the [Quick Start](../getting_started/quickstart.md) to have the sim2sim loop running.
:class: danger
Press **`O`** at any time to immediately stop control and exit. Always keep a hand near the keyboard ready to press **`O`**.

Launch

Sim2Sim (MuJoCo):

# Terminal 1 — MuJoCo simulator (from repo root)
source .venv_sim/bin/activate
python gear_sonic/scripts/run_sim_loop.py

# Terminal 2 — C++ deployment (from gear_sonic_deploy/)
bash deploy.sh --input-type keyboard sim

Real Robot:

# From gear_sonic_deploy/
bash deploy.sh --input-type keyboard real

Step-by-Step: Normal Mode (Reference Motion Tracking)

Normal Mode plays back pre-loaded reference motions. This is the default mode when the program starts.

  1. In Terminal 2, press ] to start the control system.
  2. In the MuJoCo window, press 9 to drop the robot to the ground.
  3. Go back to Terminal 2, press T to play the current reference motion — the robot executes it to completion.
  4. Press N to switch to the next motion sequence, or P for the previous one.
  5. Press T again to play the new motion.
  6. To replay the same motion, press T again after it finishes. To stop mid-motion and return to the first frame, press R — the robot pauses at the first frame without terminating the policy.
  7. Use Q / E to nudge the heading left or right (±π/12 rad per press).
  8. Press I to reinitialize the base quaternion and reset the heading to zero, i.e. robot will think the current facing is the facing at the first frame of the reference.
  9. When done, press O to stop control and exit.

Step-by-Step: Planner Mode (Real-time Motion Generation)

Planner Mode lets you control the robot in real time — choose a locomotion style, steer with WASD, and adjust speed and height on the fly.

  1. From Normal Mode, press ENTER to switch to Planner Mode. The terminal will print Planner enabled.
  2. The robot starts in the Locomotion motion set. Press 1 for slow walk, 2 for walk, or 3 for run.
  3. Press W to walk forward. The robot uses a momentum system — holding a direction key sets momentum to full; releasing it lets the robot gradually decelerate and return to idle.
  4. Steer with A / D (adjust heading and moving direction together) or turn in place with Q / E (±π/6 rad per press, only facing direction).
  5. Press , / . to strafe left / right.
  6. Press S to move backward.
  7. Adjust speed with 9 (decrease) / 0 (increase). Speed ranges depend on the current mode (see tables below).
  8. Press N to cycle to the next motion set (Locomotion → Squat → Boxing → Styled Walking → …). Use P to go back.
  9. Within a motion set, press 18 to pick a specific mode (see the Motion Sets section below).
  10. For squat-type modes, adjust body height with - (lower) / = (higher), clamped to 0.2–0.8 m.
  11. If you need an immediate halt, press R, `, or ~ — this resets movement momentum to zero instantly.
  12. Press ENTER again to return to Normal Mode, or O to stop and exit.

Control Reference

System Controls (Both Modes)

KeyAction
]Start control system
OStop control and exit (emergency stop)
ENTERToggle between Normal / Planner modes
IReinitialize base quaternion and reset heading
ZToggle encoder mode (between mode 0 and mode 1, if encoder loaded)
FReport motor temperatures (TTS voice alert)

Normal Mode Keys

KeyAction
TPlay current motion to completion
RRestart current motion from beginning (pause at frame 0)
P / NPrevious / Next motion sequence
Q / EAdjust delta heading (at policy level) left / right (±π/12 rad)

Planner Mode Keys

Movement:

KeyAction
W / SMove forward / backward
A / DAdjust heading slightly and move forward (left / right)
, / .Strafe left / right

Heading:

KeyAction
Q / EAdjust facing direction (at planner level) left / right (±π/6 rad)
J / LAdjust delta heading (at policy level) left / right (±π/12 rad)

Mode & Speed:

KeyAction
N / PNext / Previous motion set
18Select mode within the current set
9 / 0Decrease / Increase movement speed
- / =Decrease / Increase height (non-standing sets, 0.2–0.8 m)
TPlay motion

Emergency:

KeyAction
R / ` / ~Emergency stop (immediate momentum reset)

Motion Sets

A motion set is a group of related movement styles (e.g., locomotion, gestures, or crouching). Selecting a mode within a set makes the robot behave in that style. Each set contains up to eight selectable modes.

Cycle through motion sets with N (next) / P (previous). Within each set, press 18 to select a mode. For more details on the underlying planner model, mode indices, and input/output specifications, see the Kinematic Planner ONNX Model Reference.

Set 0 — Locomotion (Standing)

KeyModeSpeed Range
1Slow Walk0.2–0.8 m/s
2Walk
3Run1.5–3.0 m/s
4Happy
5Stealth
6Injured
For lateral (side-stepping) movement using **`,`** / **`.`**, we recommend keeping the target velocity at around **0.4 m/s**. Higher velocities during strafing can cause the robot's feet to collide due to the cross-legged foot placement required for lateral steps.
Happy styled walking.
Stealth styled walking.
Injured styled walking.
Running locomotion mode.

Set 1 — Squat / Ground

Height adjustable with - / = (0.2–0.8 m). Initial height defaults to 0.8 m when entering this set.

KeyModeSpeed Range
1Squatstatic
2Kneel (Two Legs)static
3Kneel (One Leg)static
4Hand Crawling0.4–1.0 m/s
5Elbow Crawling0.7–1.0 m/s
Kneeling mode with variable height control.
Hand crawling locomotion.
Elbow crawling locomotion.

Set 2 — Boxing

KeyModeSpeed Range
1Idle Boxingstatic
2Walk Boxing0.7–1.5 m/s
3Left Jab0.7–1.5 m/s
4Right Jab0.7–1.5 m/s
5Random Punches0.7–1.5 m/s
6Left Hook0.7–1.5 m/s
7Right Hook0.7–1.5 m/s
Boxing mode demo.

Set 3 — Additional Styled Walking

KeyMode
1Careful
2Object Carrying
3Crouch
4Happy Dance
5Zombie
6Point
7Scared

Movement Momentum System

The planner usage in keyboard mode uses a momentum-based movement system:

  • Pressing a direction key (W/S/A/D/,/.) sets momentum to 1.0 (full speed).
  • Each frame without a direction key press, momentum decays multiplicatively (×0.999).
  • When momentum drops below 0.1, the robot transitions to idle (for the Locomotion set) or holds the current static pose (for Squat and Boxing sets).
  • Emergency stop (R/`/~) instantly resets momentum to zero.

This means you don't need to hold a key down — a single press starts movement, and the robot coasts to a stop naturally.