Skip to content

Sport Client — C++ Example ​

Source: rbq_sdk/cpp/example/src/rbq/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 press Enter; the application sends that command once.

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 once, then waits for the next line.

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-x86_64/rbq_sport_client

Run ​

bash
./bin-x86_64/rbq_sport_client [networkInterface]

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

# Real robot — pass the interface that reaches it
./bin-x86_64/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 the walk gait (49)
7speed_levelSpeedLevel(1) — fast: move speeds × 1.5
8get_stateGetState() — print the robot state
9body_heightBodyHeight(-0.1) — body 10 cm lower
10stand_upStandUp() — lock joints in standing position
11enter_leftside_gaitLeftSideGait(1)
12exit_leftside_gaitLeftSideGait(0) — back to the walk gait (49)
13enter_handstandHandStand(1) — switch to the RL_FRONT_WALK (31) policy
14exit_handstandHandStand(0) — back to the walk gait (49)
15poseBodyPosition(0.0, 0.0, -0.1, 0.2) — body 10 cm lower, turned 0.2 rad
16eulerEuler(0.2, 0.3, 0.3) — tilt the body (roll, pitch, yaw in radians)

WARNING

Test IDs 11–14 in an open area — the example source marks them "Caution: test in open area".

Every command prints code: 0: SetNoReply(true) does not wait for the robot's reply. Only get_state waits, because it needs the answer.

move, body_height, pose and euler act only when control mode is HighLevel. The example turns it on at start by publishing true on rt/rbq/cmd/switch_control_mode (ROS /rbq/cmd/switch_control_mode); moving the gamepad stick turns it off again. While it is off the robot answers 3205 (rejected) instead of 0 — the example does not see that, because of SetNoReply(true). move also needs a walking gait — run switch_gait (6) before move.

switch_gait sets the walk gait 49. SwitchGait(1) (running) sets the same gait — 49 takes its fast policy above 1.3 m/s on its own. SwitchGait(2) (climb) sets the vision walk 48, which uses the robot's vision for the terrain; without vision it keeps walking without terrain input and gives no warning. Leaving the left-side gait or the handstand goes back to 49.

Euler(roll, pitch, yaw) takes radians. BodyHeight(h) and the z of BodyPosition(x, y, z, yaw) are metres from the default height; its yaw is radians. Standing (gait 1), the robot follows roll ±25°, pitch ±20°, yaw ±25° and height −0.15 to +0.05 m. Walking (48, 49), it follows only pitch (±25°) and height (−0.25 to +0.1 m). Larger values are clipped. The pose stays while you move or stop_move and goes back to level on stand_up, stand_down, balance_stand, recovery_stand and damp. If the robot sits, falls or is stopped another way (the app, an e-stop), the SDK drops the pose and the next move or stop_move levels the body — a robot stood up again in HighLevel mode before that may keep the last pose. The robot cannot shift its body forward or sideways, so BodyPosition returns 3204 (parameter error) unless x and y are 0.

SpeedLevel(-1) is slow, 0 normal (the default) and 1 fast: the robot multiplies move speeds by 0.5, 1 or 1.5. The gait's own speed limit still applies. The level goes back to 0 when the robot software restarts.

get_state prints the robot's answer, one key per line:

KeyValue
fsm_idCurrent gait ID (Gait State IDs)
fsm_nameCurrent gait name
speed_level-1, 0 or 1
control_mode1 HighLevel, 0 joystick
is_standing1 or 0
is_fall1 or 0

Usage example ​

$ ./bin-x86_64/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
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.
  • One request per line: std::getline blocks until you press Enter, so the loop sends one request per line — it does not repeat the command.
  • 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.