Skip to content

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:

  1. Reads a line of input from stdin (list, a command name, or a command ID).
  2. Updates the current test_option.
  3. Calls the matching SportClient method 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.bash

Binary: bin/rbq_sport_client

Run

bash
./bin/rbq_sport_client <networkInterface>
# e.g.
./bin/rbq_sport_client eth0

Available commands

Type list at the prompt to print all commands, or use the numeric ID directly.

IDNameSportClient method called
0dampDamp() — high-damping e-stop
1balance_standBalanceStand() — balanced standing
2stop_moveStopMove() — stop in place
3stand_downStandDown() — go prone
4recovery_standRecoveryStand() — stand up from fall
5moveMove(0.0, 0.0, 0.5) — rotate in place
6switch_gaitSwitchGait(0) — switch to default gait
7speed_levelSpeedLevel(1) — set speed level
8get_stateGetState() — print FSM / speed / process state
9recovery_switchSetAutoRecovery(0) — disable auto-recovery
10body_heightBodyHeight(0.3f) — set body height +0.3 m
11stand_upStandUp() — lock joints in standing position
12enter_leftside_gaitLeftSideGait(1)
13exit_leftside_gaitLeftSideGait(0)
14enter_handstandHandStand(1)
15exit_handstandHandStand(0)
16front_flipFrontFlip() ⚠️
17back_flipBackFlip() ⚠️
18poseBodyPosition(0.2, 0.2, -0.2, 0.2)
19eulerEuler(0.2, 0.3, 0.3)

⚠️ Cautionfront_flip and back_flip require 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 SportClient is initialised with SetNoReply(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_until enforces the 20 ms loop period.
  • Error counting: A res_count variable accumulates consecutive failures and prints the count alongside error codes.

See also

This user manual is intended for RBQ users.