Skip to content

Commit 13b96c3

Browse files
committed
Introducing new feature for hydra group configuration override.
1 parent 3d5ea25 commit 13b96c3

File tree

8 files changed

+513
-14
lines changed

8 files changed

+513
-14
lines changed

docs/source/features/hydra.rst

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,137 @@ the post init update is as follows:
127127

128128
Here, when modifying ``env.decimation`` or ``env.sim.dt``, the user needs to give the updated ``env.sim.render_interval``,
129129
``env.scene.height_scanner.update_period``, and ``env.scene.contact_forces.update_period`` as input as well.
130+
131+
132+
Group Override
133+
--------------
134+
Group override lets you swap out entire groups of environment- or agent-level settings in one go.
135+
Instead of overriding individual fields, you select a named preset defined in your code.
136+
137+
138+
Group Presets
139+
^^^^^^^^^^^^^
140+
First define the available group override options
141+
142+
143+
.. code-block:: python
144+
145+
@configclass
146+
class StateNoNoiseObservationsCfg:
147+
"""Observation specifications for the MDP."""
148+
149+
@configclass
150+
class PolicyCfg(ObsGroup):
151+
"""Observations for policy group."""
152+
153+
# observation terms (order preserved)
154+
joint_pos = ObsTerm(func=mdp.joint_pos_rel)
155+
# other terms .......
156+
157+
def __post_init__(self):
158+
self.enable_corruption = False
159+
self.concatenate_terms = True
160+
161+
# observation groups
162+
policy: PolicyCfg = PolicyCfg()
163+
164+
165+
@configclass
166+
class EnvConfigurables:
167+
env: dict[str, any] = {
168+
"observations": {
169+
"state_obs_no_noise": StateNoNoiseObservationsCfg(),
170+
"state_obs_noisy": # other option,
171+
},
172+
"actions.arm_action": {
173+
"joint_pos_arm_action": mdp.JointPositionActionCfg(
174+
asset_name="robot", joint_names=["panda_joint.*"], scale=0.5, use_default_offset=True
175+
),
176+
"osc_arm_action": mdp.OperationalSpaceControllerActionCfg(
177+
asset_name="robot",
178+
# rest of fields
179+
),
180+
},
181+
"events": {
182+
"rand_joint_pos_friction": JointRandPositionFrictionEventCfg(),
183+
"rand_joint_pos_friction_amarture": JointRandPositionFrictionAmartureEventCfg(),
184+
},
185+
"events.reset_robot_joints": {
186+
"aggressive": EventTerm(
187+
func=mdp.reset_joints_by_scale,
188+
mode="reset",
189+
params={
190+
"position_range": (0.0, 2.0),
191+
"velocity_range": (0.0, 1.0),
192+
},
193+
),
194+
"easy": # easy EventTerm with narrower ranges
195+
},
196+
}
197+
198+
199+
200+
@configclass
201+
class AgentConfigurables(EnvConfigurables):
202+
agent: dict[str, any] = {
203+
"policy": {
204+
"large_network": RslRlPpoActorCriticCfg(
205+
init_noise_std=1.0,
206+
actor_hidden_dims=[512, 256, 128, 64],
207+
critic_hidden_dims=[512, 256, 128, 64],
208+
activation="elu",
209+
),
210+
"medium_network": RslRlPpoActorCriticCfg(
211+
init_noise_std=1.0,
212+
actor_hidden_dims=[256, 128, 64],
213+
critic_hidden_dims=[256, 128, 64],
214+
activation="elu",
215+
),
216+
"small_network": RslRlPpoActorCriticCfg(
217+
init_noise_std=1.0,
218+
actor_hidden_dims=[128, 64],
219+
critic_hidden_dims=[128, 64],
220+
activation="elu",
221+
),
222+
},
223+
# algorithm cfg.....
224+
}
225+
226+
227+
Group Registration
228+
^^^^^^^^^^^^^^^^^^
229+
When you register your Gym environment, provide the ``configurable_entry_point`` pointing to your ``@configclass``:
230+
231+
.. code-block:: python
232+
233+
gym.register(
234+
id="Isaac-Reach-Franka-v0",
235+
entry_point="isaaclab.envs:ManagerBasedRLEnv",
236+
disable_env_checker=True,
237+
kwargs={
238+
# … other cfg entry points …
239+
"configurable_entry_point": f"{agents.__name__}.configurables:AgentConfigurables"
240+
},
241+
)
242+
243+
244+
Override Syntax
245+
^^^^^^^^^^^^^^^
246+
Select one preset per group via Hydra-style CLI flags. For example::
247+
248+
python scripts/reinforcement_learning/rsl_rl/train.py \
249+
--task=Isaac-Reach-Franka-v0 \
250+
--headless \
251+
env.events=rand_joint_pos_friction_amarture \
252+
env.observations=state_obs_no_noise \
253+
env.actions.arm_action=osc_arm_action \
254+
agent.policy=large_network
255+
256+
Under the hood, Hydra will replace:
257+
258+
- ``env.events`` with ``EnvConfigurables.env["rand_joint_pos_friction_amarture"]``
259+
- ``env.observations`` with ``EnvConfigurables.env["state_obs_no_noise"]``
260+
- ``env.actions.arm_action`` with ``EnvConfigurables.env["actions.arm_action"]["osc_arm_action"]``
261+
- ``agent.policy`` with ``AgentConfigurables.agent["large_network"]``
262+
263+
allowing you to switch qualitative modes of your experiments with a single flag.

