四足机器人教师网络如何设计:从 Privileged Policy 到可蒸馏的鲁棒运动能力

对四足机器人来说,好的教师网络不是“越大越强”就好,而是要服务于最终学生策略的可迁移性。教师应在仿真中利用特权信息学会稳定、鲁棒、可解释的运动能力;学生再从有限真实可观测信息中蒸馏出可落地策略。


一、先明确 teacher 的角色

四足机器人里的 teacher 常见有三种:

1. Privileged teacher

输入包含真实机器人部署时拿不到、或者很难直接拿到的信息,例如:

  • 地形高度图;
  • 足端接触状态;
  • 摩擦系数;
  • 外力扰动;
  • 精确机体速度;
  • 质量、惯量、电机能力等动力学参数。

这种 teacher 的目标是:先在仿真中学出强策略,再把能力蒸馏给 student。

2. MoCap / trajectory teacher

teacher 学习或提供动物运动、人工设计轨迹、轨迹优化结果等参考动作。

它适合:

  • agile locomotion;
  • 跳跃;
  • 快速转身;
  • 跑步;
  • 风格化 gait。

3. Planner / MPC teacher

teacher 不一定是神经网络,也可以是:

  • MPC;
  • WBC;
  • 轨迹优化器;
  • 启发式 gait planner。

学生策略学习它输出的动作、目标关节角、足端轨迹或隐变量。

如果任务是四足强化学习导航或鲁棒运动控制,我更推荐:

privileged teacher + student distillation + teacher latent adaptation


二、Teacher 输入:可以多,但不能作弊过度

teacher 可以使用比 student 更丰富的信息,但一个关键原则是:

teacher 可以看得更多,但这些信息最好能被 student 通过历史观测、视觉、IMU、足端反馈间接推断。

比较合理的 teacher observation 包括:

本体状态

  • base linear velocity;
  • base angular velocity;
  • gravity vector in body frame;
  • joint position;
  • joint velocity;
  • previous action;
  • command velocity。

地形信息

  • local height scan;
  • local height map;
  • foot terrain height;
  • terrain normal。

动力学特权信息

  • body mass variation;
  • motor strength;
  • friction coefficient;
  • action latency;
  • external push。

接触信息

  • foot contact state;
  • foot slip velocity;
  • contact force。

但需要避免 teacher 直接拿到过强的信息,例如:

  • 未来完整地形答案;
  • 精确全局路径,而 student 只有局部感知;
  • 仿真内部 reward 相关变量;
  • 真实部署时无法估计、也无法通过历史观测推断的隐变量。

如果 teacher 依赖了学生永远无法推断的信息,teacher 可能很强,但 student 蒸馏会很差。


三、网络结构:稳定优先,不要过度复杂

四足低层控制通常需要高频、稳定、低延迟。因此 teacher 网络不一定要很大,反而应该优先保证训练稳定和可迁移性。

一个实用结构是:

proprioception encoder
+
privileged encoder / terrain encoder

latent z

policy MLP

action

具体可以这样设计:

  • proprioception encoder:MLP;
  • terrain height map encoder:MLP / 1D CNN / small CNN;
  • privileged dynamics encoder:MLP;
  • policy head:MLP;
  • output:关节目标、PD target offset 或 residual action。

常见规模:

  • encoder:2-3 层,hidden size 128/256;
  • policy:3 层,hidden size 256;
  • activation:ELU / ReLU;
  • action:12 维关节目标,或者 12 维 residual joint target。

不建议一开始就使用很大的 Transformer。对四足低层 locomotion 来说,MLP/CNN 往往更稳、更容易 sim-to-real。


四、Reward 设计比网络结构更重要

一个好的 teacher,核心通常不是网络结构,而是 reward 和训练分布。

推荐把 reward 分成几类。

1. 任务奖励

  • tracking linear velocity;
  • tracking angular velocity;
  • heading tracking;
  • navigation progress;
  • goal progress。

2. 稳定性奖励

  • base height;
  • roll/pitch penalty;
  • orientation stability;
  • no fall bonus。

3. 运动质量奖励

  • energy penalty;
  • torque penalty;
  • action rate penalty;
  • joint acceleration penalty;
  • foot slip penalty;
  • foot clearance;
  • gait regularity。

4. 安全约束

  • collision penalty;
  • joint limit penalty;
  • excessive contact force penalty;
  • body-ground contact penalty。

一个重要判断是:

teacher 不应该只追速度,而应该学会稳定、节能、少打滑、可蒸馏的动作。

如果 teacher 动作过于激进,student 学起来会困难,真机部署也更危险。


五、让 teacher 输出可学生化的中间表征

如果 teacher 只是输出 action,student 往往很难学。

更好的方式是让 teacher 产生一个 latent:

