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 |
|---|---|
| DDS initialization and topic creation. |
| Topic publisher template. |
| Topic subscriber template. |
| Low-level RPC client wrapper. |
| RPC status codes. |
| Motion-control interfaces. |
| Motion API parameters, responses, and enums. |
| Motion topics, joint indices, and hand constants. |
| Audio module entry point. |
| AI and LUI clients. |
| Vision client. |
| 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 |
|---|---|---|---|
|
| 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. |
|
| Request succeeded. | Read output parameters or the response body and continue. |
|
| 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. |
|
| 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. |
|
| 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 |
|
| Requests are being sent too frequently. | Reduce the call rate and use bounded backoff. Prefer the corresponding non-blocking command interface for continuous control. |
|
| 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. |
|
| 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. |
|
| 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;