运行现有脚本#

展厅#

Isaac Lab中的主要核心接口扩展 omni.isaac.lab 提供了执行器、对象、机器人和传感器的主要模块。我们提供了一系列演示脚本和教程。这些展示了如何以最简化的方式在代码中使用提供的接口。

一些快速展厅脚本可供运行和查看:

  • 产生不同的四足动物,并使用位置命令使机器人站立:

    ./isaaclab.sh -p source/standalone/demos/quadrupeds.py
    
  • 产生不同的机械臂,并施加随机关节位置命令:

    ./isaaclab.sh -p source/standalone/demos/arms.py
    
  • 产生不同的手部并命令它们打开和关闭:

    ./isaaclab.sh -p source/standalone/demos/hands.py
    
  • 生成不同配置的过程生成地形:

    ./isaaclab.sh -p source/standalone/demos/procedural_terrain.py
    
  • 产生不同的可变形(软)体并让它们从高处落下:

    ./isaaclab.sh -p source/standalone/demos/deformables.py
    
  • 产生对可视化有用的多个标记:

    ./isaaclab.sh -p source/standalone/demos/markers.py
    

工作流#

使用Isaac Lab,我们还提供了包含在 omni.isaac.lab_tasks 扩展中的一套基准环境。我们使用OpenAI Gym注册表来注册这些环境。对于每个环境,我们提供一个默认配置文件,定义了场景、观察、奖励和动作空间。

可以通过运行下面的命令找到已在OpenAI Gym注册的环境列表:

./isaaclab.sh -p source/standalone/environments/list_envs.py

基本代理#

这些包括输出零或随机代理的基本代理。它们有助于确保环境配置正确。

  • 调试杆示例上的零动作代理

    ./isaaclab.sh -p source/standalone/environments/zero_agent.py --task Isaac-Cartpole-v0 --num_envs 32
    
  • 调试杆示例上的随机动作代理:

    ./isaaclab.sh -p source/standalone/environments/random_agent.py --task Isaac-Cartpole-v0 --num_envs 32
    

状态机#

我们包括手工制作的状态机示例,用于环境。这有助于理解环境以及如何使用提供的接口。状态机是用 Warp 编写的,它允许使用CUDA核函数对大量环境进行有效执行。

./isaaclab.sh -p source/standalone/environments/state_machine/lift_cube_sm.py --num_envs 32

远程操作#

我们提供接口,用于在机器人控制中提供SE(2)和SE(3)空间的命令。在SE(2)远程操作的情况下,返回的命令是线性x-y速度和偏航速率,而在SE(3)远程操作的情况下,返回的命令是表示姿势变化的6-D向量。

使用键盘设备进行逆运动学(IK)控制:

./isaaclab.sh -p source/standalone/environments/teleoperation/teleop_se3_agent.py --task Isaac-Lift-Cube-Franka-IK-Rel-v0 --num_envs 1 --teleop_device keyboard

该脚本打印了配置的远程操作事件。对于键盘,这些是如下所示:

Keyboard Controller for SE(3): Se3Keyboard
    Reset all commands: L
    Toggle gripper (open/close): K
    Move arm along x-axis: W/S
    Move arm along y-axis: A/D
    Move arm along z-axis: Q/E
    Rotate arm along x-axis: Z/X
    Rotate arm along y-axis: T/G
    Rotate arm along z-axis: C/V

模仿学习#

使用远程操作设备,还可以收集学习自示范(LfD)的数据。为此,我们支持学习框架 Robomimic (仅限Linux),并允许以 HDF5 格式保存数据。

  1. 为环境 Isaac-Lift-Cube-Franka-IK-Rel-v0 收集远程操作的演示:

    # step a: collect data with keyboard
    ./isaaclab.sh -p source/standalone/workflows/robomimic/collect_demonstrations.py --task Isaac-Lift-Cube-Franka-IK-Rel-v0 --num_envs 1 --num_demos 10 --teleop_device keyboard
    # step b: inspect the collected dataset
    ./isaaclab.sh -p source/standalone/workflows/robomimic/tools/inspect_demonstrations.py logs/robomimic/Isaac-Lift-Cube-Franka-IK-Rel-v0/hdf_dataset.hdf5
    
  2. 将数据集分割为训练集和验证集:

    # install the dependencies
    sudo apt install cmake build-essential
    # install python module (for robomimic)
    ./isaaclab.sh -i robomimic
    # split data
    ./isaaclab.sh -p source/standalone//workflows/robomimic/tools/split_train_val.py logs/robomimic/Isaac-Lift-Cube-Franka-IK-Rel-v0/hdf_dataset.hdf5 --ratio 0.2
    
  3. 使用 RobomimicIsaac-Lift-Cube-Franka-IK-Rel-v0 训练BC代理:

    ./isaaclab.sh -p source/standalone/workflows/robomimic/train.py --task Isaac-Lift-Cube-Franka-IK-Rel-v0 --algo bc --dataset logs/robomimic/Isaac-Lift-Cube-Franka-IK-Rel-v0/hdf_dataset.hdf5
    
  4. 播放学习模型以可视化结果:

    ./isaaclab.sh -p source/standalone/workflows/robomimic/play.py --task Isaac-Lift-Cube-Franka-IK-Rel-v0 --checkpoint /PATH/TO/model.pth
    

