11# Copyright (c) 2024-2025 Ziqi Fan
22# SPDX-License-Identifier: Apache-2.0
33
4- # Copyright (c) 2024 -2025, The Isaac Lab Project Developers.
4+ # Copyright (c) 2022 -2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md) .
55# All rights reserved.
66#
7- # SPDX-License-Identifier: Apache-2.0
7+ # SPDX-License-Identifier: BSD-3-Clause
88
99"""Script to train RL agent with RSL-RL."""
1010
1111"""Launch Isaac Sim Simulator first."""
1212
1313import argparse
14- import os
1514import sys
1615
1716from isaaclab .app import AppLauncher
3534 "--distributed" , action = "store_true" , default = False , help = "Run training with multiple GPUs or nodes."
3635)
3736parser .add_argument ("--export_io_descriptors" , action = "store_true" , default = False , help = "Export IO descriptors." )
37+ parser .add_argument (
38+ "--ray-proc-id" , "-rid" , type = int , default = None , help = "Automatically configured by Ray integration, otherwise None."
39+ )
3840# append RSL-RL cli arguments
3941cli_args .add_rsl_rl_args (parser )
4042# append AppLauncher cli args
5557"""Check for minimum supported RSL-RL version."""
5658
5759import importlib .metadata as metadata
60+ import platform
5861
5962from packaging import version
6063
6164# check minimum supported rsl-rl version
6265RSL_RL_VERSION = "3.0.1"
6366installed_version = metadata .version ("rsl-rl-lib" )
6467if version .parse (installed_version ) < version .parse (RSL_RL_VERSION ):
65- cmd = [r"python" , "-m" , "pip" , "install" , f"rsl-rl-lib=={ RSL_RL_VERSION } " ]
68+ if platform .system () == "Windows" :
69+ cmd = [r".\isaaclab.bat" , "-p" , "-m" , "pip" , "install" , f"rsl-rl-lib=={ RSL_RL_VERSION } " ]
70+ else :
71+ cmd = ["./isaaclab.sh" , "-p" , "-m" , "pip" , "install" , f"rsl-rl-lib=={ RSL_RL_VERSION } " ]
6672 print (
6773 f"Please install the correct version of RSL-RL.\n Existing version is: '{ installed_version } '"
6874 f" and required version is: '{ RSL_RL_VERSION } '.\n To install the correct version, run:"
7379"""Rest everything follows."""
7480
7581import gymnasium as gym
82+ import logging
83+ import os
84+ import time
7685import torch
7786from datetime import datetime
7887
79- import omni
8088from rsl_rl .runners import DistillationRunner , OnPolicyRunner
8189
8290from isaaclab .envs import (
8896)
8997from isaaclab .utils .dict import print_dict
9098from isaaclab .utils .io import dump_yaml
99+
91100from isaaclab_rl .rsl_rl import RslRlBaseRunnerCfg , RslRlVecEnvWrapper
101+
102+ import robot_lab .tasks # noqa: F401 # isort: skip
92103from isaaclab_tasks .utils import get_checkpoint_path
93104from isaaclab_tasks .utils .hydra import hydra_task_config
94105
95- import robot_lab .tasks # noqa: F401
106+ # import logger
107+ logger = logging .getLogger (__name__ )
108+
109+ # PLACEHOLDER: Extension template (do not remove this comment)
96110
97111torch .backends .cuda .matmul .allow_tf32 = True
98112torch .backends .cudnn .allow_tf32 = True
@@ -147,7 +161,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
147161 if isinstance (env_cfg , ManagerBasedRLEnvCfg ):
148162 env_cfg .export_io_descriptors = args_cli .export_io_descriptors
149163 else :
150- omni . log . warn (
164+ logger . warning (
151165 "IO descriptors are only supported for manager based RL environments. No IO descriptors will be exported."
152166 )
153167
@@ -177,6 +191,8 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
177191 print_dict (video_kwargs , nesting = 4 )
178192 env = gym .wrappers .RecordVideo (env , ** video_kwargs )
179193
194+ start_time = time .time ()
195+
180196 # wrap around environment for rsl-rl
181197 env = RslRlVecEnvWrapper (env , clip_actions = agent_cfg .clip_actions )
182198
@@ -202,6 +218,8 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
202218 # run training
203219 runner .learn (num_learning_iterations = agent_cfg .max_iterations , init_at_random_ep_len = True )
204220
221+ print (f"Training time: { round (time .time () - start_time , 2 )} seconds" )
222+
205223 # close the simulator
206224 env .close ()
207225
0 commit comments