Skip to content

High Level Command — Python Example

Source: rbq_sdk/python/example/sport/rbq_high_level.py

Python port of rbq_high_level.cpp.
Publishes HighLevelCommand at 50 Hz over DDS, selects gaits from the terminal, and reads joystick velocity setpoints.

Overview

Three concurrent actors:

ActorRateRole
Control loop thread50 HzPublishes HighLevelCommand with current gait + velocity
Joystick loop thread100 HzPolls joystick and updates velocity setpoints
Main thread (terminal)blockingReads gait names / IDs from stdin

At startup the control loop publishes switchControlMode = true once (after 200 ms), enabling EXT_JOY mode on the robot stack. Without this, HighLevelCommand is ignored.

Prerequisites

  • rbq_sdk_py installed — see Python SDK Overview.
  • A Linux joystick device at /dev/input/js* (required to start).
  • Robot stack running (simulation or hardware).

Install & Run

bash
cd RBQ/rbq_sdk/python
pip install -e .
bash
cd RBQ/rbq_sdk/python/example/high_level
python3 rbq_high_level.py <networkInterface> [joystickPath]
# e.g.
python3 rbq_high_level.py eth0
python3 rbq_high_level.py eth0 /dev/input/js1

Joystick auto-detection: prefers a device whose name contains "Logitech", "gamepad", "Xbox", or "wireless", then falls back to the first available js* node.
Override via argument or JOY=/dev/input/js1 python3 rbq_high_level.py eth0.

Terminal commands

list              # print all available gaits
standing          # switch to STANDING by name
3                 # switch to TROTTING by ID
rl_trot           # switch to RL_TROT by name

Available gaits

NameIDDescription
sitting0Robot sits on the ground
standing1Neutral standing posture (default at startup)
aiming2Aiming posture
trotting3MPC trot gait
trot_stairs4Stair-adaptive trot
waving5Slow walk gait
trot_running6High-speed trot
docking10Auto-docking sequence
rl_trot30RL-based trot
rl_front_walk31RL forward walk
rl_left_walk33RL lateral left walk
rl_right_walk34RL lateral right walk
rl_bound35RL bound gait
rl_pace36RL pace gait
rl_pronk37RL pronk gait
rl_3leg_hr38RL 3-leg (hind-right lifted)
rl_3leg_hl39RL 3-leg (hind-left lifted)
rl_3leg_fl41RL 3-leg (front-left lifted)
rl_trot_vision42RL trot with vision
rl_trot_run45RL trot run
rl_silent46RL silent gait
rl_stairs47RL stair climbing
rl_walk_vision48RL walk w/ terrain height feedback (height/pitch adjustable)
rl_walk49RL walk (height/pitch adjustable)
rl_end80RL end state

Joystick velocity controls

AxisMaps toMax value
Left stick Y (forward)vel_x±1.2 m/s
Left stick X (lateral)vel_y±0.5 m/s
Right stick X (yaw)omega_z±60 deg/s

Deadzone of 0.12 applied before scaling.

omega_z units: sent in deg/s — QuadWalk multiplies by D2R internally.

DDS topics

DirectionTopicMessage type
Publishrt/rbq/cmd/highLevelHighLevelCommand_
Publishrt/rbq/cmd/switchControlModeBool_

Key implementation notes

  • gait_transition flag: A threading.Lock-protected consume_gait_pending() method ensures the flag is consumed exactly once per gait change — mirrors the C++ std::atomic::exchange() pattern.
  • switchControlMode: Published once at startup after a 200 ms delay. If not published, the robot ignores HighLevelCommand.
  • Timing: The control loop uses time.monotonic() and time.sleep() for 20 ms pacing. On slip, it resets next_tick to avoid clock drift.
  • No RT thread: Unlike the C++ version, no real-time thread is used. sudo is not required.

See also

This user manual is intended for RBQ users.