### Install Dependencies with Install Script Source: https://github.com/boosterrobotics/booster_robotics_sdk/blob/main/README.md Run this script to install all necessary dependencies for the SDK. Ensure you have the required operating system and CPU architecture. ```bash sudo ./install.sh ``` -------------------------------- ### Run Generic Example Client Source: https://github.com/boosterrobotics/booster_robotics_sdk/blob/main/README.md Run a generic example client named 'xxx' locally. This client connects to a specified IP address. ```bash cd build ./xxx 127.0.0.1 ``` -------------------------------- ### Install Python SDK via Pip Source: https://github.com/boosterrobotics/booster_robotics_sdk/blob/main/README.md Recommended method for installing the Python SDK. Installs the pre-built package for easy integration. ```bash pip install booster_robotics_sdk_python --user ``` -------------------------------- ### Build C++ Examples Source: https://github.com/boosterrobotics/booster_robotics_sdk/blob/main/README.md Steps to build the C++ examples. This involves creating a build directory, navigating into it, configuring with CMake, and compiling the code. ```bash mkdir build cd build cmake .. make ``` -------------------------------- ### Build and Install Python SDK from Source Source: https://github.com/boosterrobotics/booster_robotics_sdk/blob/main/README.md Steps to build and install the Python SDK from source. This requires CMake and enables Python bindings. ```bash mkdir build cd build cmake .. -DBUILD_PYTHON_BINDING=on make sudo make install ``` -------------------------------- ### Install Python Build Dependencies Source: https://github.com/boosterrobotics/booster_robotics_sdk/blob/main/README.md Install necessary Python packages for building the SDK from source. Includes pybind11 and pybind11-stubgen. ```bash pip3 install pybind11 pip3 install pybind11-stubgen ``` -------------------------------- ### Run Python SDK Example Source: https://github.com/boosterrobotics/booster_robotics_sdk/blob/main/README.md Execute the Python SDK example script. This script likely demonstrates the functionality of the Python binding and requires an IP address. ```bash python3 python_example/sdk_pybind_b1_exmaple.py 127.0.0.1 ``` -------------------------------- ### Run b1_low_level_subscriber Source: https://github.com/boosterrobotics/booster_robotics_sdk/blob/main/README.md Execute the b1_low_level_subscriber locally. This example likely subscribes to low-level data streams. ```bash cd build ./b1_low_level_subscriber ``` -------------------------------- ### Posture Transitions - C++ Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Commands the robot to perform posture transitions: lie down, get up, or get up into a specific mode (e.g., kWalking). Includes error checking and a delay for sequential actions. ```cpp // C++ — lie down then get up into walking mode int32_t ret = client.LieDown(); // robot lies on its back if (ret != 0) { std::cerr << "LieDown failed: " << ret; } std::this_thread::sleep_for(std::chrono::seconds(5)); // Get up into default mode ret = client.GetUp(); // OR get up into a specific mode ret = client.GetUpWithMode(booster::robot::RobotMode::kWalking); if (ret != 0) { std::cerr << "GetUp failed: " << ret; } ``` -------------------------------- ### Export PATH for pybind11-stubgen Source: https://github.com/boosterrobotics/booster_robotics_sdk/blob/main/README.md If pybind11-stubgen is not found after installation, export the PATH to include the local bin directory. ```bash export PATH=/home/[user name]/.local/bin:$PATH ``` -------------------------------- ### Direct Low-Level Joint Control (Python) Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Sends low-level joint commands using Python. This example demonstrates how to set the head pitch joint to a specific angle (0.785 radians) and publishes the command at a 50 Hz rate. ```python # Python — low-level joint command (head pitch nod) from booster_robotics_sdk_python import ( ChannelFactory, B1LowCmdPublisher, LowCmd, LowCmdType, MotorCmd, B1JointCnt, B1JointIndex) import time ChannelFactory.Instance().Init(0) pub = B1LowCmdPublisher() pub.InitChannel() motor_cmds = [MotorCmd() for _ in range(B1JointCnt)] low_cmd = LowCmd() low_cmd.cmd_type = LowCmdType.PARALLEL low_cmd.motor_cmd = motor_cmds # Nod head: set head pitch joint to 0.785 rad low_cmd.motor_cmd[B1JointIndex.kHeadPitch.value].q = 0.785 low_cmd.motor_cmd[B1JointIndex.kHeadPitch.value].dq = 0.0 low_cmd.motor_cmd[B1JointIndex.kHeadPitch.value].kp = 4.0 low_cmd.motor_cmd[B1JointIndex.kHeadPitch.value].kd = 1.0 low_cmd.motor_cmd[B1JointIndex.kHeadPitch.value].weight = 1.0 while True: pub.Write(low_cmd) print("Published LowCmd") time.sleep(0.02) # 50 Hz ``` -------------------------------- ### Run b1_loco_example_client Source: https://github.com/boosterrobotics/booster_robotics_sdk/blob/main/README.md Execute the b1_loco_example_client locally. This client connects to a specified IP address, typically localhost. ```bash cd build ./b1_loco_example_client 127.0.0.1 ``` -------------------------------- ### Initialize B1LocoClient and Change Mode in C++ Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Initializes the high-level locomotion client and transitions the robot through different modes. Ensure ChannelFactory is initialized first. Mode changes may require delays. ```cpp #include #include #include #include int main(int argc, char* argv[]) { booster::robot::ChannelFactory::Instance()->Init(0, argv[1]); booster::robot::b1::B1LocoClient client; client.Init(); // or client.Init("my_robot") for named robot // Transition to Prepare mode (robot stands up) int32_t ret = client.ChangeMode(booster::robot::RobotMode::kPrepare); if (ret != 0) { std::cerr << "ChangeMode failed: " << ret << std::endl; return 1; } std::this_thread::sleep_for(std::chrono::seconds(3)); // Transition to Walking mode ret = client.ChangeMode(booster::robot::RobotMode::kWalking); if (ret != 0) { std::cerr << "ChangeMode failed: " << ret << std::endl; return 1; } std::cout << "Robot is now walking-ready" << std::endl; return 0; } ``` -------------------------------- ### Get Spatial Frame Transform - Python Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Retrieves the spatial transform between two frames. Requires importing Frame and Transform classes. The transform object is updated in-place. ```python # Python from booster_robotics_sdk_python import Frame, Transform tf = Transform() ret = client.GetFrameTransform(Frame.kBody, Frame.kRightHand, tf) if ret == 0: print(f"pos: {tf.position.x}, {tf.position.y}, {tf.position.z}") ``` -------------------------------- ### Initialize B1LocoClient and Change Mode in Python Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Initializes the high-level locomotion client in Python and switches between robot modes. ChannelFactory must be initialized prior to this. Mode transitions are synchronous. ```python from booster_robotics_sdk_python import B1LocoClient, ChannelFactory, RobotMode import sys, time ChannelFactory.Instance().Init(0, sys.argv[1]) client = B1LocoClient() client.Init() ret = client.ChangeMode(RobotMode.kPrepare) if ret != 0: print(f"ChangeMode failed: {ret}") sys.exit(1) time.sleep(3) ret = client.ChangeMode(RobotMode.kWalking) assert ret == 0, f"Walk mode failed: {ret}" ``` -------------------------------- ### Get Spatial Frame Transform - C++ Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Queries the transform (position and orientation) between two specified coordinate frames, such as body to right hand. Includes error checking and prints the resulting position and quaternion orientation. ```cpp // C++ — get transform from body frame to right hand frame #include #include booster::robot::Transform tf; int32_t ret = client.GetFrameTransform( booster::robot::Frame::kBody, booster::robot::Frame::kRightHand, tf); if (ret == 0) { std::cout << "Right hand position: " << tf.position_.x_ << ", " << tf.position_.y_ << ", " << tf.position_.z_ << std::endl; std::cout << "Orientation (quaternion xyzw): " << tf.orientation_.x_ << ", " << tf.orientation_.y_ << ", " << tf.orientation_.z_ << ", " << tf.orientation_.w_ << std::endl; } else { std::cerr << "GetFrameTransform failed: " << ret; } // Expected output: // Right hand position: 0.28, -0.18, 0.05 // Orientation (quaternion xyzw): 0.0, 0.71, 0.0, 0.71 ``` -------------------------------- ### Python: Subscribe to Low State and Odometry Feedback Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Subscribe to low state (IMU, joint data) and odometry feedback. Initialize ChannelFactory and then create subscribers for each data type. ```python from booster_robotics_sdk_python import ( ChannelFactory, B1LowStateSubscriber, B1OdometerStateSubscriber) import time def on_low_state(msg): imu = msg.imu_state print(f"rpy: {imu.rpy[0]:.3f}, {imu.rpy[1]:.3f}, {imu.rpy[2]:.3f}") print(f"Motors (parallel): {len(msg.motor_state_parallel)}") for i, m in enumerate(msg.motor_state_parallel): print(f" [{i}] q={m.q:.3f} dq={m.dq:.3f} tau={m.tau_est:.3f}") def on_odometer(msg): print(f"Odometry: x={msg.x:.3f} y={msg.y:.3f} theta={msg.theta:.3f}") ChannelFactory.Instance().Init(0) low_sub = B1LowStateSubscriber(on_low_state) odom_sub = B1OdometerStateSubscriber(on_odometer) low_sub.InitChannel() odom_sub.InitChannel() while True: time.sleep(1) ``` -------------------------------- ### B1LocoClient::Init / B1LocoClient::ChangeMode Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Connects to the locomotion service and sets the robot's operational mode. `Init()` should be called after `ChannelFactory::Init()`. `ChangeMode()` transitions the robot between different states like damping, preparing to stand, walking, or custom joint control. ```APIDOC ## B1LocoClient::Init / B1LocoClient::ChangeMode — Connect and set robot mode `B1LocoClient` is the primary high-level control interface. Call `Init()` after `ChannelFactory::Init()` to connect to the locomotion service, then use `ChangeMode` to transition between `kDamping` (all motors passive), `kPrepare` (standing still), `kWalking` (full locomotion), and `kCustom` (direct joint control). ### C++ Example ```cpp // C++ — initialize client and sequence through modes #include #include #include #include int main(int argc, char* argv[]) { booster::robot::ChannelFactory::Instance()->Init(0, argv[1]); booster::robot::b1::B1LocoClient client; client.Init(); // or client.Init("my_robot") for named robot // Transition to Prepare mode (robot stands up) int32_t ret = client.ChangeMode(booster::robot::RobotMode::kPrepare); if (ret != 0) { std::cerr << "ChangeMode failed: " << ret << std::endl; return 1; } std::this_thread::sleep_for(std::chrono::seconds(3)); // Transition to Walking mode ret = client.ChangeMode(booster::robot::RobotMode::kWalking); if (ret != 0) { std::cerr << "ChangeMode failed: " << ret << std::endl; return 1; } std::cout << "Robot is now walking-ready" << std::endl; return 0; } ``` ### Python Example ```python # Python — initialize and switch mode from booster_robotics_sdk_python import B1LocoClient, ChannelFactory, RobotMode import sys, time ChannelFactory.Instance().Init(0, sys.argv[1]) client = B1LocoClient() client.Init() ret = client.ChangeMode(RobotMode.kPrepare) if ret != 0: print(f"ChangeMode failed: {ret}") sys.exit(1) time.sleep(3) ret = client.ChangeMode(RobotMode.kWalking) assert ret == 0, f"Walk mode failed: {ret}" ``` ``` -------------------------------- ### Query Robot State with B1LocoClient Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Use GetMode, GetStatus, and GetRobotInfo to retrieve the robot's current mode, full status, and device metadata. Ensure the client is properly initialized. ```cpp // C++ — query robot state #include #include void PrintRobotInfo(booster::robot::b1::B1LocoClient &client) { // Current mode booster::robot::b1::GetModeResponse mode_resp; if (client.GetMode(mode_resp) == 0) { std::cout << "Current mode: " << static_cast(mode_resp.mode_) << std::endl; // 0=kDamping, 1=kPrepare, 2=kWalking, 3=kCustom, 4=kSoccer } // Full status booster::robot::b1::GetStatusResponse status_resp; if (client.GetStatus(status_resp) == 0) { std::cout << "Body control: " << static_cast(status_resp.current_body_control_) << std::endl; std::cout << "Active actions: " << status_resp.current_actions_.size() << std::endl; } // Device info booster::robot::b1::GetRobotInfoResponse info; if (client.GetRobotInfo(info) == 0) { std::cout << "Model: " << info.model_ << std::endl; std::cout << "Firmware: " << info.version_ << std::endl; std::cout << "Serial number: " << info.serial_number_ << std::endl; std::cout << "Edition: " << info.edition_ << std::endl; std::cout << "Region: " << info.region_ << std::endl; } } ``` ```python # Python — query mode from booster_robotics_sdk_python import GetModeResponse gm = GetModeResponse() ret = client.GetMode(gm) if ret == 0: print(f"Current mode: {gm.mode}") # Output: Current mode: RobotMode.kWalking ``` -------------------------------- ### Record and Replay Robot Trajectories with B1LocoClient Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Enable kinesthetic teaching by entering `ZeroTorqueDrag` mode, then use `RecordTrajectory` to capture motion. `ReplayTrajectory` plays back saved motion from a file. ```cpp // C++ — record then replay a kinesthetically taught motion // 1. Enter zero-torque drag mode so human can move the robot arms client.ZeroTorqueDrag(true); // 2. Start recording client.RecordTrajectory(true); std::this_thread::sleep_for(std::chrono::seconds(10)); // record 10s // 3. Stop recording client.RecordTrajectory(false); client.ZeroTorqueDrag(false); // 4. Replay the recorded trajectory from file int32_t ret = client.ReplayTrajectory("/home/user/recordings/motion1.traj"); if (ret != 0) { std::cerr << "Replay failed: " << ret; } ``` -------------------------------- ### Deploy Custom Neural Policies with B1LocoClient Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Load, activate, and unload custom RL policies using ONNX models. Configure parameters like action scale, KP, and KD gains, and specify joint ordering. Ensure correct model and trajectory file paths. ```cpp // C++ — load, activate, then unload a custom RL policy #include booster::robot::b1::CustomModelParams params; params.action_scale_ = std::vector(29, 0.25); // 29 joints for 7-DOF arm config params.kp_ = std::vector(29, 60.0); params.kd_ = std::vector(29, 1.5); booster::robot::b1::CustomModel model( "/home/user/models/policy.onnx", {params}, booster::robot::b1::JointOrder::kMuJoCo); booster::robot::b1::CustomTrainedTraj traj( "/home/user/recordings/traj.bin", model); std::string tid; int32_t ret = client.LoadCustomTrainedTraj(traj, tid); if (ret != 0) { std::cerr << "Load failed: " << ret; return; } std::cout << "Loaded with TID: " << tid << std::endl; // Activate the policy ret = client.ActivateCustomTrainedTraj(tid); if (ret != 0) { std::cerr << "Activate failed: " << ret; } // ... robot executes the policy ... // Unload when done client.UnloadCustomTrainedTraj(tid); ``` -------------------------------- ### Posture Transitions - Python Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Commands the robot to lie down and then stand up. A 5-second delay is included between actions. ```python # Python client.LieDown() import time; time.sleep(5) client.GetUp() ``` -------------------------------- ### B1LocoClient::RecordTrajectory / B1LocoClient::ReplayTrajectory Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Enables kinesthetic teaching: ZeroTorqueDrag makes joints compliant so the operator can physically pose the robot; RecordTrajectory captures the motion; ReplayTrajectory plays it back from a saved file. ```APIDOC ## B1LocoClient::RecordTrajectory / B1LocoClient::ReplayTrajectory — Trajectory recording and playback ### Description Enables kinesthetic teaching: `ZeroTorqueDrag` makes joints compliant so the operator can physically pose the robot; `RecordTrajectory` captures the motion; `ReplayTrajectory` plays it back from a saved file. ### Method - `ZeroTorqueDrag(bool enable)` - `RecordTrajectory(bool record)` - `ReplayTrajectory(const std::string& file_path)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp // C++ — record then replay a kinesthetically taught motion // 1. Enter zero-torque drag mode so human can move the robot arms client.ZeroTorqueDrag(true); // 2. Start recording client.RecordTrajectory(true); std::this_thread::sleep_for(std::chrono::seconds(10)); // record 10s // 3. Stop recording client.RecordTrajectory(false); client.ZeroTorqueDrag(false); // 4. Replay the recorded trajectory from file int32_t ret = client.ReplayTrajectory("/home/user/recordings/motion1.traj"); if (ret != 0) { std::cerr << "Replay failed: " << ret; } ``` ### Response #### Success Response (0) Indicates the trajectory operation was successful. #### Response Example `0` for success, non-zero for failure. ERROR HANDLING: - Returns a non-zero integer on failure. ``` -------------------------------- ### B1LocoClient::GetUp / B1LocoClient::LieDown / B1LocoClient::GetUpWithMode Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Commands the robot to transition between different postures: stand up, lie down, or stand up into a specific mode. ```APIDOC ## B1LocoClient::GetUp / B1LocoClient::LieDown / B1LocoClient::GetUpWithMode ### Description Commands the robot to stand up from a prone or fallen position, lie down, or stand up into a specific mode (`kWalking` or `kSoccer`). ### Methods - **LieDown()**: Commands the robot to lie down. - **GetUp()**: Commands the robot to stand up to the default mode. - **GetUpWithMode(RobotMode mode)**: Commands the robot to stand up into a specified mode. ### Parameters - **mode** (RobotMode) - Required for `GetUpWithMode` - Specifies the desired robot mode upon standing (e.g., `kWalking`, `kSoccer`). ### Request Example (C++) ```cpp // Lie down client.LieDown(); // Get up client.GetUp(); // Get up into walking mode client.GetUpWithMode(booster::robot::RobotMode::kWalking); ``` ### Request Example (Python) ```python # Lie down client.LieDown() # Get up client.GetUp() ``` ### Response - **ret** (int32_t) - Returns 0 on success, non-zero on failure. ``` -------------------------------- ### B1LocoClient::LionDancePrepare / LionDanceMove / LionDanceStart Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt A multi-step choreography API for executing a lion dance sequence. Must follow a specific state transition order. ```APIDOC ## B1LocoClient::LionDancePrepare / LionDanceMove / LionDanceStart ### Description A multi-step choreography API. Must follow state transition order: `LionDancePrepare(true)` → `LionDanceMove(true)` (optional) → `LionDanceStart(dance_id)`. Entering `LionDanceStart` from any other state can cause dangerous joint discontinuities. ### Method Call ### Endpoint N/A (SDK Methods) ### Parameters - **LionDancePrepare(prepare: bool)**: Prepares the robot for the lion dance. - **LionDanceMove(move: bool)**: Enables synchronized movement for the lion dance (optional). - **LionDanceStart(dance_id: int)**: Starts a specific lion dance sequence. ### Request Example ```cpp // C++ — lion dance choreography (MUST follow transition rules) // Step 1: Enter prepare pose (from Walking mode) int32_t ret = client.LionDancePrepare(true); if (ret != 0) { std::cerr << "Prepare failed: " << ret; return; } std::this_thread::sleep_for(std::chrono::seconds(2)); // Step 2 (optional): Enter synchronized movement mode ret = client.LionDanceMove(true); std::this_thread::sleep_for(std::chrono::seconds(1)); // Step 3: Start a specific lion dance (only from LionDancePrepare or LionDanceMove) ret = client.LionDanceStart(0); // dance_id 0 if (ret != 0) { std::cerr << "LionDanceStart failed: " << ret; } // Exit: stop prepare pose client.LionDancePrepare(false); ``` ### Response #### Success Response (0) Returns 0 on success for each step. #### Error Response Returns a non-zero integer on failure. #### Response Example ``` 0 ``` ``` -------------------------------- ### Python: Subscribe to Dexterous Hand and Touch Data Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Subscribe to dexterous hand reply data (finger angles, forces, etc.) and tactile/touch sensor data. Initialize ChannelFactory before creating subscribers. ```python from booster_robotics_sdk_python import ( ChannelFactory, B1LowHandDataScriber, B1LowHandTouchDataScriber) import time def on_hand_data(msg): print(f"Hand index: {msg.hand_index}, type: {msg.hand_type}") for i, p in enumerate(msg.hand_data): print(f" finger[{i}] angle={p.angle} force={p.force} " f"current={p.current} temp={p.temp} err={p.error}") def on_touch_data(msg): print(f"Touch — hand: {msg.hand_index}") td = msg.touch_data print(f" finger_one: {list(td.finger_one)}") print(f" finger_palm: {list(td.finger_palm)}") ChannelFactory.Instance().Init(0) hand_sub = B1LowHandDataScriber(on_hand_data) touch_sub = B1LowHandTouchDataScriber(on_touch_data) hand_sub.InitChannel() touch_sub.InitChannel() while True: time.sleep(1) ``` -------------------------------- ### B1LocoClient::LoadCustomTrainedTraj / ActivateCustomTrainedTraj / UnloadCustomTrainedTraj Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Loads an ONNX/policy model file onto the robot with PD gain and action-scale configuration, returns a trajectory ID, then activates or unloads it. Supports both MuJoCo and IsaacLab joint orderings. ```APIDOC ## B1LocoClient::LoadCustomTrainedTraj / ActivateCustomTrainedTraj / UnloadCustomTrainedTraj — Neural policy deployment ### Description Loads an ONNX/policy model file onto the robot with PD gain and action-scale configuration, returns a trajectory ID, then activates or unloads it. Supports both MuJoCo and IsaacLab joint orderings. ### Method - `LoadCustomTrainedTraj(const CustomTrainedTraj& traj, std::string& tid)` - `ActivateCustomTrainedTraj(const std::string& tid)` - `UnloadCustomTrainedTraj(const std::string& tid)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp // C++ — load, activate, then unload a custom RL policy #include booster::robot::b1::CustomModelParams params; params.action_scale_ = std::vector(29, 0.25); // 29 joints for 7-DOF arm config params.kp_ = std::vector(29, 60.0); params.kd_ = std::vector(29, 1.5); booster::robot::b1::CustomModel model( "/home/user/models/policy.onnx", {params}, booster::robot::b1::JointOrder::kMuJoCo); booster::robot::b1::CustomTrainedTraj traj( "/home/user/recordings/traj.bin", model); std::string tid; int32_t ret = client.LoadCustomTrainedTraj(traj, tid); if (ret != 0) { std::cerr << "Load failed: " << ret; return; } std::cout << "Loaded with TID: " << tid << std::endl; // Activate the policy ret = client.ActivateCustomTrainedTraj(tid); if (ret != 0) { std::cerr << "Activate failed: " << ret; } // ... robot executes the policy ... // Unload when done client.UnloadCustomTrainedTraj(tid); ``` ### Response #### Success Response (0) Indicates the custom trained trajectory operation was successful. #### Response Example `0` for success, non-zero for failure. `tid` is populated with the trajectory ID on successful load. ERROR HANDLING: - Returns a non-zero integer on failure. ``` -------------------------------- ### Switch Locomotion Gait Type with B1LocoClient Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Use `SwitchGait` to select between different locomotion controllers like whole-body humanlike or half-body humanlike (v1/v2). Check the return value for errors. ```cpp // C++ — switch gait client.SwitchGait(booster::robot::b1::GaitType::kWholeBodyHumanlikeGait); client.SwitchGait(booster::robot::b1::GaitType::kHalfBodyHumanlikeGait); int32_t ret = client.SwitchGait(booster::robot::b1::GaitType::kHalfBodyHumanlikeGaitV2); if (ret != 0) { std::cerr << "SwitchGait failed: " << ret; } ``` -------------------------------- ### Whole-Body Control Modes with B1LocoClient Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Switch to whole-body controller (WBC) locomotion using `EnterWBCGait`. Enable independent upper-body control with `UpperBodyCustomControl(true)` while the lower body moves autonomously. Use `ExitWBCGait` to return to default locomotion. ```cpp // C++ — enter WBC gait, then switch to upper body custom control client.EnterWBCGait(); // ... robot walks using WBC controller ... client.UpperBodyCustomControl(true); // enable custom upper body // ... publish joint commands to arms via LowCmd while legs walk autonomously ... client.UpperBodyCustomControl(false); // disable client.ExitWBCGait(); ``` -------------------------------- ### Control Gripper with B1LocoClient Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Control the Inspire EG2-4C2 gripper by specifying position, force, and speed. Supports 'kPosition' mode (stops at target or contact) and 'kForce' mode (maintains applied force). ```cpp // C++ — open left gripper halfway in position mode #include booster::robot::b1::GripperMotionParameter motion; motion.position_ = 500; // 500/1000 * 77mm ≈ 38.5 mm opening motion.force_ = 100; // reaction force threshold motion.speed_ = 100; // movement speed int32_t ret = client.ControlGripper( motion, booster::robot::b1::GripperControlMode::kPosition, booster::robot::b1::HandIndex::kLeftHand); if (ret != 0) { std::cerr << "Gripper control failed: " << ret; } // Force mode — gripper keeps squeezing until specified force motion.position_ = 1000; motion.force_ = 300; motion.speed_ = 50; client.ControlGripper(motion, booster::robot::b1::GripperControlMode::kForce, booster::robot::b1::HandIndex::kRightHand); ``` ```python # Python from booster_robotics_sdk_python import GripperMotionParameter, GripperControlMode, B1HandIndex motion = GripperMotionParameter() motion.position = 500 motion.force = 100 motion.speed = 100 ret = client.ControlGripper(motion, GripperControlMode.kPosition, B1HandIndex.kLeftHand) if ret != 0: print(f"Gripper failed: {ret}") ``` -------------------------------- ### Execute Lion Dance Choreography Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt A multi-step API for executing a lion dance sequence. It is crucial to follow the specified state transition order: `LionDancePrepare(true)` → `LionDanceMove(true)` (optional) → `LionDanceStart(dance_id)`. Deviating from this order can lead to dangerous joint movements. ```cpp // C++ — lion dance choreography (MUST follow transition rules) // Step 1: Enter prepare pose (from Walking mode) int32_t ret = client.LionDancePrepare(true); if (ret != 0) { std::cerr << "Prepare failed: " << ret; return; } std::this_thread::sleep_for(std::chrono::seconds(2)); // Step 2 (optional): Enter synchronized movement mode ret = client.LionDanceMove(true); std::this_thread::sleep_for(std::chrono::seconds(1)); // Step 3: Start a specific lion dance (only from LionDancePrepare or LionDanceMove) ret = client.LionDanceStart(0); // dance_id 0 if (ret != 0) { std::cerr << "LionDanceStart failed: " << ret; } // Exit: stop prepare pose client.LionDancePrepare(false); ``` -------------------------------- ### Play and Stop Sound Files with B1LocoClient Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Use `PlaySound` with the absolute path to an audio file on the robot's filesystem. `StopSound` halts any currently playing audio. ```cpp // C++ — play and stop a sound file int32_t ret = client.PlaySound("/home/user/audio/hello.wav"); if (ret != 0) { std::cerr << "PlaySound failed: " << ret; } std::this_thread::sleep_for(std::chrono::seconds(3)); client.StopSound(); ``` -------------------------------- ### Initialize ChannelFactory in C++ Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Initializes the DDS transport layer. Must be called once before creating any clients or publishers. Specify the domain ID and optionally the network interface. ```cpp #include int main(int argc, char* argv[]) { // argv[1] is the network interface, e.g. "eth0" or "127.0.0.1" booster::robot::ChannelFactory::Instance()->Init(0, argv[1]); // ... create clients, publishers, subscribers } ``` -------------------------------- ### B1LocoClient::PlaySound / B1LocoClient::StopSound Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Plays a local audio file on the robot by providing its absolute path on the robot's filesystem. ```APIDOC ## B1LocoClient::PlaySound / B1LocoClient::StopSound — Audio playback ### Description Plays a local audio file on the robot by providing its absolute path on the robot's filesystem. ### Method - `PlaySound(const std::string& audio_path)` - `StopSound()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp // C++ — play and stop a sound file int32_t ret = client.PlaySound("/home/user/audio/hello.wav"); if (ret != 0) { std::cerr << "PlaySound failed: " << ret; } std::this_thread::sleep_for(std::chrono::seconds(3)); client.StopSound(); ``` ### Response #### Success Response (0) Indicates the sound playback was successfully started or stopped. #### Response Example `0` for success, non-zero for failure. ERROR HANDLING: - Returns a non-zero integer on failure. ``` -------------------------------- ### ChannelFactory::Init Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Initializes the DDS transport layer. This singleton must be initialized once before creating any clients, publishers, or subscribers. It accepts a DDS domain ID and an optional network interface name. ```APIDOC ## ChannelFactory::Init — Initialize the DDS transport `ChannelFactory` is a singleton that must be initialized once before any channel, publisher, subscriber, or `B1LocoClient` is created. It accepts a DDS domain ID and an optional network interface name. ### C++ Example ```cpp // C++ — initialize on domain 0 bound to a specific network interface #include int main(int argc, char* argv[]) { // argv[1] is the network interface, e.g. "eth0" or "127.0.0.1" booster::robot::ChannelFactory::Instance()->Init(0, argv[1]); // ... create clients, publishers, subscribers } ``` ### Python Example ```python # Python — initialize without a specific interface (uses default) from booster_robotics_sdk_python import ChannelFactory ChannelFactory.Instance().Init(0) # local communication ChannelFactory.Instance().Init(0, "eth0") # remote robot over network ``` ``` -------------------------------- ### Trigger Pre-programmed Dances with B1LocoClient Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Use `Dance` for upper-body and `WholeBodyDance` for full-body pre-programmed sequences. The `kStop` ID can halt any ongoing dance. ```cpp #include // Upper-body dances (arms only) client.Dance(booster::robot::b1::DanceId::kNewYear); client.Dance(booster::robot::b1::DanceId::kNezha); client.Dance(booster::robot::b1::DanceId::kTowardsFuture); client.Dance(booster::robot::b1::DanceId::kDabbingGesture); client.Dance(booster::robot::b1::DanceId::kRespectGesture); client.Dance(booster::robot::b1::DanceId::kStop); // stop current dance // Whole-body dances client.WholeBodyDance(booster::robot::b1::WholeBodyDanceId::kMichaelDance1); int32_t ret = client.WholeBodyDance( booster::robot::b1::WholeBodyDanceId::kBoxingStyleKick); if (ret != 0) { std::cerr << "Dance failed: " << ret; } ``` -------------------------------- ### Velocity-Based Locomotion with B1LocoClient::Move Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Command the robot to move using linear and angular velocities. The robot must be in 'kWalking' mode. Sending (0, 0, 0) stops the robot. Use MoveCommand for fire-and-forget control. ```cpp // C++ — keyboard-driven movement loop (vx m/s, vy m/s, vyaw rad/s) #include #include // Walk forward at 0.2 m/s client.Move(0.2f, 0.0f, 0.0f); // Strafe left at 0.2 m/s client.Move(0.0f, 0.2f, 0.0f); // Rotate counter-clockwise at 1.0 rad/s client.Move(0.0f, 0.0f, 1.0f); // Stop int32_t ret = client.Move(0.0f, 0.0f, 0.0f); if (ret != 0) { std::cerr << "Move failed: " << ret << std::endl; } // Fire-and-forget (no blocking wait for ack) — useful for tight control loops client.MoveCommand(0.5f, 0.0f, 0.0f); ``` ```python # Python — walk forward, strafe, rotate, stop ret = client.Move(0.2, 0.0, 0.0) # forward 0.2 m/s ret = client.Move(0.0, 0.2, 0.0) # strafe left ret = client.Move(0.0, 0.0, 1.0) # turn CCW at 1 rad/s ret = client.Move(0.0, 0.0, 0.0) # stop if ret != 0: print(f"Move failed: {ret}") ``` -------------------------------- ### C++: Subscribe to Low-Level State Feedback Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Subscribe to low-level state messages containing IMU and per-joint motor data. Ensure ChannelFactory is initialized before creating the subscriber. ```cpp #include #include #include void OnLowState(const void *msg) { const auto *s = static_cast(msg); auto &imu = s->imu_state(); std::cout << "IMU rpy: " << imu.rpy()[0] << ", " << imu.rpy()[1] << ", " << imu.rpy()[2] << " | gyro: " << imu.gyro()[0] << ", " << imu.gyro()[1] << ", " << imu.gyro()[2] << std::endl; for (int i = 0; i < (int)s->motor_state_parallel().size(); ++i) { const auto &m = s->motor_state_parallel()[i]; std::cout << " joint[" << i << "] q=" << m.q() << " dq=" << m.dq() << " tau=" << m.tau_est() << std::endl; } } int main() { booster::robot::ChannelFactory::Instance()->Init(0); booster::robot::ChannelSubscriber sub("rt/low_state", OnLowState); sub.InitChannel(); while (true) { std::this_thread::sleep_for(std::chrono::seconds(1)); } } ``` -------------------------------- ### Initialize ChannelFactory in Python Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Initializes the DDS transport layer in Python. Must be called once before creating any clients or publishers. Can specify a network interface or use the default. ```python from booster_robotics_sdk_python import ChannelFactory ChannelFactory.Instance().Init(0) # local communication ChannelFactory.Instance().Init(0, "eth0") # remote robot over network ``` -------------------------------- ### B1LocoClient::SwitchGait Source: https://context7.com/boosterrobotics/booster_robotics_sdk/llms.txt Switches between available locomotion gait controllers: whole-body humanlike, half-body humanlike (v1 or v2). ```APIDOC ## B1LocoClient::SwitchGait — Gait type selection ### Description Switches between available locomotion gait controllers: whole-body humanlike, half-body humanlike (v1 or v2). ### Method - `SwitchGait(GaitType gait_type)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp // C++ — switch gait client.SwitchGait(booster::robot::b1::GaitType::kWholeBodyHumanlikeGait); client.SwitchGait(booster::robot::b1::GaitType::kHalfBodyHumanlikeGait); int32_t ret = client.SwitchGait(booster::robot::b1::GaitType::kHalfBodyHumanlikeGaitV2); if (ret != 0) { std::cerr << "SwitchGait failed: " << ret; } ``` ### Response #### Success Response (0) Indicates the gait was successfully switched. #### Response Example `0` for success, non-zero for failure. ERROR HANDLING: - Returns a non-zero integer on failure. ```