C++ Controller Wrappers
The SDK provides two high-level C++ controllers:
include/booster/robot/b1/move_controller.hppinclude/booster/robot/b1/arm_controller.hpp
These wrappers initialize DDS, create a motion client, and subscribe or publish topics during construction. Call Close() explicitly when finished; the destructor also performs cleanup.
MoveController
MoveController implements relative movement, absolute movement, and turning using B1LocoClient::MoveCommand and rt/odometer_state.
Construction performs the following operations:
- Calls
ChannelFactory::Init(0, network_ip). - Initializes
B1LocoClient. - Subscribes to
rt/odometer_state. - Waits for odometry data.
- Calls
ResetOdometry.
#include <booster/robot/b1/move_controller.hpp>
booster::robot::b1::MoveController ctrl("<network_ip>");
ctrl.MoveToRelative(1.0F, 0.0F, 0.3F);
ctrl.TurnAround(1.57F, 0.5F);
ctrl.Close();
Public methods:
Method | Description |
|---|---|
| Move to absolute |
| Move by a relative displacement from the current position. |
| Turn in place by the specified angle in radians. |
| Send |
| Stop movement and close the subscriber. |
ArmController
ArmController controls upper-body joints 2 through 9 over rt/joint_ctrl and tracks current joint angles from rt/low_state.
Construction performs the following operations:
- Calls
ChannelFactory::Init(0, network_ip). - Initializes
B1LocoClient. - Creates a
ChannelPublisher<LowCmd>. - Subscribes to
rt/low_state. - Calls
UpperBodyCustomControl(true).
On shutdown, it attempts UpperBodyCustomControl(false) before closing the subscriber and publisher.
#include <booster/robot/b1/arm_controller.hpp>
booster::robot::b1::ArmController arm("<network_ip>");
arm.ControlArm(
booster::robot::b1::ArmJoint::kLeftPitch, -0.3F, 1000.0F)
.ControlArm(
booster::robot::b1::ArmJoint::kRightPitch, -0.3F, 1000.0F)
.Finish();
arm.Close();
Joint mapping:
C++ | Global joint index |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Every ArmJoint member is a business alias for the shared K1/T1 upper-body layout:
Enum member | Value | Meaning |
|---|---|---|
| 2 | Left shoulder pitch joint. |
| 3 | Left shoulder roll joint. |
| 4 | Left arm joint 4, at the left-elbow-pitch slot of the shared layout. |
| 5 | Left arm joint 5, at the left-elbow-yaw slot of the shared layout. |
| 6 | Right shoulder pitch joint. |
| 7 | Right shoulder roll joint. |
| 8 | Right arm joint 8, at the right-elbow-pitch slot of the shared layout. |
| 9 | Right arm joint 9, at the right-elbow-yaw slot of the shared layout. |
This enum applies only to the K1/T1 joint range 2..9 and is not compatible with T1_7DofArm’s 7-DoF arms; use JointIndexWith7DofArm for T1_7DofArm. Both ControlArm(ArmJoint, target_rad, duration_ms) and ControlArm(int, target_rad, duration_ms) only queue targets; Finish() performs the interpolation at approximately 100 Hz. Durations below 50 ms are raised to 50 ms, and raw indices outside 2..9 are ignored.
Operational Notes
MoveControllerrequires odometry. Its constructor throwsstd::runtime_errorif no data arrives within five seconds.ArmControllerplans only upper-body joints. Other joints are written with zero stiffness and damping inLowCmd, allowing the internal controller to continue balancing the robot.ArmController::Finish()blocks until the longest queued motion ends. It returnstruefor an empty queue or when every publish succeeds, andfalseafter any publish failure.Close()is idempotent and discards unexecuted targets.- Both controllers send commands to the physical robot. Use them only in an appropriate robot mode and a safe environment.