Skip to content

Bottom LED — Python Example ​

Source: rbq_sdk/python/example/sport/rbq_led_bottom.py

Python port of the C++ Bottom LED. Sets the two status LEDs under the body by publishing one LedBottom_ message on rt/rbq/cmd/led_bottom, then prints the 1 Hz LedBottomState_ the robot reports on rt/rbq/led_bottom.

How it works ​

  1. Reads interface and optional side mode r g b on_ms off_ms count from the command line.
  2. Calls ChannelFactoryInitialize(0, interface), then creates ChannelPublisher("rt/rbq/cmd/led_bottom", LedBottom_) and ChannelSubscriber("rt/rbq/led_bottom", LedBottomState_) with a handler that keeps the latest state.
  3. Waits ~0.5 s for DDS discovery, fills the LedBottom_ message and publishes once.
  4. Waits ~2.5 s for the IF board to apply the setting and report it, prints the last LedBottomState_ received and exits.

The on-robot Network process checks the ranges (the same check as PUT /api/led/bottom), Motion sends the setting to the IF board over CAN FD, and the board's once-a-second report comes back on rt/rbq/led_bottom.

Prerequisites ​

  • rbq_sdk_py importable — see Python SDK Overview.
  • The robot stack running on the same DDS interface.
  • A CAN FD robot. On other robots Network rejects the command and publishes no state, so the example prints no state on rt/rbq/led_bottom. In the simulator Motion stands in for the IF board and MuJoCo shows the two LEDs under the body, so the example works there too.

Run ​

bash
cd RBQ/rbq_sdk/python/example/sport
python3 rbq_led_bottom.py [networkInterface] [side] [mode] [r] [g] [b] [on_ms] [off_ms] [count]

# Both LEDs steady blue (the defaults) — the interface always comes first:
python3 rbq_led_bottom.py eth0

# Right LED blinking red, 0.5 s on / 0.5 s off, forever:
python3 rbq_led_bottom.py eth0 right blink 255 0 0 500 500 0

# Both LEDs off:
python3 rbq_led_bottom.py eth0 both off

All arguments are positional, so the interface must be the first argument.

Arguments and defaults are identical to the C++ version. Use the interface that reaches the robot — lo when running on the robot PC, your NIC from another host.

Example output ​

[rbq_led_bottom] published: side=right mode=blink rgb=255,0,0 on_ms=500 off_ms=500 count=0
[rbq_led_bottom] state: age_ms=312 configured=1 if_fw=2026100701
  right: mode=blink rgb=255,0,0 on_ms=500 off_ms=500 count=0 actual=255,0,0 lpf_w=0.6
  left: mode=on rgb=0,0,255 on_ms=0 off_ms=0 count=0 actual=0,0,255 lpf_w=0.4

Values depend on the robot. actual is the last output after the IF board's power limit, and limited appears when that limit reduced the output within the last second.

This user manual is intended for RBQ users.