Skip to content

High Level Command — C++ Example

Source: rbq_sdk/cpp/example/src/rbq_high_level.cpp

Publishes HighLevelCommand messages at 50 Hz over DDS.
Gait selection is done from the terminal; velocity setpoints come from a joystick.

Overview

Three concurrent actors run together:

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

At startup the control loop also publishes switchControlMode = true once, which enables EXT_JOY mode on the robot stack — without this the HighLevelCommand topic is ignored.

Prerequisites

  • RBQ SDK built and installed — see C++ SDK Overview.
  • A Linux joystick device at /dev/input/js* (the joystick is required to start the program).
  • Robot stack running (simulation or hardware).

Build

From rbq_sdk/cpp/example/:

bash
bash scripts/setup.bash
bash scripts/build.bash

Binary: bin/rbq_high_level

Run

bash
./bin/rbq_high_level <networkInterface> [joystickPath]
# e.g.
./bin/rbq_high_level eth0
./bin/rbq_high_level eth0 /dev/input/js1

The joystick auto-detection follows the same logic as the Sport Client (Joystick) example.

Terminal commands

At the > prompt type either a gait name or a numeric gait ID.

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

A deadzone of 0.12 is applied before scaling.

Note on omega_z units: HighLevelCommand.omega_z is sent in degrees per second.
The on-robot QuadWalk multiplies by D2R internally, so the SDK side sends raw deg/s values (e.g. 60 deg/s ≈ 1.05 rad/s of yaw).

DDS topics used

DirectionTopicMessage type
Publishrt/rbq/cmd/highLevelrbq_msgs::msg::dds_::HighLevelCommand_
Publishrt/rbq/cmd/switchControlModestd_msgs::msg::dds_::Bool_

Key implementation notes

  • gait_transition flag: Set to true only on the single tick immediately following a gait change, using std::atomic<bool>::exchange(). This ensures the QuadWalk gaitTimer is triggered exactly once rather than continuously.
  • switchControlMode: Published once at startup (after a 200 ms delay to let DDS subscribers connect). If not published, the robot ignores HighLevelCommand and stays in joystick mode.
  • Timing: The control loop uses clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, ...) for precise 20 ms scheduling. If the loop runs late, it resets timeNext to the current time rather than chasing a drifting target.

See also

This user manual is intended for RBQ users.