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
    └── idl/
        └── _rbq_idl/               # Generated Python IDL bindings

Note — examples under development: rbq_high_level.py and rbq_low_level.py are currently in development and not yet released. Only rbq_sport_client.py and rbq_sport_client_joy.py are available.

Requirements

ItemMinimum
OSUbuntu 22.04
Python3.8 or later
CycloneDDS Python bindingInstalled via rbq_sdk/python/setup.py

Install

bash
cd rbq_sdk/python
pip install -e .

Initialize DDS

python
from rbq_sdk_py.core.channel import ChannelFactoryInitialize

# argv[1] is the network interface, e.g. "eth0"
ChannelFactoryInitialize(0, nic)

Pass None (or omit the second argument) to let CycloneDDS auto-detect the interface.

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/highLevel", 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/info/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

This user manual is intended for RBQ users.