# Legged Gym

**Legged Gym** 是一个面向腿式机器人运动控制的开源强化学习框架，由[苏黎世联邦理工学院](https://www.edgepedia.org/zh/eth-zurich)（ETH Zurich）机器人系统实验室基于英伟达的 Isaac Gym 物理仿真器构建。它通过在单块 GPU 上并行运行数千个仿真机器人，为四足和人形机器人训练运动策略，将策略训练时间从数天缩短到数分钟，并包含将训练好的策略迁移到实体机器人所需的各项组件。<sup>[1](https://github.com/leggedrobotics/legged_gym)</sup>

| 关键事实 | 详情 |
|---|---|
| 作者 | Nikita Rudin、David Hoeller、Philipp Reist、Marco Hutter，苏黎世联邦理工学院机器人系统实验室<sup>[2](https://proceedings.mlr.press/v164/rudin22a.html)</sup> |
| 发表 | 《利用大规模并行深度强化学习在数分钟内学会行走》，第 5 届机器人学习会议论文集，PMLR 164:91-100，2022 年<sup>[2](https://proceedings.mlr.press/v164/rudin22a.html)</sup> |
| 训练速度 | 在单块工作站 GPU 上，平坦地形策略训练不到 4 分钟，崎岖地形策略训练 20 分钟，相比此前工作加速多个数量级<sup>[2](https://proceedings.mlr.press/v164/rudin22a.html)</sup> |
| 仿真后端 | 英伟达 Isaac Gym，将物理仿真和神经网络训练都保持在 GPU 上，比 CPU 仿真器的强化学习流水线快 2 到 3 个数量级<sup>[3](https://arxiv.org/abs/2108.10470)</sup> |
| 仿真到现实工具包 | 执行器网络、摩擦与质量随机化、带噪观测，以及训练期间的随机推搡<sup>[1](https://github.com/leggedrobotics/legged_gym)</sup> |
| 学习算法 | 近端策略优化（Proximal Policy Optimization），由配套的 rsl_rl 库提供<sup>[1](https://github.com/leggedrobotics/legged_gym)</sup> |
| 状态 | 环境已于 2024 年 1 月迁移至 Isaac Lab；原仓库此后仅接收有限更新<sup>[1](https://github.com/leggedrobotics/legged_gym)</sup> |

## 大规模并行训练

该框架基于这样一个洞见：只要在单块 GPU 上以大规模并行方式运行仿真，为腿式运动训练深度强化学习策略就不需要在服务器集群上耗费数天算力。Legged Gym 封装了 Isaac Gym，后者将物理仿真和神经网络训练都放在 GPU 上运行，并把数据从物理缓冲区直接传入 PyTorch 张量，避免 CPU 瓶颈。<sup>[3](https://arxiv.org/abs/2108.10470)</sup>在 2022 年的论文中，作者使用数千个并行仿真机器人，训练四足机器人 ANYmal 在具有挑战性的地形上行走。平坦地形策略训练不到四分钟，崎岖地形策略训练二十分钟，作者称这相比此前工作加速了多个数量级，并将策略迁移到实体机器人上验证了该方法。<sup>[2](https://proceedings.mlr.press/v164/rudin22a.html)</sup>

**地形课程。** 论文还引入了一种受游戏启发的课程机制，适合同时用数千个仿真机器人进行训练：每个机器人所面对地形的难度会随着其策略的提升而增加。<sup>[2](https://proceedings.mlr.press/v164/rudin22a.html)</sup>

## 仿真到现实迁移

仅在仿真中训练的策略必须经受真实硬件的考验，仓库打包了实验室为此使用的各项技术。其中包括执行器网络——一个从真实世界数据训练得到的执行器响应学习模型，使仿真器能够复现延迟、滞回和饱和等硬件行为；摩擦与质量随机化；带噪观测；以及训练期间对机器人施加的随机推搡。<sup>[1](https://github.com/leggedrobotics/legged_gym)</sup><sup> • </sup><sup>[4](https://rsl.ethz.ch/research/researchtopics/legged-locomotion.html)</sup>

这一做法契合该实验室更广泛的仿真到现实方法：仅在仿真中训练的策略被迁移到实体机器人后，仍能在训练中从未遇到过的条件下保持鲁棒性，例如可变形地形、碎石和植被。<sup>[5](https://rsl.ethz.ch/research/researchtopics/rl-robotics.html)</sup>

## 代码结构与使用

每个环境由一个环境文件（`legged_robot.py`）和一个配置文件（`legged_robot_config.py`）定义，后者包含一个环境参数类和一个 PPO 训练参数类。两个类都使用继承，因此添加新机器人或新任务的方式是：继承现有配置、添加机器人资产，并向任务注册表注册任务。配置中每个非零的奖励权重都会向总奖励和中加入一个同名奖励函数，将权重设为零则会移除该奖励项。<sup>[1](https://github.com/leggedrobotics/legged_gym)</sup>

基础的 `legged_robot` 环境实现了一个崎岖地形运动任务。训练和回放通过 `train.py` 和 `play.py` 脚本运行，并附带诸如 `anymal_c_flat` 的任务参数，并行环境数量、随机种子和最大迭代次数可在命令行中覆盖。<sup>[1](https://github.com/leggedrobotics/legged_gym)</sup>

## 衍生框架

Legged Gym 成为其他机器人学习框架的常见起点。[宇树科技](https://www.edgepedia.org/zh/unitree-robotics)（Unitree Robotics）的 unitree_rl_gym 基于 legged_gym 和 rsl_rl 构建，支持 Go2 四足机器人以及 H1、H1_2 和 G1 人形机器人，其工作流是在 Isaac Gym 中运行训练，在 MuJoCo 中验证策略作为仿真到仿真检查，然后部署到实体机器人。<sup>[6](https://embodiedterms.com/en/t/unitree-rl-gym/)</sup>Humanoid-Gym 是一个训练人形机器人运动并实现零样本仿真到现实迁移的框架，同样基于 Isaac Gym，并在 XBot-S 和 XBot-L 人形机器人上得到验证。<sup>[7](https://arxiv.org/abs/2404.05695)</sup>轮腿式及其他变体遵循同样的模式，苏黎世联邦理工学院关于风险感知运动和地形参数学习的研究项目也使用了 legged gym 框架和 ANYmal 机器人。<sup>[8](https://www.research-collection.ethz.ch/server/api/core/bitstreams/c24e257f-8698-4030-8dec-114a72b3ac3e/content)</sup>

## 迁移至 Isaac Lab

2024 年 1 月 9 日，维护者宣布，随着英伟达从 Isaac Gym 转向 Isaac Sim，本工作的所有环境均已迁移至 Isaac Lab，原仓库此后仅接收有限的更新和支持。鼓励用户迁移到新框架，运动任务记录在 Isaac Lab 的环境概览中。<sup>[1](https://github.com/leggedrobotics/legged_gym)</sup>

## 腿式运动研究中的背景

Legged Gym 出自苏黎世联邦理工学院机器人系统实验室由 [Marco Hutter](https://www.edgepedia.org/zh/marco-hutter) 领导的研究计划，该计划将强化学习用于腿式机器人的运动控制和感知。同一实验室在感知运动方面的工作将视觉感知与本体感觉相结合，使 ANYmal 能够穿越艰难的自然地形，包括一次历时 31 分钟、攀登 1,098 米高的埃策尔山（Mount Etzel）且无摔倒的徒步，后续项目还教会了机器人跑酷技能和打羽毛球。<sup>[5](https://rsl.ethz.ch/research/researchtopics/rl-robotics.html)</sup><sup> • </sup><sup>[9](https://ethz.ch/en/news-and-events/eth-news/news/2022/01/how-robots-learn-to-hike.html)</sup><sup> • </sup><sup>[10](https://ethz.ch/en/news-and-events/eth-news/news/2024/03/anymal-can-do-parkour-and-walk-across-rubble.html)</sup>Legged Gym 充当了这一研究方向中大部分工作的训练环境，其开源发布旨在更广泛地加速学习型腿式运动的研究。<sup>[2](https://proceedings.mlr.press/v164/rudin22a.html)</sup>

## References

1. [leggedrobotics/legged_gym, GitHub repository and README](https://github.com/leggedrobotics/legged_gym)
2. [Rudin, N., Hoeller, D., Reist, P., Hutter, M. (2022). Learning to Walk in Minutes Using Massively Parallel Deep Reinforcement Learning. PMLR 164:91-100](https://proceedings.mlr.press/v164/rudin22a.html)
3. [Makoviychuk, V. et al. (2021). Isaac Gym: High Performance GPU-Based Physics Simulation For Robot Learning. arXiv:2108.10470](https://arxiv.org/abs/2108.10470)
4. [Legged Locomotion, Robotic Systems Lab, ETH Zurich](https://rsl.ethz.ch/research/researchtopics/legged-locomotion.html)
5. [Reinforcement Learning for Robotics, Robotic Systems Lab, ETH Zurich](https://rsl.ethz.ch/research/researchtopics/rl-robotics.html)
6. [What is unitree_rl_gym? Embodied AI Glossary](https://embodiedterms.com/en/t/unitree-rl-gym/)
7. [Gu, X., Wang, Y.-J., Chen, J. (2024). Humanoid-Gym: Reinforcement Learning for Humanoid Robot with Zero-Shot Sim2Real Transfer. arXiv:2404.05695](https://arxiv.org/abs/2404.05695)
8. [ETH Research Collection: experiments using the ANYmal robot and the legged gym RL framework](https://www.research-collection.ethz.ch/server/api/core/bitstreams/c24e257f-8698-4030-8dec-114a72b3ac3e/content)
9. [How robots learn to hike, ETH Zurich News, 19 January 2022](https://ethz.ch/en/news-and-events/eth-news/news/2022/01/how-robots-learn-to-hike.html)
10. [ANYmal can do parkour and walk across rubble, ETH Zurich News, 13 March 2024](https://ethz.ch/en/news-and-events/eth-news/news/2024/03/anymal-can-do-parkour-and-walk-across-rubble.html)

---
*Initially written Oct 15, 2026 · Edited: Oct 25, 2026*

Topic: 技术与人造世界 › 工程与制造 › 机器人技术与自动化 › Humanoid robots › Learning-based locomotion and skills

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/legged-gym

English original: https://www.edgepedia.org/legged-gym
