| | |
| | |
| | |
| | |
| |
|
| | from __future__ import annotations |
| |
|
| | import argparse |
| | import random |
| | from typing import TYPE_CHECKING |
| |
|
| | if TYPE_CHECKING: |
| | from isaaclab_rl.rsl_rl import RslRlBaseRunnerCfg |
| |
|
| |
|
| | def add_rsl_rl_args(parser: argparse.ArgumentParser): |
| | """Add RSL-RL arguments to the parser. |
| | |
| | Args: |
| | parser: The parser to add the arguments to. |
| | """ |
| | |
| | arg_group = parser.add_argument_group("rsl_rl", description="Arguments for RSL-RL agent.") |
| | |
| | arg_group.add_argument( |
| | "--experiment_name", type=str, default=None, help="Name of the experiment folder where logs will be stored." |
| | ) |
| | arg_group.add_argument("--run_name", type=str, default=None, help="Run name suffix to the log directory.") |
| | |
| | arg_group.add_argument("--resume", action="store_true", default=False, help="Whether to resume from a checkpoint.") |
| | arg_group.add_argument("--load_run", type=str, default=None, help="Name of the run folder to resume from.") |
| | arg_group.add_argument("--checkpoint", type=str, default=None, help="Checkpoint file to resume from.") |
| | |
| | arg_group.add_argument( |
| | "--logger", type=str, default=None, choices={"wandb", "tensorboard", "neptune"}, help="Logger module to use." |
| | ) |
| | arg_group.add_argument( |
| | "--log_project_name", type=str, default=None, help="Name of the logging project when using wandb or neptune." |
| | ) |
| |
|
| |
|
| | def parse_rsl_rl_cfg(task_name: str, args_cli: argparse.Namespace) -> RslRlBaseRunnerCfg: |
| | """Parse configuration for RSL-RL agent based on inputs. |
| | |
| | Args: |
| | task_name: The name of the environment. |
| | args_cli: The command line arguments. |
| | |
| | Returns: |
| | The parsed configuration for RSL-RL agent based on inputs. |
| | """ |
| | from isaaclab_tasks.utils.parse_cfg import load_cfg_from_registry |
| |
|
| | |
| | rslrl_cfg: RslRlBaseRunnerCfg = load_cfg_from_registry(task_name, "rsl_rl_cfg_entry_point") |
| | rslrl_cfg = update_rsl_rl_cfg(rslrl_cfg, args_cli) |
| | return rslrl_cfg |
| |
|
| |
|
| | def update_rsl_rl_cfg(agent_cfg: RslRlBaseRunnerCfg, args_cli: argparse.Namespace): |
| | """Update configuration for RSL-RL agent based on inputs. |
| | |
| | Args: |
| | agent_cfg: The configuration for RSL-RL agent. |
| | args_cli: The command line arguments. |
| | |
| | Returns: |
| | The updated configuration for RSL-RL agent based on inputs. |
| | """ |
| | |
| | if hasattr(args_cli, "seed") and args_cli.seed is not None: |
| | |
| | if args_cli.seed == -1: |
| | args_cli.seed = random.randint(0, 10000) |
| | agent_cfg.seed = args_cli.seed |
| | if args_cli.resume is not None: |
| | agent_cfg.resume = args_cli.resume |
| | if args_cli.load_run is not None: |
| | agent_cfg.load_run = args_cli.load_run |
| | if args_cli.checkpoint is not None: |
| | agent_cfg.load_checkpoint = args_cli.checkpoint |
| | if args_cli.run_name is not None: |
| | agent_cfg.run_name = args_cli.run_name |
| | if args_cli.logger is not None: |
| | agent_cfg.logger = args_cli.logger |
| | |
| | if agent_cfg.logger in {"wandb", "neptune"} and args_cli.log_project_name: |
| | agent_cfg.wandb_project = args_cli.log_project_name |
| | agent_cfg.neptune_project = args_cli.log_project_name |
| |
|
| | return agent_cfg |
| |
|