Sport Client — C++ Example
Source: rbq_sdk/cpp/example/src/rbq_sport_client.cpp
An interactive terminal application that sends SportClient commands to the robot one at a time.
Type a command name (or its numeric ID) and the application executes it in a 50 Hz loop until you type a different command.
How it works
The program has a single loop that:
- Reads a line of input from
stdin(list, a command name, or a command ID). - Updates the current
test_option. - Calls the matching
SportClientmethod on every 20 ms tick.
There is no separate control thread — the terminal read blocks until the user presses Enter, making this a simple sequential test harness.
Prerequisites
- RBQ SDK built and installed — see C++ SDK Overview.
- Robot stack running (simulation or hardware) and reachable on the same network.
Build
From rbq_sdk/cpp/example/:
bash
bash scripts/setup.bash
bash scripts/build.bashBinary: bin/rbq_sport_client
Run
bash
./bin/rbq_sport_client <networkInterface>
# e.g.
./bin/rbq_sport_client eth0Available commands
Type list at the prompt to print all commands, or use the numeric ID directly.
| ID | Name | SportClient method called |
|---|---|---|
| 0 | damp | Damp() — high-damping e-stop |
| 1 | balance_stand | BalanceStand() — balanced standing |
| 2 | stop_move | StopMove() — stop in place |
| 3 | stand_down | StandDown() — go prone |
| 4 | recovery_stand | RecoveryStand() — stand up from fall |
| 5 | move | Move(0.0, 0.0, 0.5) — rotate in place |
| 6 | switch_gait | SwitchGait(0) — switch to default gait |
| 7 | speed_level | SpeedLevel(1) — set speed level |
| 8 | get_state | GetState() — print FSM / speed / process state |
| 9 | recovery_switch | SetAutoRecovery(0) — disable auto-recovery |
| 10 | body_height | BodyHeight(0.3f) — set body height +0.3 m |
| 11 | stand_up | StandUp() — lock joints in standing position |
| 12 | enter_leftside_gait | LeftSideGait(1) |
| 13 | exit_leftside_gait | LeftSideGait(0) |
| 14 | enter_handstand | HandStand(1) |
| 15 | exit_handstand | HandStand(0) |
| 16 | front_flip | FrontFlip() ⚠️ |
| 17 | back_flip | BackFlip() ⚠️ |
| 18 | pose | BodyPosition(0.2, 0.2, -0.2, 0.2) |
| 19 | euler | Euler(0.2, 0.3, 0.3) |
⚠️ Caution —
front_flipandback_fliprequire a clear open area.
Run these only when the robot has sufficient space on all sides.
Usage example
$ ./bin/rbq_sport_client eth0
Input "list " to list all test option ...
balance_stand
Test: balance_stand, test_id: 1
Request successed: balance_stand, code: 0
Request successed: balance_stand, code: 0
...
move
Test: move, test_id: 5
Request successed: move, code: 0
...Key implementation notes
- SetNoReply(true): The
SportClientis initialised withSetNoReply(true). This fires each request as a DDS publish without waiting for an RPC response — suitable for high-frequency control over WiFi where round-trip latency is unpredictable. - 50 Hz tick:
std::this_thread::sleep_untilenforces the 20 ms loop period. - Error counting: A
res_countvariable accumulates consecutive failures and prints the count alongside error codes.
