LeRobot 文件

在模擬環境中訓練強化學習

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

在模擬環境中訓練強化學習

本指南介紹如何使用 gym_hil 模擬環境,以便在使用 LeRobot 框架進行“人在環路”(HIL)強化學習時,替代真實的機器人。

gym_hil 是一個提供與 Gymnasium 相容的模擬環境的軟體包,專為“人在環路”強化學習設計。這些環境允許您:

  • 在模擬環境中訓練策略,以便在真實機器人上訓練前測試強化學習堆疊

  • 使用遊戲手柄或鍵盤等外部裝置在模擬環境中收集演示

  • 在策略學習過程中進行人工干預

目前,主要環境是基於 MuJoCo 的 Franka Panda 機器人模擬,任務包括拾取立方體等。

安裝

首先,在 LeRobot 環境中安裝 gym_hil 軟體包。

pip install -e ".[hilserl]"

我需要什麼?

  • 一個遊戲手柄或鍵盤來控制機器人
  • 一塊英偉達(Nvidia)GPU

配置

要將 gym_hil 與 LeRobot 一起使用,您需要建立一個配置檔案。這裡提供了一個示例。關鍵配置部分包括:

環境型別和任務

{
  "type": "hil",
  "name": "franka_sim",
  "task": "PandaPickCubeGamepad-v0",
  "device": "cuda"
}

可用任務:

  • PandaPickCubeBase-v0: 基礎環境
  • PandaPickCubeGamepad-v0: 帶遊戲手柄控制
  • PandaPickCubeKeyboard-v0: 帶鍵盤控制

Gym 包裝器配置

"wrapper": {
    "gripper_penalty": -0.02,
    "control_time_s": 15.0,
    "use_gripper": true,
    "fixed_reset_joint_positions": [0.0, 0.195, 0.0, -2.43, 0.0, 2.62, 0.785],
    "end_effector_step_sizes": {
        "x": 0.025,
        "y": 0.025,
        "z": 0.025
    },
    "control_mode": "gamepad"
    }

重要引數:

  • gripper_penalty: 對過多抓手移動的懲罰
  • use_gripper: 是否啟用抓手控制
  • end_effector_step_sizes: 末端執行器在 x,y,z 軸上的步長大小
  • control_mode: 設定為 "gamepad" 以使用遊戲手柄控制器

使用 LeRobot 的人在環路強化學習執行

基本用法

要執行環境,請將模式設定為 null

python -m lerobot.scripts.rl.gym_manipulator --config_path path/to/gym_hil_env.json

記錄資料集

要收集資料集,請將模式設定為 record,同時定義 repo_id 和要記錄的回合數。

python -m lerobot.scripts.rl.gym_manipulator --config_path path/to/gym_hil_env.json

訓練策略

要訓練策略,請檢視此處提供的配置示例,並執行執行者(actor)和學習者(learner)伺服器。

python -m lerobot.scripts.rl.actor --config_path path/to/train_gym_hil_env.json

在另一個終端中,執行學習者伺服器。

python -m lerobot.scripts.rl.learner --config_path path/to/train_gym_hil_env.json

模擬環境提供了一種安全且可重複的方式來開發和測試您的“人在環路”強化學習元件,然後再部署到真實機器人上。

恭喜 🎉,您已完成本教程!

如果你有任何問題或需要幫助,請在 Discord 上聯絡我們。

論文引用

@article{luo2024precise,
  title={Precise and Dexterous Robotic Manipulation via Human-in-the-Loop Reinforcement Learning},
  author={Luo, Jianlan and Xu, Charles and Wu, Jeffrey and Levine, Sergey},
  journal={arXiv preprint arXiv:2410.21845},
  year={2024}
}
< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.