Omniverse Isaac Gym environments
Environments
The repository https://github.com/NVIDIA-Omniverse/OmniIsaacGymEnvs provides the example reinforcement learning environments for Omniverse Isaac Gym
These environments can be easily loaded and configured by calling a single function provided with this library. This function also makes it possible to configure the environment from the command line arguments (see configuration-and-command-line-arguments) or from its parameters as a python dictionary
Additionally, multi-threaded environments can be loaded. These are designed to isolate the RL policy in a new thread, separate from the main simulation and rendering thread. Read more about it in the NVIDIA Omniverse Isaac Sim documentation: Multi-Threaded Environment Wrapper
Note
The command line arguments has priority over the function parameters
Note
Only the configuration related to the environment will be used. The configuration related to RL algorithms are discarded since they do not belong to this library
Note
Omniverse Isaac Gym environments implement a functionality to get their configuration from the command line. Setting the headless
option from the trainer configuration will not work. In this case, it is necessary to invoke the scripts as follows: python script.py headless=True
Basic usage
Common environments
In this approach, the RL algorithm maintains the main execution loop
1# import the environment loader
2from skrl.envs.torch import load_omniverse_isaacgym_env
3
4# load environment
5env = load_omniverse_isaacgym_env(task_name="Cartpole")
1# import the environment loader
2from skrl.envs.torch import load_omniverse_isaacgym_env
3
4# load environment
5env = load_omniverse_isaacgym_env()
Run the main script passing the configuration as command line arguments. For example:
python main.py task=Cartpole
Multi-threaded environments
In this approach, the RL algorithm is executed on a secondary thread while the simulation and rendering is executed on the main thread
1import threading
2
3# import the environment loader
4from skrl.envs.torch import load_omniverse_isaacgym_env
5
6# load environment
7env = load_omniverse_isaacgym_env(task_name="Cartpole", multi_threaded=True, timeout=30)
8
9...
10
11# start training in a separate thread
12threading.Thread(target=trainer.train).start()
13
14# run the simulation in the main thread
15env.run()
1import threading
2
3# import the environment loader
4from skrl.envs.torch import load_omniverse_isaacgym_env
5
6# load environment
7env = load_omniverse_isaacgym_env(multi_threaded=True, timeout=30)
8
9...
10
11# start training in a separate thread
12threading.Thread(target=trainer.train).start()
13
14# run the simulation in the main thread
15env.run()
Run the main script passing the configuration as command line arguments. For example:
python main.py task=Cartpole
API
- skrl.envs.torch.loaders.load_omniverse_isaacgym_env(task_name: str = '', omniisaacgymenvs_path: str = '', show_cfg: bool = True, multi_threaded: bool = False, timeout: int = 30)
Load an Omniverse Isaac Gym environment
Omniverse Isaac Gym benchmark environments: https://github.com/NVIDIA-Omniverse/OmniIsaacGymEnvs
- Parameters
task_name (str, optional) – The name of the task (default: “”). If not specified, the task name is taken from the command line argument (
task=TASK_NAME
). Command line argument has priority over function parameter if both are specifiedomniisaacgymenvs_path (str, optional) – The path to the
omniisaacgymenvs
directory (default: “”). If empty, the path will obtained from omniisaacgymenvs package metadatashow_cfg (bool, optional) – Whether to print the configuration (default: True)
multi_threaded (bool, optional) – Whether to use multi-threaded environment (default: False)
timeout (int, optional) – Seconds to wait for data when queue is empty in multi-threaded environment (default: 30)
- Raises
ValueError – The task name has not been defined, neither by the function parameter nor by the command line arguments
RuntimeError – The omniisaacgymenvs package is not installed or the path is wrong
- Returns
Omniverse Isaac Gym environment
- Return type
omni.isaac.gym.vec_env.vec_env_base.VecEnvBase or omni.isaac.gym.vec_env.vec_env_mt.VecEnvMT