Skip to content

Bottom LED — C++ Example ​

Source: rbq_sdk/cpp/example/src/rbq/rbq_led_bottom.cpp

Sets the two status LEDs under the body (right and left) and prints the state the robot reports back. It publishes one LedBottom message on rt/rbq/cmd/led_bottom, waits for the 1 Hz LedBottomState on rt/rbq/led_bottom, prints it and exits.

How it works ​

  1. Reads interface and optional side mode r g b on_ms off_ms count from the command line.
  2. Initializes the DDS ChannelFactory on the given interface, creates a Publisher<LedBottom_> on rt/rbq/cmd/led_bottom and a Subscriber<LedBottomState_> on rt/rbq/led_bottom.
  3. Waits ~500 ms for DDS discovery, fills the LedBottom fields 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 receives the command, checks the ranges (the same check as PUT /api/led/bottom) and passes it to Motion, which sends it to the IF board over CAN FD. The IF board holds the setting and reports it back once a second; Network republishes that report on rt/rbq/led_bottom.

Prerequisites ​

  • RBQ SDK built and installed — see C++ SDK Overview.
  • The robot stack running and reachable 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.

Build ​

From rbq_sdk/cpp/example/:

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

Binary: bin/rbq_led_bottom

Run ​

bash
./bin-x86_64/rbq_led_bottom [interface] [side] [mode] [r] [g] [b] [on_ms] [off_ms] [count]

# Both LEDs steady blue (the defaults) — the interface always comes first:
./bin-x86_64/rbq_led_bottom eth0

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

# Both LEDs off:
./bin-x86_64/rbq_led_bottom eth0 both off

All arguments are positional, so the interface must be the first argument. Use the interface that reaches the robot — lo when running on the robot PC, your NIC from another host.

ArgMeaningDefault
interfaceCycloneDDS interface (lo on the robot / NIC from another host)—
sideright / left / both — the other LED keeps its settingboth
modeoff / on / blinkon
r g bcolour, 0–255 each0 0 255
on_ms off_msblink on / off time, 10–2550 ms (10 ms steps); ignored unless blink500 500
countblink repeats, 0 = forever; ignored unless blink0

Out-of-range values are rejected by Network (logged on the robot) and the LEDs stay as they were.

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. configured=0 means the IF board rebooted and holds no setting — Motion resends the last one by itself.

This user manual is intended for RBQ users.