Skip to content

RBQ SDK — Python Overview ​

The RBQ Python SDK (rbq_sdk/python/) is a Python package (rbq_sdk_py) that wraps the same CycloneDDS infrastructure as the C++ SDK, exposing SportClient API and DDS channel utilities in pure Python.

Package layout ​

rbq_sdk/python/
├── rbq_sdk_py/
│   ├── core/
│   │   └── channel.py          # ChannelFactoryInitialize, ChannelPublisher, ChannelSubscriber
│   └── sport/
│       ├── sport_client.py     # SportClient — Python binding to the Network service
│       └── sport_api.py        # ID_DEFAULT_MODE, ID_RUNNING_MODE, ID_CLIMB_MODE constants
└── example/
    ├── sport/
    │   ├── rbq_sport_client.py      # Terminal CLI for SportClient commands
    │   ├── rbq_sport_client_joy.py  # Joystick-driven SportClient
    │   ├── rbq_high_level.py        # High-level command example
    │   ├── rbq_low_level.py         # Low-level command example
    │   ├── rbq_target_go.py         # Target-go navigation example
    │   └── rbq_led_bottom.py        # Bottom LED example
    ├── front_camera/
    │   ├── capture_image.py         # Grab one front-camera frame to img.jpg
    │   └── camera_opencv.py         # Show the front-camera stream with OpenCV
    └── idl/
        └── _rbq_idl.py             # Generated Python IDL bindings

Note — examples: rbq_high_level.py, rbq_low_level.py, rbq_target_go.py, rbq_led_bottom.py, rbq_sport_client.py, and rbq_sport_client_joy.py are all available under example/sport/.

Requirements ​

ItemMinimum
OSUbuntu 22.04
Python3.8 or later
CycloneDDS Python bindingInstalled via rbq_sdk/python/pyproject.toml

Install ​

bash
cd rbq_sdk/python
pip install -e .

Initialize DDS ​

python
from rbq_sdk_py.core.channel import ChannelFactoryInitialize

# Interface name — "lo" for the simulator and the on-robot stack,
# a NIC such as "eth0" to reach a robot from another host
ChannelFactoryInitialize(0, nic)

Pass None (or omit the second argument) to let CycloneDDS auto-detect the interface. The bundled examples default to "lo" instead of auto-detecting, so they match the simulator without any argument.

SportClient ​

python
from rbq_sdk_py.sport.sport_client import SportClient

sport = SportClient()
sport.Init()

sport.BalanceStand()
sport.Move(vx=0.5, vy=0.0, vyaw=0.0)
sport.SwitchGait(ID_DEFAULT_MODE)
sport.Damp()

Publishing custom messages ​

python
from rbq_sdk_py.core.channel import ChannelPublisher
# IDL types are imported from the example's _rbq_idl package
from _rbq_idl import HighLevelCommand_, Bool_

pub = ChannelPublisher("rt/rbq/cmd/high_level", HighLevelCommand_)
pub.Init()

msg = HighLevelCommand_()
msg.gait_state = 1
msg.vel_x = 0.5
pub.Write(msg)

Subscribing to messages ​

python
from rbq_sdk_py.core.channel import ChannelSubscriber
from _rbq_idl import Imu_

def on_imu(sample):
    print(sample.angular_velocity.x)

sub = ChannelSubscriber("rt/rbq/imu", Imu_)
sub.Init(handler=on_imu, queueLen=4)

Joystick (Linux /dev/input/js*) ​

The Python examples include a self-contained Joy class that reads raw Linux joystick events without any external dependency:

python
joy = Joy("/dev/input/js0")
joy.open()

while True:
    joy.poll()
    lx = deadzone(joy.ax[AXIS_LX], DEADZONE)
    ly = deadzone(joy.ax[AXIS_LY], DEADZONE)
    joy.end_frame()
    time.sleep(0.01)

The pick_joy_path(argv) helper auto-detects a connected gamepad (prefers Logitech/Xbox/Wireless by name, then falls back to the first /dev/input/js* node).

Example programs ​

ExampleWhat it demonstrates
Sport Client (Python)Terminal CLI for all SportClient commands
Sport Client Joystick (Python)Gamepad-driven SportClient with full button mapping
High Level Command (Python)50 Hz HighLevelCommand publisher with joystick velocity
Low Level (RL Policy) (Python)Joint-level control + ONNX policy runner
Target Go (Python)One-shot walk-to-pose command publisher
Bottom LED (Python)Set the bottom status LEDs and print the reported state
Wheel Control (Python)Spin the wheels of an RBQ wheel robot (wheel joints only)

This user manual is intended for RBQ users.