Skip to main content

C++ API Reference

Public C++ APIs are under include/booster in the release package. After running sudo ./install.sh, headers and libraries are installed to /usr/local/include and /usr/local/lib. The SDK requires C++17.

Core Headers​

Header

Contents

booster/robot/channel/channel_factory.hpp

DDS initialization and topic creation.

booster/robot/channel/channel_publisher.hpp

Topic publisher template.

booster/robot/channel/channel_subscriber.hpp

Topic subscriber template.

booster/robot/rpc/rpc_client.hpp

Low-level RPC client wrapper.

booster/robot/rpc/error.hpp

RPC status codes.

booster/robot/b1/b1_loco_client.hpp

Motion-control interfaces.

booster/robot/b1/b1_loco_api.hpp

Motion API parameters, responses, and enums.

booster/robot/b1/b1_api_const.hpp

Motion topics, joint indices, and hand constants.

booster/robot/audio/audio_manager.h

Audio module entry point.

booster/robot/ai/client.hpp

AI and LUI clients.

booster/robot/vision/vision_client.hpp

Vision client.

booster/robot/camera/camera_client.hpp

Camera catalog client.

Build an External Application​

First run sudo ./install.sh as described in Quick Start. The installation directories are in the compiler and linker system search paths, so applications do not need target_include_directories or target_link_directories:

cmake_minimum_required(VERSION 3.15)
project(my_booster_app CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Threads REQUIRED)

add_executable(my_booster_app main.cpp)
target_link_libraries(
my_booster_app
PRIVATE
booster_robotics_sdk
Threads::Threads
${CMAKE_DL_LIBS}
rt)

Build the application:

cmake -S . -B build
cmake --build build -j

See C++ Example Index for the release package’s bundled examples.

RPC Error Codes​

C++ RPC wrappers return int32_t. Status-code constants are defined in booster/robot/rpc/error.hpp. Check every return value:

int32_t ret = client.Move(0.2F, 0.0F, 0.0F);
if (ret != booster::robot::kRpcStatusCodeSuccess) {
// Handle the error.
}

Value

Constant

Meaning

Recommended handling

-1

kRpcStatusCodeInvalid

Default or invalid state, usually before a request has been sent.

Verify that the client was initialized, the service is available, and the send path was reached.

0

kRpcStatusCodeSuccess

Request succeeded.

Read output parameters or the response body and continue.

100

kRpcStatusCodeTimeout

No RPC response arrived within the timeout.

Check the communication IP, service state, and timeout. Retry only operations that are safe to repeat, with a bounded retry count.

400

kRpcStatusCodeBadRequest

Invalid request, commonly caused by an invalid value, range, or request body.

Check the interface contract and robot model. Do not repeatedly retry unchanged parameters.

409

kRpcStatusCodeConflict

The request conflicts with the current robot state, often while another state transition is in progress.

Wait for the current operation to finish, then confirm the mode with GetMode or GetStatus before retrying.

429

kRpcStatusCodeRequestTooFrequent

Requests are being sent too frequently.

Reduce the call rate and use bounded backoff. Prefer the corresponding non-blocking command interface for continuous control.

500

kRpcStatusCodeInternalServerError

Internal error in a robot service node.

Preserve request parameters, response data, and robot-side logs. Retry transient failures only a limited number of times.

501

kRpcStatusCodeServerRefused

The robot service node refused the request.

Confirm that the service is running, the interface is supported by the current firmware, and the robot is in an allowed state.

502

kRpcStatusCodeStateTransitionFailed

Robot state-machine transition failed, usually because the transition is illegal or a previous transition has not completed.

Query the current mode and state, wait for existing transitions, and retry using the required state sequence.

Typed methods return response data through output parameters:

booster::robot::b1::GetStatusResponse status;
int32_t ret = client.GetStatus(status);

To inspect a raw RPC response:

booster::robot::Response resp;
int32_t ret = client.SendApiRequestWithResponse(
booster::robot::b1::LocoApiId::kGetStatus,
"",
resp);
if (ret == booster::robot::kRpcStatusCodeSuccess) {
std::cout << resp.GetBody() << "\n";
}

Topic Templates​

Publish:

booster::robot::ChannelPublisher<booster_interface::msg::LowCmd> pub(
booster::robot::b1::kTopicJointCtrl);
pub.InitChannel();
pub.Write(&cmd);
pub.CloseChannel();

Subscribe:

booster::robot::ChannelSubscriber<booster_interface::msg::LowState> sub(
booster::robot::b1::kTopicLowState,
[](const void *msg) {
const auto *state =
static_cast<const booster_interface::msg::LowState *>(msg);
});
sub.InitChannel();

ChannelSubscriberOptions configures reliable and the underlying executor options.

IDL Messages​

Generated IDL headers are under include/booster/idl in the release package and are available at /usr/local/include/booster/idl after installation. Common namespaces include booster_interface::msg, geometry_msgs::msg, sensor_msgs::msg, nav_msgs::msg, and booster_msgs::audio.

#include <booster/idl/b1/LowCmd.h>
#include <booster/idl/b1/MotorCmd.h>

booster_interface::msg::LowCmd cmd;
std::vector<booster_interface::msg::MotorCmd> motors;