LeIsaac × LeRobot EnvHub
LeRobot EnvHub 现在支持使用 LeIsaac 进行仿真中的模仿学习。 启动日常操作任务,远程操作机器人,收集演示,将它们推送到 Hub,并在 LeRobot 中训练策略 — 全部在一个循环中。
LeIsaac 与 IsaacLab 和 SO101 Leader/Follower 设置集成,提供:
- 🕹️ 远程操作优先工作流用于数据收集
- 📦 内置数据转换,可用于 LeRobot 训练
- 🤖 日常技能,如摘橙子、举起立方体、清洁桌子和折叠布料
- ☁️ 持续升级来自 LightWheel:云仿真、EnvHub 支持、Sim2Real 工具等
下面您将找到通过 LeRobot EnvHub 公开的当前支持的 LeIsaac 任务。
可用环境
下表列出了 LeIsaac x LeRobot Envhub 中所有可用的任务和环境。您也可以通过运行以下命令获取最新的环境列表:
python scripts/environments/list_envs.py
| 任务 | 环境 ID | 任务描述 | 相关机器人 |
|---|---|---|---|
| LeIsaac-SO101-PickOrange-v0 LeIsaac-SO101-PickOrange-Direct-v0 |
摘三个橙子并放入盘子中,然后将手臂重置到休息状态。 | 单臂 SO101 Follower | |
| LeIsaac-SO101-LiftCube-v0 LeIsaac-SO101-LiftCube-Direct-v0 |
举起红色立方体。 | 单臂 SO101 Follower | |
| LeIsaac-SO101-CleanToyTable-v0 LeIsaac-SO101-CleanToyTable-BiArm-v0 LeIsaac-SO101-CleanToyTable-BiArm-Direct-v0 |
将两个字母 e 对象放入盒子中,并将手臂重置到休息状态。 | 单臂 SO101 Follower 双臂 SO101 Follower |
|
| LeIsaac-SO101-FoldCloth-BiArm-v0 LeIsaac-SO101-FoldCloth-BiArm-Direct-v0 |
折叠布料,并将手臂重置到休息状态。 注意:在此任务中,只有 DirectEnv 支持 check_success。 |
双臂 SO101 Follower |
在 LeRobot 中用一行代码直接加载 LeIsaac
EnvHub:通过 HuggingFace 共享 LeIsaac 环境
EnvHub 是我们的可重现环境中心,用一行代码启动打包的仿真,立即实验,并为社区发布您自己的任务。
LeIsaac 提供 EnvHub 支持,因此您只需几个命令即可使用或共享任务。
如何开始,环境设置
运行以下命令设置您的代码环境:
# 首先参考入门/安装来安装 leisaac
conda create -n leisaac_envhub python=3.11
conda activate leisaac_envhub
conda install -c "nvidia/label/cuda-12.8.1" cuda-toolkit
pip install -U torch==2.7.0 torchvision==0.22.0 --index-url https://download.pytorch.org/whl/cu128
pip install 'leisaac[isaaclab] @ git+https://github.com/LightwheelAI/leisaac.git#subdirectory=source/leisaac' --extra-index-url https://pypi.nvidia.com
# 安装 lerobot
pip install lerobot==0.4.1
# 修复 numpy 版本
pip install numpy==1.26.0
使用示例
EnvHub 以统一接口公开每个 LeIsaac 支持的任务。下面的示例加载 so101_pick_orange 并演示随机动作推演和交互式远程操作。
随机动作
点击展开代码示例
# envhub_random_action.py
import torch
from lerobot.envs import make_env
# 从 hub 加载
envs_dict = make_env("LightwheelAI/leisaac_env:envs/so101_pick_orange.py", n_envs=1, trust_remote_code=True)
# 访问环境
suite_name = next(iter(envs_dict))
sync_vector_env = envs_dict[suite_name][0]
# 从 sync vector env 检索 isaac 环境
env = sync_vector_env.envs[0].unwrapped
# 像任何 gym 环境一样使用它
obs, info = env.reset()
while True:
action = torch.tensor(env.action_space.sample())
obs, reward, terminated, truncated, info = env.step(action)
if terminated or truncated:
obs, info = env.reset()
env.close()
python envhub_random_action.py
您应该看到 SO101 手臂在纯随机命令下摆动。
远程操作
LeRobot 的远程操作堆栈可以驱动模拟手臂。
连接 SO101 Leader 控制器,运行下面的校准命令。
lerobot-calibrate \
--teleop.type=so101_leader \
--teleop.port=/dev/ttyACM0 \
--teleop.id=leader
然后启动远程操作脚本。
点击展开代码示例
# envhub_teleop_example.py
import logging
import time
import gymnasium as gym
from dataclasses import asdict, dataclass
from pprint import pformat
from lerobot.teleoperators import ( # noqa: F401
Teleoperator,
TeleoperatorConfig,
make_teleoperator_from_config,
so_leader,
bi_so_leader,
)
from lerobot.utils.robot_utils import precise_sleep
from lerobot.utils.utils import init_logging
from lerobot.envs import make_env
@dataclass
class TeleoperateConfig:
teleop: TeleoperatorConfig
env_name: str = "so101_pick_orange"
fps: int = 60
@dataclass
class EnvWrap:
env: gym.Env
def make_env_from_leisaac(env_name: str = "so101_pick_orange"):
envs_dict = make_env(
f'LightwheelAI/leisaac_env:envs/{env_name}.py',
n_envs=1,
trust_remote_code=True
)
suite_name = next(iter(envs_dict))
sync_vector_env = envs_dict[suite_name][0]
env = sync_vector_env.envs[0].unwrapped
return env
def teleop_loop(teleop: Teleoperator, env: gym.Env, fps: int):
from leisaac.devices.action_process import preprocess_device_action
from leisaac.assets.robots.lerobot import SO101_FOLLOWER_MOTOR_LIMITS
from leisaac.utils.env_utils import dynamic_reset_gripper_effort_limit_sim
env_wrap = EnvWrap(env=env)
obs, info = env.reset()
while True:
loop_start = time.perf_counter()
if env.cfg.dynamic_reset_gripper_effort_limit:
dynamic_reset_gripper_effort_limit_sim(env, 'so101leader')
raw_action = teleop.get_action()
processed_action = preprocess_device_action(
dict(
so101_leader=True,
joint_state={
k.removesuffix(".pos"): v for k, v in raw_action.items()},
motor_limits=SO101_FOLLOWER_MOTOR_LIMITS),
env_wrap
)
obs, reward, terminated, truncated, info = env.step(processed_action)
if terminated or truncated:
obs, info = env.reset()
dt_s = time.perf_counter() - loop_start
precise_sleep(max(1 / fps - dt_s, 0.0))
loop_s = time.perf_counter() - loop_start
print(f"\ntime: {loop_s * 1e3:.2f}ms ({1 / loop_s:.0f} Hz)")
def teleoperate(cfg: TeleoperateConfig):
init_logging()
logging.info(pformat(asdict(cfg)))
teleop = make_teleoperator_from_config(cfg.teleop)
env = make_env_from_leisaac(cfg.env_name)
teleop.connect()
if hasattr(env, 'initialize'):
env.initialize()
try:
teleop_loop(teleop=teleop, env=env, fps=cfg.fps)
except KeyboardInterrupt:
pass
finally:
teleop.disconnect()
env.close()
def main():
teleoperate(TeleoperateConfig(
teleop=so_leader.SO101LeaderConfig(
port="/dev/ttyACM0",
id='leader',
use_degrees=False,
),
env_name="so101_pick_orange",
fps=60,
))
if __name__ == "__main__":
main()
python envhub_teleop_example.py
运行脚本可让您使用物理 Leader 设备操作模拟手臂。
☁️ 云仿真(无需 GPU)
没有本地 GPU 或正确的驱动程序?没问题!您可以完全在云中运行 LeIsaac,无需任何设置。 LeIsaac 在 NVIDIA Brev 上开箱即用,直接在浏览器中为您提供完全配置的环境。
👉 从这里开始: https://lightwheelai.github.io/leisaac/docs/cloud_simulation/nvidia_brev
一旦您的实例部署完成,只需打开 端口 80 (HTTP) 的链接即可启动 Visual Studio Code Server(默认密码:password)。从那里,您可以运行仿真、编辑代码和可视化 IsaacLab 环境 — 全部来自您的 Web 浏览器。
无需 GPU,无需驱动程序,无需本地安装。只需点击并运行。
附加说明
我们保持 EnvHub 覆盖与 LeIsaac 任务一致。当前支持:
so101_pick_orangeso101_lift_cubeso101_clean_toytablebi_so101_fold_cloth
通过在调用 make_env 时定位不同的脚本来切换任务,例如:
envs_dict_pick_orange = make_env("LightwheelAI/leisaac_env:envs/so101_pick_orange.py", n_envs=1, trust_remote_code=True)
envs_dict_lift_cube = make_env("LightwheelAI/leisaac_env:envs/so101_lift_cube.py", n_envs=1, trust_remote_code=True)
envs_dict_clean_toytable = make_env("LightwheelAI/leisaac_env:envs/so101_clean_toytable.py", n_envs=1, trust_remote_code=True)
envs_dict_fold_cloth = make_env("LightwheelAI/leisaac_env:envs/bi_so101_fold_cloth.py", n_envs=1, trust_remote_code=True)
注意:使用 bi_so101_fold_cloth 时,在检索环境后立即调用 initialize(),然后再执行任何其他操作:
点击展开代码示例
import torch
from lerobot.envs import make_env
# 从 hub 加载
envs_dict = make_env("LightwheelAI/leisaac_env:envs/bi_so101_fold_cloth.py", n_envs=1, trust_remote_code=True)
# 访问环境
suite_name = next(iter(envs_dict))
sync_vector_env = envs_dict[suite_name][0]
# 从 sync vector env 检索 isaac 环境
env = sync_vector_env.envs[0].unwrapped
# 注意:首先 initialize()
env.initialize()
# 使用 env 进行其他操作...