Skip to content

High Level Command — ROS2 Example

Source: rbq_sdk/ros2/src/rbq_examples/src/rbq_high_level.cpp

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

Overview

Three concurrent actors run together:

ActorRateRole
Control loop (timer)50 HzPublishes HighLevelCommand with the current gait + velocity
Joystick threadevent-drivenReads joystick events and updates atomic velocity values
Terminal threadblockingReads gait names/IDs from stdin

At startup, switchControlMode = true is published once (after a 200 ms delay) to enable HighLevel mode on the robot — without this the HighLevelCommand topic is ignored.

Prerequisites

  • ROS 2 Humble installed and sourced.
  • RBQ ROS2 SDK built — see Quick Start.
  • Robot stack running (simulation or hardware).
  • A Linux joystick device at /dev/input/js* (optional; terminal-only mode still works without one).

Build

bash
cd RBQ/rbq_sdk/ros2
rosdep install --from-paths src -y --ignore-src
colcon build --symlink-install
source install/setup.bash

Run

bash
ros2 run rbq_examples rbq_high_level [joystickPath]
# e.g.
ros2 run rbq_examples rbq_high_level
ros2 run rbq_examples rbq_high_level /dev/input/js1

Default joystick path: /dev/input/js0.

Terminal commands

Type either a gait name or a numeric gait ID and press Enter.

list              # print all available gaits
stand             # switch to STAND by name
3                 # switch to WALK by ID
rl_trot           # switch to RL_TROT by name

Available gaits

NameIDDescription
sit0Robot sits on the ground
stand1Neutral standing posture
aim2Aiming posture
walk3MPC trot gait
stairs4Stair-adaptive gait
wave5Slow walk gait
run6High-speed gait
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_fr40RL 3-leg (front-right 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)

Joystick velocity controls

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

A deadzone of 0.12 is applied before scaling.
omega_z is sent in degrees per second — QuadWalk converts to rad/s internally.

ROS 2 topics used

DirectionTopicMessage type
Publish/rbq/cmd/highLevelrbq_msgs/msg/HighLevelCommand
Publish/rbq/cmd/switchControlModestd_msgs/msg/Bool
Publish/rbq/cmd/switchGaitstd_msgs/msg/Int8
Publish/rbq/cmd/joysensor_msgs/msg/Joy
Subscribe/rbq/robot_statusrbq_msgs/msg/RobotStatus (best-effort QoS)

Key implementation notes

  • gait_transition flag: Set to true on every gait change message. This triggers the QuadWalk gait timer to start the transition.
  • switchControlMode: Sent once at startup after a 200 ms delay (mode_timer_) to allow DDS subscribers to connect before the command arrives.
  • Joystick events: The joystick thread runs independently and updates vel_x_, vel_y_, omega_z_ atomics. The 50 Hz timer reads these atomics on each publish cycle.

See also

This user manual is intended for RBQ users.