软件设置

SDK安装、ROS2全身控制接口、关节状态读取和命令、运动API基础知识、MuJoCo人形模拟以及前3个故障排除问题。

跳转到一个部分:

第 1 步 — SDK 安装

加速器 SDK 安装

Booster SDK 分发为 booster_robotics_sdk_python 在 PyPI 上。 它提供与 K1 网络控制接口的 Python 绑定。

创建虚拟环境(推荐)

python3 -m venv ~/.venvs/booster-k1
source ~/.venvs/booster-k1/bin/activate

安装SDK

pip install booster_robotics_sdk_python

验证安装

python3 -c "import booster_robotics_sdk; print('SDK ready')"

网络配置

K1 通过有线以太网进行通信。 连接前配置主机的网络接口:

# Set your PC's Ethernet interface to 192.168.10.10
sudo ip addr add 192.168.10.10/24 dev eth0
sudo ip link set eth0 up

# Verify connectivity to the K1
ping 192.168.10.102
第 2 步 — ROS2 集成

ROS2全身控制接口

K1 附带一个 ROS2 桥接节点,该节点将所有接头作为标准暴露 ros2_control 硬件接口。 这使得能够与 MoveIt2、轨迹规划器和自定义控制器集成。

安装 ROS2 Humble

sudo apt update && sudo apt install software-properties-common curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | \
  sudo apt-key add -
sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu jammy main" \
  > /etc/apt/sources.list.d/ros2.list'
sudo apt update
sudo apt install ros-humble-desktop ros-humble-ros2-control \
  ros-humble-ros2-controllers ros-humble-joint-state-publisher-gui -y

克隆并构建 K1 ROS2 包

mkdir -p ~/k1_ws/src && cd ~/k1_ws/src
git clone https://github.com/BoosterRobotics/booster_ros2.git
cd ~/k1_ws
source /opt/ros/humble/setup.bash
colcon build --symlink-install

启动K1大桥

source ~/k1_ws/install/setup.bash
ros2 launch booster_ros2 k1_bringup.launch.py \
  robot_ip:=192.168.10.102

检查联合状态

# List all available topics
ros2 topic list

# Stream joint states (22 joints at 500 Hz)
ros2 topic echo /joint_states
步骤 3 — 联合状态 API

读取和指挥联合状态

Python SDK 提供对所有 22 个关节的直接访问。 在命令运动之前,始终以 DAMP 模式启动。

连接并读取关节状态

from booster_robotics_sdk import BoosterRobot, RobotMode

# Connect to the robot
robot = BoosterRobot(ip="192.168.10.102")
robot.connect()

# Enter DAMP mode (safe, low impedance)
robot.set_mode(RobotMode.DAMP)

# Read full joint state
state = robot.get_state()
print(f"Mode: {state.mode}")
print(f"Joint positions (rad): {state.joint_positions}")
print(f"Joint velocities (rad/s): {state.joint_velocities}")
print(f"Joint torques (Nm): {state.joint_torques}")
print(f"IMU euler (deg): {state.imu_euler}")

robot.disconnect()

命令臂关节位置(自定义模式)

自定义模式允许直接对手臂进行关节级控制。 需要起重夹具——机器人不得支撑其自身重量。 请参阅 安全页面.

from booster_robotics_sdk import BoosterRobot, RobotMode, ArmCommand
import numpy as np

robot = BoosterRobot(ip="192.168.10.102")
robot.connect()

# Transition: DAMP -> PREP -> CUSTOM
robot.set_mode(RobotMode.DAMP)
robot.set_mode(RobotMode.PREP)
import time; time.sleep(3)  # Wait for PREP stabilization
robot.set_mode(RobotMode.CUSTOM)

# Command right arm to a target configuration (7 DOF)
# Joints: shoulder_pitch, shoulder_roll, shoulder_yaw,
#         elbow_pitch, wrist_pitch, wrist_roll, wrist_yaw
target = [0.0, -0.3, 0.0, 0.8, 0.0, 0.0, 0.0]
cmd = ArmCommand(side="right", joint_positions=target, kp=60, kd=2)
robot.send_arm_command(cmd)

robot.disconnect()

头部姿势控制

from booster_robotics_sdk import BoosterRobot, HeadCommand

robot = BoosterRobot(ip="192.168.10.102")
robot.connect()
robot.set_mode(RobotMode.PREP)

# Head: yaw in [-90, 90] deg, pitch in [-40, 30] deg
cmd = HeadCommand(yaw_deg=15.0, pitch_deg=-10.0)
robot.send_head_command(cmd)

robot.disconnect()
第 4 步 — 运动 API

Locomotion API 基础知识

K1 的运动控制器可自主管理平衡和步态。 您指挥速度目标; 板载控制器负责稳定性。 始终有一名观察员在场。

模式转换顺序