z_privileged = encoder(privileged info)
action = policy(proprioception, z_privileged)

然后 student 学习:

z_student = history_encoder(proprioception history / vision)
action = policy(proprioception, z_student)

这样 student 不是直接硬模仿动作,而是在学习估计 teacher 的隐变量。

这种结构很适合四足机器人:

  • teacher 用真实 friction、mass、terrain 信息;
  • student 用过去几十帧 proprioception 推断这些隐变量;
  • 最终部署时,student 可以根据机体反馈适应不同地面和动力学变化。

六、推荐训练流程

一个比较稳的训练流程是:

1. 训练 privileged teacher

使用 PPO / SAC / AMP 等算法,在仿真中使用 privileged observation 训练 teacher。

同时加入大量 domain randomization:

  • friction;
  • mass;
  • motor strength;
  • latency;
  • terrain;
  • sensor noise;
  • external push。

2. 冻结 teacher 的 policy backbone

保留 teacher 中 latent-conditioned policy 的主体结构。

3. 训练 student encoder

student 输入:

  • history proprioception;
  • IMU;
  • joint history;
  • depth / height scan,可选。

训练目标可以是:

  • 预测 teacher latent;
  • 模仿 teacher action;
  • 同时做 latent loss + action distillation loss。

4. student RL fine-tuning

让 student 在没有 privileged info 的情况下继续 PPO fine-tuning。

这个阶段 reward 可以和 teacher 类似,但应更强调:

  • 安全;
  • 动作平滑;
  • 扰动恢复;
  • 真实部署可接受的运动幅度。

5. sim-to-real 检查

部署前重点检查:

  • latency randomization;
  • friction randomization;
  • motor strength randomization;
  • IMU noise;
  • joint encoder noise;
  • action delay;
  • action clipping;
  • torque limit。

七、用于导航时,teacher 需要分层

如果目标是导航,不建议让一个 teacher 同时负责全局导航和底层运动。

更可靠的系统结构是:

global planner / local planner

velocity command / foothold command

locomotion teacher

student locomotion policy

PD controller / torque control

teacher 主要负责:

  • 接受速度命令;
  • 在复杂地形上稳定跟踪;
  • 处理扰动;
  • 保持身体稳定;
  • 必要时调整 gait。

导航高层单独处理:

  • obstacle avoidance;
  • waypoint following;
  • terrain cost;
  • exploration;
  • global path planning。

这样的分层系统更容易调试,也更容易做安全约束。


八、如何判断一个 teacher 是否足够好

我会用这些指标判断 teacher 的质量:

  • 同样 command 下动作稳定,不抖;
  • 不依赖单一 gait,能随速度自然切换;
  • 受到 push 后可以恢复;
  • 地形变化时 foot slip 少;
  • torque 和 action rate 不爆;
  • rollout 长时间不发散;
  • student 蒸馏后性能下降不大;
  • 在 domain randomization 下仍稳定;
  • 真机部署前动作看起来保守但有力。

如果 teacher 在仿真里很强,但动作高频抖动、力矩很大、依赖精确地形答案,那么它不是一个好的 teacher,而只是一个过拟合的仿真策略。


九、总结建议

如果现在要设计四足机器人的教师网络,我会选择:

PPO 训练 privileged teacher;
teacher 输入 proprioception + terrain height scan + dynamics randomization parameters + contact info;
网络使用 MLP/CNN encoder + latent-conditioned policy;
student 用历史 proprioception / 视觉去预测 teacher latent;
teacher 不直接做全局导航,而是做鲁棒 locomotion skill。

最关键的一句话是:

teacher 要强,但不能强到学生无法模仿;要聪明,但动作必须保守、平滑、可迁移。

algorithms axis-angle bang-bang bode calibration chrome cmake cmakelists cnn colcon conan control cpp cpu d435i data_struct db design-pattern dots economics eigen factory-pattern fcpx figure finance forge fov gazebo gdb git gnu ibus interest isaac gym isaac lab isaaclab kdl latex launch learning-notes legged locomotion legged robotics legged-robot life linux linux-kernel mac math matlab matrix memory mlp money motion-control motor moveit mpc mujoco network ocs2 ode operator optimal algorithm optimal-control perf performance personal-finance ppo privileged learning profiling python qos quadrotor realsense reinforcement learning reward tuning rnn robot robotics ros ros2 rtb security shell sim-to-real simulation socket stairs stl tcp-ip teacher policy thread tools twist ubuntu uml unitree urdf vae valgrind vcxsrv velocity vim web wifi work wsl 中文输入 交叉编译 依赖管理 分支管理 四足机器人 实验诊断 强化学习 机器人控制 机器人视觉 构建系统 深度学习 深度相机 点云 版本控制 神经网络 训练曲线 输入法 配置类 飞控
知识共享许可协议