Skip to content

Commit a77910b

Browse files
authored
Fixes skrl train/play script configurations when using the --agent argument and rename agent configuration variable (isaac-sim#3643)
# Description This PR address the following points: * Fix skrl train/play script configuration when using the `--agent` argument Example: ```bash python scripts/reinforcement_learning/skrl/train.py --task Isaac-Cart-Double-Pendulum-Direct-v0 --headless --agent skrl_mappo_cfg_entry_point ``` Error: ``` [INFO]: Parsing configuration from: isaaclab_tasks.direct.cart_double_pendulum.cart_double_pendulum_env:CartDoublePendulumEnvCfg [INFO]: Parsing configuration from: /home/toni/Documents/RL/toni_IsaacLab/source/isaaclab_tasks/isaaclab_tasks/direct/cart_double_pendulum/agents/skrl_mappo_cfg.yaml [INFO] Logging experiment in directory: /home/toni/Documents/RL/toni_IsaacLab/logs/skrl/cart_double_pendulum_direct Error executing job with overrides: [] Traceback (most recent call last): File "/home/toni/Documents/RL/toni_IsaacLab/source/isaaclab_tasks/isaaclab_tasks/utils/hydra.py", line 101, in hydra_main func(env_cfg, agent_cfg, *args, **kwargs) File "/home/toni/Documents/RL/toni_IsaacLab/scripts/reinforcement_learning/skrl/train.py", line 156, in main log_dir = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") + f"_{algorithm}_{args_cli.ml_framework}" ^^^^^^^^^ NameError: name 'algorithm' is not defined ``` * Replace `STATES` by `OBSERVATIONS` when defining skrl's agent configuration model inputs to ensure a smooth and error-free transition when the new mayor version of **skrl** gets released. In such mayor version `OBSERVATIONS` and `STATES` have different value/usage. ## Type of change <!-- As you go through the list, delete the ones that are not applicable. --> - Bug fix (non-breaking change which fixes an issue)
1 parent a8cec21 commit a77910b

54 files changed

Lines changed: 110 additions & 108 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

scripts/reinforcement_learning/skrl/play.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
agent_cfg_entry_point = "skrl_cfg_entry_point" if algorithm in ["ppo"] else f"skrl_{algorithm}_cfg_entry_point"
122122
else:
123123
agent_cfg_entry_point = args_cli.agent
124+
algorithm = agent_cfg_entry_point.split("_cfg")[0].split("skrl_")[-1].lower()
124125

125126

126127
@hydra_task_config(args_cli.task, agent_cfg_entry_point)

scripts/reinforcement_learning/skrl/train.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
agent_cfg_entry_point = "skrl_cfg_entry_point" if algorithm in ["ppo"] else f"skrl_{algorithm}_cfg_entry_point"
120120
else:
121121
agent_cfg_entry_point = args_cli.agent
122+
algorithm = agent_cfg_entry_point.split("_cfg")[0].split("skrl_")[-1].lower()
122123

123124

124125
@hydra_task_config(args_cli.task, agent_cfg_entry_point)

source/isaaclab_tasks/isaaclab_tasks/direct/allegro_hand/agents/skrl_ppo_cfg.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ models:
1919
initial_log_std: 0.0
2020
network:
2121
- name: net
22-
input: STATES
22+
input: OBSERVATIONS
2323
layers: [1024, 512, 256, 128]
2424
activations: elu
2525
output: ACTIONS
@@ -28,7 +28,7 @@ models:
2828
clip_actions: False
2929
network:
3030
- name: net
31-
input: STATES
31+
input: OBSERVATIONS
3232
layers: [1024, 512, 256, 128]
3333
activations: elu
3434
output: ONE

source/isaaclab_tasks/isaaclab_tasks/direct/ant/agents/skrl_ppo_cfg.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ models:
1919
initial_log_std: 0.0
2020
network:
2121
- name: net
22-
input: STATES
22+
input: OBSERVATIONS
2323
layers: [256, 128, 64]
2424
activations: elu
2525
output: ACTIONS
@@ -28,7 +28,7 @@ models:
2828
clip_actions: False
2929
network:
3030
- name: net
31-
input: STATES
31+
input: OBSERVATIONS
3232
layers: [256, 128, 64]
3333
activations: elu
3434
output: ONE

source/isaaclab_tasks/isaaclab_tasks/direct/anymal_c/agents/skrl_flat_ppo_cfg.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ models:
1919
initial_log_std: 0.0
2020
network:
2121
- name: net
22-
input: STATES
22+
input: OBSERVATIONS
2323
layers: [128, 128, 128]
2424
activations: elu
2525
output: ACTIONS
@@ -28,7 +28,7 @@ models:
2828
clip_actions: False
2929
network:
3030
- name: net
31-
input: STATES
31+
input: OBSERVATIONS
3232
layers: [128, 128, 128]
3333
activations: elu
3434
output: ONE

source/isaaclab_tasks/isaaclab_tasks/direct/anymal_c/agents/skrl_rough_ppo_cfg.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ models:
1919
initial_log_std: 0.0
2020
network:
2121
- name: net
22-
input: STATES
22+
input: OBSERVATIONS
2323
layers: [512, 256, 128]
2424
activations: elu
2525
output: ACTIONS
@@ -28,7 +28,7 @@ models:
2828
clip_actions: False
2929
network:
3030
- name: net
31-
input: STATES
31+
input: OBSERVATIONS
3232
layers: [512, 256, 128]
3333
activations: elu
3434
output: ONE

source/isaaclab_tasks/isaaclab_tasks/direct/cart_double_pendulum/agents/skrl_ippo_cfg.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ models:
1919
initial_log_std: 0.0
2020
network:
2121
- name: net
22-
input: STATES
22+
input: OBSERVATIONS
2323
layers: [32, 32]
2424
activations: elu
2525
output: ACTIONS
@@ -28,7 +28,7 @@ models:
2828
clip_actions: False
2929
network:
3030
- name: net
31-
input: STATES
31+
input: OBSERVATIONS
3232
layers: [32, 32]
3333
activations: elu
3434
output: ONE

source/isaaclab_tasks/isaaclab_tasks/direct/cart_double_pendulum/agents/skrl_mappo_cfg.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ models:
1919
initial_log_std: 0.0
2020
network:
2121
- name: net
22-
input: STATES
22+
input: OBSERVATIONS
2323
layers: [32, 32]
2424
activations: elu
2525
output: ACTIONS
@@ -28,7 +28,7 @@ models:
2828
clip_actions: False
2929
network:
3030
- name: net
31-
input: STATES
31+
input: OBSERVATIONS
3232
layers: [32, 32]
3333
activations: elu
3434
output: ONE

source/isaaclab_tasks/isaaclab_tasks/direct/cart_double_pendulum/agents/skrl_ppo_cfg.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ models:
1919
initial_log_std: 0.0
2020
network:
2121
- name: net
22-
input: STATES
22+
input: OBSERVATIONS
2323
layers: [32, 32]
2424
activations: elu
2525
output: ACTIONS
@@ -28,7 +28,7 @@ models:
2828
clip_actions: False
2929
network:
3030
- name: net
31-
input: STATES
31+
input: OBSERVATIONS
3232
layers: [32, 32]
3333
activations: elu
3434
output: ONE

source/isaaclab_tasks/isaaclab_tasks/direct/cartpole/agents/skrl_camera_ppo_cfg.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ models:
1919
initial_log_std: 0.0
2020
network:
2121
- name: features_extractor
22-
input: permute(STATES, (0, 3, 1, 2)) # PyTorch NHWC -> NCHW. Warning: don't permute for JAX since it expects NHWC
22+
input: permute(OBSERVATIONS, (0, 3, 1, 2)) # PyTorch NHWC -> NCHW. Warning: don't permute for JAX since it expects NHWC
2323
layers:
2424
- conv2d: {out_channels: 32, kernel_size: 8, stride: 4, padding: 0}
2525
- conv2d: {out_channels: 64, kernel_size: 4, stride: 2, padding: 0}
@@ -36,7 +36,7 @@ models:
3636
clip_actions: False
3737
network:
3838
- name: features_extractor
39-
input: permute(STATES, (0, 3, 1, 2)) # PyTorch NHWC -> NCHW. Warning: don't permute for JAX since it expects NHWC
39+
input: permute(OBSERVATIONS, (0, 3, 1, 2)) # PyTorch NHWC -> NCHW. Warning: don't permute for JAX since it expects NHWC
4040
layers:
4141
- conv2d: {out_channels: 32, kernel_size: 8, stride: 4, padding: 0}
4242
- conv2d: {out_channels: 64, kernel_size: 4, stride: 2, padding: 0}

0 commit comments

Comments
 (0)