Skip to main content

C++ Controller Wrappers

The SDK provides two high-level C++ controllers:

  • include/booster/robot/b1/move_controller.hpp
  • include/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

MoveToTarget(x, y, vel)

Move to absolute x, y coordinates in the current odometry frame.

MoveToRelative(dx, dy, vel)

Move by a relative displacement from the current position.

TurnAround(angle, vel)

Turn in place by the specified angle in radians.

Stop()

Send MoveCommand(0, 0, 0).

Close()

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++ ArmJoint

Global joint index

kLeftPitch

2

kLeftRoll

3

kLeftYaw

4

kLeftElbow

5

kRightPitch

6

kRightRoll

7

kRightYaw

8

kRightElbow

9

Every ArmJoint member is a business alias for the shared K1/T1 upper-body layout:

Enum member

Value

Meaning

kLeftPitch

2

Left shoulder pitch joint.

kLeftRoll

3

Left shoulder roll joint.

kLeftYaw

4

Left arm joint 4, at the left-elbow-pitch slot of the shared layout.

kLeftElbow

5

Left arm joint 5, at the left-elbow-yaw slot of the shared layout.

kRightPitch

6

Right shoulder pitch joint.

kRightRoll

7

Right shoulder roll joint.

kRightYaw

8

Right arm joint 8, at the right-elbow-pitch slot of the shared layout.

kRightElbow

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​

  • MoveController requires odometry. Its constructor throws std::runtime_error if no data arrives within five seconds.
  • ArmController plans only upper-body joints. Other joints are written with zero stiffness and damping in LowCmd, allowing the internal controller to continue balancing the robot.
  • ArmController::Finish() blocks until the longest queued motion ends. It returns true for an empty queue or when every publish succeeds, and false after 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.