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:
| Actor | Rate | Role |
|---|---|---|
| Control loop thread | 50 Hz | Publishes HighLevelCommand with current gait + velocity |
| Joystick loop thread | 100 Hz | Polls joystick and updates velocity setpoints |
| Main thread (terminal) | blocking | Reads 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_pyinstalled — 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/js1Joystick 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 nameAvailable gaits
| Name | ID | Description |
|---|---|---|
sitting | 0 | Robot sits on the ground |
standing | 1 | Neutral standing posture (default at startup) |
aiming | 2 | Aiming posture |
trotting | 3 | MPC trot gait |
trot_stairs | 4 | Stair-adaptive trot |
waving | 5 | Slow walk gait |
trot_running | 6 | High-speed trot |
docking | 10 | Auto-docking sequence |
rl_trot | 30 | RL-based trot |
rl_front_walk | 31 | RL forward walk |
rl_left_walk | 33 | RL lateral left walk |
rl_right_walk | 34 | RL lateral right walk |
rl_bound | 35 | RL bound gait |
rl_pace | 36 | RL pace gait |
rl_pronk | 37 | RL pronk gait |
rl_3leg_hr | 38 | RL 3-leg (hind-right lifted) |
rl_3leg_hl | 39 | RL 3-leg (hind-left lifted) |
rl_3leg_fl | 41 | RL 3-leg (front-left lifted) |
rl_trot_vision | 42 | RL trot with vision |
rl_trot_run | 45 | RL trot run |
rl_silent | 46 | RL silent gait |
rl_stairs | 47 | RL stair climbing |
rl_walk_vision | 48 | RL walk w/ terrain height feedback (height/pitch adjustable) |
rl_walk | 49 | RL walk (height/pitch adjustable) |
rl_end | 80 | RL end state |
Joystick velocity controls
| Axis | Maps to | Max 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_zunits: sent in deg/s — QuadWalk multiplies by D2R internally.
DDS topics
| Direction | Topic | Message type |
|---|---|---|
| Publish | rt/rbq/cmd/highLevel | HighLevelCommand_ |
| Publish | rt/rbq/cmd/switchControlMode | Bool_ |
Key implementation notes
gait_transitionflag: Athreading.Lock-protectedconsume_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 ignoresHighLevelCommand.- Timing: The control loop uses
time.monotonic()andtime.sleep()for 20 ms pacing. On slip, it resetsnext_tickto avoid clock drift. - No RT thread: Unlike the C++ version, no real-time thread is used.
sudois not required.