from booster_robotics_sdk import BoosterRobot, RobotMode, LocomotionCommand
import time

robot = BoosterRobot(ip="192.168.10.102")
robot.connect()

# Step 1: Enter DAMP (zero torque, safe to handle)
robot.set_mode(RobotMode.DAMP)
time.sleep(1)

# Step 2: Enter PREP (stand up to PREP posture)
robot.set_mode(RobotMode.PREP)
time.sleep(5)  # Wait for full PREP stabilization — do not skip

# Step 3: Enter WALK
robot.set_mode(RobotMode.WALK)
time.sleep(2)

命令运动(速度模式)

# Walk forward at 0.3 m/s
cmd = LocomotionCommand(
    vx=0.3,    # forward/back (m/s), range: [-0.5, 0.5]
    vy=0.0,    # lateral (m/s),      range: [-0.3, 0.3]
    vyaw=0.0   # rotation (rad/s),   range: [-1.0, 1.0]
)
robot.send_locomotion_command(cmd)
time.sleep(2)

# Stop
robot.send_locomotion_command(LocomotionCommand(vx=0, vy=0, vyaw=0))
time.sleep(1)

# Return to PREP then DAMP
robot.set_mode(RobotMode.PREP)
time.sleep(3)
robot.set_mode(RobotMode.DAMP)
robot.disconnect()

软件紧急停止

# Call from any thread — immediately enters DAMP mode
robot.emergency_stop()

在紧急情况下总是更喜欢使用硬件急停按钮。 e-stop 软件仅作为备份。

可选 — 模拟

MuJoCo 人形模拟

K1 URDF 模型包含在 SDK 中。 在硬件部署之前使用 MuJoCo 开发和测试运动和操作策略。

安装MuJoCo

pip install mujoco

克隆K1健身房环境

git clone https://github.com/BoosterRobotics/booster_gym.git
cd booster_gym
pip install -e .

运行步行模拟

python examples/walk_sim.py --render

艾萨克·西姆(高级)

NVIDIA Isaac Sim 为大规模策略训练提供 GPU 加速的并行模拟。 K1 URDF 干净地导入到 Isaac Sim 4.x 中。 需要 NVIDIA GPU(推荐 16 GB VRAM)和 Isaac Sim 许可证。 请参阅 人形比较文章 用于模拟基准。

模拟与真实的对齐 — K1 MuJoCo 模型包括与真实硬件匹配的校准惯性参数和关节限制。 经过模拟训练的策略可以通过最小的增益调整来部署。

故障排除

Humanoid 设置的 3 大问题

错误1 无法连接到 K1: Connection refused / ping timeout

最常见的问题。 几乎总是主机 PC 端的网络配置错误。

使固定:

# 1. Verify your PC's interface is on the correct subnet
ip addr show eth0
# Should show 192.168.10.10/24

# 2. Set it if not configured
sudo ip addr flush dev eth0
sudo ip addr add 192.168.10.10/24 dev eth0
sudo ip link set eth0 up

# 3. Ping the robot
ping -c 4 192.168.10.102

# 4. If ping fails, verify the K1 is fully booted
# The K1 takes ~60 seconds to boot. Look for the LED sequence
# to complete before attempting connection.
错误2 机器人在 PREP 到 WALK 过渡期间跌倒

K1 需要至少 3 秒的 PREP 时间来让平衡控制器初始化。 转换太快是首次设置时跌倒的最常见原因。

使固定:

# Always wait at least 5 seconds in PREP before WALK
robot.set_mode(RobotMode.PREP)
time.sleep(5)  # Do not reduce this

# Verify PREP is fully active before proceeding
state = robot.get_state()
assert state.mode == RobotMode.PREP, "PREP not confirmed"

# Have your spotter positioned with the e-stop
robot.set_mode(RobotMode.WALK)
错误3 ROS2桥接失败: hardware interface not found

ROS2桥找不到K1的硬件接口。 通常是由于启动文件中缺少软件包或机器人 IP 不正确造成的。

使固定:

# 1. Install missing ros2_control packages
sudo apt install ros-humble-ros2-control \
  ros-humble-ros2-controllers -y

# 2. Rebuild the workspace
cd ~/k1_ws && colcon build --symlink-install

# 3. Source both ROS2 and your workspace
source /opt/ros/humble/setup.bash
source ~/k1_ws/install/setup.bash

# 4. Verify robot_ip matches actual K1 IP
ros2 launch booster_ros2 k1_bringup.launch.py \
  robot_ip:=192.168.10.102

# 5. Check the K1 is connected and responding
ping 192.168.10.102

还卡住了吗? 发表在 SVRC论坛 包含您的 Ubuntu 版本、确切的错误消息和 SDK 版本(pip show booster_robotics_sdk_python).

软件工作正常吗? 开始收集数据。

一旦K1移动,下一步就是全身遥控和演示录制。