Device Information Interfaces
Device-catalog interfaces are distributed across two clients:
B1LocoClient:GetSensors,GetHands, andGetRobotModel.CameraClient:GetCameras.
These methods return DeviceInfo, a JSON-backed container with two fields:
kind_: the data category, defined byDeviceInfoKind.json_: the RPC response body, which parser helpers convert into concrete IDL messages.
DeviceInfoKind
Enum | Value | Description |
|---|---|---|
| -1 | Unclassified data; |
| 0 | IMU and sensor catalog. |
| 1 | Hand end-effector catalog. |
| 2 | Static robot model. |
| 3 | Camera catalog. |
C++ Usage
#include <booster/idl/b1/ImuInfo.h>
#include <booster/robot/b1/b1_loco_client.hpp>
#include <booster/robot/channel/channel_factory.hpp>
#include <booster/robot/common/device_info_parser.hpp>
#include <booster/robot/rpc/error.hpp>
booster::robot::ChannelFactory::Instance()->Init(0, "<network_ip>");
booster::robot::b1::B1LocoClient client;
client.Init();
booster::robot::b1::DeviceInfo info;
int32_t ret = client.GetSensors(info);
if (ret == booster::robot::kRpcStatusCodeSuccess) {
booster_interface::msg::ImuInfoList imus;
booster::robot::ImuInfoListFromDeviceInfo(imus, info);
for (const auto &imu : imus.imus()) {
// Use imu.
}
}
Parser helpers are declared in include/booster/robot/common/device_info_parser.hpp:
Function | Input kind | Output message |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Call info.ToJson().dump(2) to inspect the raw JSON.
Public Containers and Parsers
DeviceInfo::FromJson(json) reads kind_ and json_ from a service response and ToJson() returns the original JSON; it does not guess a concrete IDL type. Position, Orientation, Posture, Quaternion, and Transform are public JSON types shared by motion and camera APIs. Position x_, y_, and z_ are metres; Euler angles roll_, pitch_, and yaw_ are radians; quaternions use x_, y_, z_, w_ order; Posture combines position and Euler orientation; Transform combines position and a quaternion. Each type provides FromJson and ToJson.
DeviceInfoKind values are kUnknown = -1 (unclassified data or a bare RPC body), kSensors = 0 (IMU/sensor catalog), kHands = 1 (hand-device catalog), kRobotModel = 2 (static robot model), and kCamera = 3 (camera catalog). Public parser helpers ImuInfoListFromDeviceInfo, HandListFromDeviceInfo, RobotModelFromDeviceInfo, and CameraListFromDeviceInfo clear the output when kind_ does not match. Check the RPC status and kind_ before reading a parsed result.
CameraClient
#include <booster/idl/b1/Camera.h>
#include <booster/robot/camera/camera_client.hpp>
#include <booster/robot/common/device_info_parser.hpp>
booster::robot::camera::CameraClient camera;
camera.Init();
booster::robot::b1::DeviceInfo info;
if (camera.GetCameras(info) == booster::robot::kRpcStatusCodeSuccess) {
booster_interface::msg::CameraList cameras;
booster::robot::CameraListFromDeviceInfo(cameras, info);
for (const auto &item : cameras.cameras()) {
// Use item.
}
}