source/isaaclab_tasks/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
# Note: Semantic Versioning is used: https://semver.org/
4-
version = "0.10.36"
4+
version = "0.11.0"
55

66
# Description
77
title = "Isaac Lab Environments"

source/isaaclab_tasks/docs/CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
---------
33

4+
0.11.0 (2025-07-05)
5+
~~~~~~~~~~~~~~~~~~~~
6+
7+
Changed
8+
^^^^^^^
9+
10+
* Add new feature that support hydra group config override, and provide example at Isaac-Reach-Franka-v0 env
11+
12+
413
0.10.36 (2025-06-26)
514
~~~~~~~~~~~~~~~~~~~~
615

source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/reach/config/franka/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"rl_games_cfg_entry_point": f"{agents.__name__}:rl_games_ppo_cfg.yaml",
2525
"rsl_rl_cfg_entry_point": f"{agents.__name__}.rsl_rl_ppo_cfg:FrankaReachPPORunnerCfg",
2626
"skrl_cfg_entry_point": f"{agents.__name__}:skrl_ppo_cfg.yaml",
27+
"configurable_entry_point": f"{agents.__name__}.configurables:AgentConfigurables",
2728
},
2829
)
2930

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
from isaaclab.utils import configclass
7+
8+
from isaaclab_rl.rsl_rl import RslRlPpoActorCriticCfg, RslRlPpoAlgorithmCfg
9+
10+
from ..configurables import EnvConfigurables
11+
12+
13+
@configclass
14+
class AgentConfigurables(EnvConfigurables):
15+
agent: dict[str, any] = {
16+
"policy": {
17+
"large_network": RslRlPpoActorCriticCfg(
18+
init_noise_std=1.0,
19+
actor_hidden_dims=[512, 256, 128, 64],
20+
critic_hidden_dims=[512, 256, 128, 64],
21+
activation="elu",
22+
),
23+
"medium_network": RslRlPpoActorCriticCfg(
24+
init_noise_std=1.0,
25+
actor_hidden_dims=[256, 128, 64],
26+
critic_hidden_dims=[256, 128, 64],
27+
activation="elu",
28+
),
29+
"small_network": RslRlPpoActorCriticCfg(
30+
init_noise_std=1.0,
31+
actor_hidden_dims=[128, 64],
32+
critic_hidden_dims=[128, 64],
33+
activation="elu",
34+
),
35+
},
36+
"algorithm": {
37+
"standard": RslRlPpoAlgorithmCfg(
38+
value_loss_coef=1.0,
39+
use_clipped_value_loss=True,
40+
clip_param=0.2,
41+
entropy_coef=0.001,
42+
num_learning_epochs=8,
43+
num_mini_batches=4,
44+
learning_rate=1.0e-3,
45+
schedule="adaptive",
46+
gamma=0.99,
47+
lam=0.95,
48+
desired_kl=0.01,
49+
max_grad_norm=1.0,
50+
),
51+
"small_batch": RslRlPpoAlgorithmCfg(
52+
value_loss_coef=1.0,
53+
use_clipped_value_loss=True,
54+
clip_param=0.2,
55+
entropy_coef=0.001,
56+
num_learning_epochs=8,
57+
num_mini_batches=16,
58+
learning_rate=1.0e-4,
59+
schedule="adaptive",
60+
gamma=0.99,
61+
lam=0.95,
62+
desired_kl=0.01,
63+
max_grad_norm=1.0,
64+
),
65+
},
66+
}

0 commit comments

Comments
 (0)