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]

# Simulator / on-robot stack — interface defaults to lo
./bin/rbq_sport_client

# Real robot — pass the interface that reaches it
./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
8get_stateGetState() — print FSM / speed / process state
11stand_upStandUp() — lock joints in standing position
12enter_leftside_gaitLeftSideGait(1)
13exit_leftside_gaitLeftSideGait(0)

The example program's list also prints commands the robot does not implement; those return a "not implemented" error. Only the commands above are supported.

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 initialized 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.