强化学习#

我们提供不同增强型库的包装器。这些包装器将环境中的数据转换为相应的库函数参数和返回类型。

  • 使用 Stable-Baselines3Isaac-Cartpole-v0 上训练代理:

    # install python module (for stable-baselines3)
    ./isaaclab.sh -i sb3
    # run script for training
    # note: we set the device to cpu since SB3 doesn't optimize for GPU anyway
    ./isaaclab.sh -p source/standalone/workflows/sb3/train.py --task Isaac-Cartpole-v0 --headless --device cpu
    # run script for playing with 32 environments
    ./isaaclab.sh -p source/standalone/workflows/sb3/play.py --task Isaac-Cartpole-v0 --num_envs 32 --checkpoint /PATH/TO/model.zip
    # run script for recording video of a trained agent (requires installing `ffmpeg`)
    ./isaaclab.sh -p source/standalone/workflows/sb3/play.py --task Isaac-Cartpole-v0 --headless --video --video_length 200
    
  • 使用 SKRLIsaac-Reach-Franka-v0 上训练一个代理:

    # install python module (for skrl)
    ./isaaclab.sh -i skrl
    # run script for training
    ./isaaclab.sh -p source/standalone/workflows/skrl/train.py --task Isaac-Reach-Franka-v0 --headless
    # run script for playing with 32 environments
    ./isaaclab.sh -p source/standalone/workflows/skrl/play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --checkpoint /PATH/TO/model.pt
    # run script for recording video of a trained agent (requires installing `ffmpeg`)
    ./isaaclab.sh -p source/standalone/workflows/skrl/play.py --task Isaac-Reach-Franka-v0 --headless --video --video_length 200
    
    # install python module (for skrl)
    ./isaaclab.sh -i skrl
    # install skrl dependencies for JAX. Visit https://skrl.readthedocs.io/en/latest/intro/installation.html for more details
    ./isaaclab.sh -p -m pip install skrl["jax"]
    # run script for training
    ./isaaclab.sh -p source/standalone/workflows/skrl/train.py --task Isaac-Reach-Franka-v0 --headless --ml_framework jax
    # run script for playing with 32 environments
    ./isaaclab.sh -p source/standalone/workflows/skrl/play.py --task Isaac-Reach-Franka-v0 --num_envs 32  --ml_framework jax --checkpoint /PATH/TO/model.pt
    # run script for recording video of a trained agent (requires installing `ffmpeg`)
    ./isaaclab.sh -p source/standalone/workflows/skrl/play.py --task Isaac-Reach-Franka-v0 --headless --ml_framework jax --video --video_length 200
    
  • 使用 Isaac-Ant-v0 上的 RL-Games 训练一个代理:

    # install python module (for rl-games)
    ./isaaclab.sh -i rl_games
    # run script for training
    ./isaaclab.sh -p source/standalone/workflows/rl_games/train.py --task Isaac-Ant-v0 --headless
    # run script for playing with 32 environments
    ./isaaclab.sh -p source/standalone/workflows/rl_games/play.py --task Isaac-Ant-v0 --num_envs 32 --checkpoint /PATH/TO/model.pth
    # run script for recording video of a trained agent (requires installing `ffmpeg`)
    ./isaaclab.sh -p source/standalone/workflows/rl_games/play.py --task Isaac-Ant-v0 --headless --video --video_length 200
    
  • 使用 Isaac-Reach-Franka-v0 上的 RSL-RL 训练一个代理:

    # install python module (for rsl-rl)
    ./isaaclab.sh -i rsl_rl
    # run script for training
    ./isaaclab.sh -p source/standalone/workflows/rsl_rl/train.py --task Isaac-Reach-Franka-v0 --headless
    # run script for playing with 32 environments
    ./isaaclab.sh -p source/standalone/workflows/rsl_rl/play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --load_run run_folder_name --checkpoint model.pt
    # run script for recording video of a trained agent (requires installing `ffmpeg`)
    ./isaaclab.sh -p source/standalone/workflows/rsl_rl/play.py --task Isaac-Reach-Franka-v0 --headless --video --video_length 200
    

上述所有脚本都会将训练进度记录到存储库根目录下 log 目录中的 Tensorboard 中。 log 目录遵循模式 logs/<library>/<task>/<date-time> , 其中 <library> 是学习框架的名称, <task> 是任务名称, <date-time> 是执行训练脚本时的时间戳。

要查看日志,请运行 :

# execute from the root directory of the repository
./isaaclab.sh -p -m tensorboard.main --logdir=logs