Files
go1_pro_sdk/examples
2026-06-20 20:02:36 +08:00
..
2026-06-20 20:02:36 +08:00
2026-06-20 20:02:36 +08:00
2026-06-20 20:02:36 +08:00
2026-06-20 20:02:36 +08:00
2026-06-20 20:02:36 +08:00
2026-06-20 20:02:36 +08:00

Examples

每个示例都假定:

  • 你已经从狗上提取了 blowfish_state.bin (或用包内置的)
  • 已经停掉 Pi 上的 keep_sport_alive + Legged_sport + appTransit
  • 狗悬空 (脚架/吊带), 除非明确说不需要

只读类 (无风险)

monitor_state.py — 实时监听状态

python examples/monitor_state.py --duration 30 --verbose

不触发任何电机, 持续发 damping LowCmd 维持 MCU 回包流, 解码后打印 12 关节角 + IMU + 电量.

monitor_remote.py — 实时监听遥控器

python examples/monitor_remote.py --duration 60

按下按键/拨动摇杆都会实时输出. 包括 L2 模拟值.

控制类 (需要狗悬空!)

example_sin_leg.py — 单腿小幅 sin

python examples/example_sin_leg.py --amplitude 0.3 --freq 0.5 --duration 10

保守参数, 适合首次电机控制. sin 中点 = 当前关节角, 不强行移动到指定位置.

example_position.py — 复刻原版 example_position

python examples/example_position.py --max-steps 5000

跟 free-dog-sdk example_position(lowlevel).py 逻辑一模一样:

  • 0..10: 记录 qInit
  • 10..400: 插值到 sin_mid_q = [0, 1.2, -2.0]
  • 400+: 1Hz sin 摆动 (FR_1 ±0.6, FR_2 ±0.9)

Mac 上实测 480 Hz.

example_remote_control.py — 摇杆控制 FR 腿

python examples/example_remote_control.py
  • 左摇杆 X → 髋外摆
  • 左摇杆 Y → 大腿前后
  • L2 按下 → 退出

安全

所有控制类示例都内置 apply_safety(cmd, state, power_factor=1) (10% 力矩限制), 出问题会立即停机. 见 docs/SAFETY.md.