Passing non asset arguments to InteractiveSceneCfg #2896
-
Hi all, I'm trying to dynamically generate scenes by passing arguments like However, the Example Code: from isaaclab.utils.configclass import configclass
from isaaclab.scene import InteractiveScene, InteractiveSceneCfg
@configclass
class MyDynamicSceneCfg(InteractiveSceneCfg):
# This helper variable causes the error
num_objects: int = 10
def __post_init__(self):
super().__post_init__()
# Logic to generate `num_objects` assets would go here...
pass Is this the wrong way to use the configclass? A suggestion would be to have a meta_data variable that gets ignored by the InteractiveScene parser. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Thank you for posting this. The issue you're facing—where adding a helper variable like num_objects to your InteractiveSceneCfg causes a ValueError from the InteractiveScene parser—is due to how Isaac Lab's InteractiveScene and configclass system expect configuration classes to operate. Every field in your configclass, unless handled specially, is interpreted as an asset or entity to instantiate in the scene. This is by design so that all configuration data relevant for scene instantiation is exposed and serializable, supporting vectorization and easy Hydra/CLI overrides.123 Why the Error Occurs
Possible Workarounds1. Use “meta_data” or "_helper" Prefix and Skip LogicThere isn’t an officially documented, built-in
2. Storing Helper Data in a Dict/Property (Recommended)The best-documented pattern is to avoid adding plain ints/floats/lists as typed fields on your InteractiveSceneCfg. Instead:
3. Only Use Annotated Fields for Scene EntitiesReview the official [scene creation tutorial] and API docs: every field of the configclass scene config should be a scene entity or a proper config setting (num_envs, env_spacing, etc.). Helper variables should not be fields.32 Example: Safe Patternfrom isaaclab.utils.configclass import configclass
from isaaclab.scene import InteractiveScene, InteractiveSceneCfg
@configclass
class MyDynamicSceneCfg(InteractiveSceneCfg):
# Only config fields for actual scene assets/entities!
pass
def make_dynamic_scene_cfg(num_objects):
cfg = MyDynamicSceneCfg()
# Now, in __post_init__ or after construction, use num_objects to mutate cfg
# Or append objects programmatically here instead of declaring num_objects as a field
for i in range(num_objects):
# Dynamically add assets with unique names
setattr(cfg, f"dyn_asset_{i}", ...config for asset...)
return cfg Or, if you want to store meta info: @configclass
class MyDynamicSceneCfg(InteractiveSceneCfg):
# Only scene assets/entities here
def __post_init__(self):
super().__post_init__()
self._meta_data = {"num_objects": 10}
# Use self._meta_data['num_objects'] internally, but do not declare as field Footnotes |
Beta Was this translation helpful? Give feedback.
Thank you for posting this. The issue you're facing—where adding a helper variable like num_objects to your InteractiveSceneCfg causes a ValueError from the InteractiveScene parser—is due to how Isaac Lab's InteractiveScene and configclass system expect configuration classes to operate. Every field in your configclass, unless handled specially, is interpreted as an asset or entity to instantiate in the scene. This is by design so that all configuration data relevant for scene instantiation is exposed and serializable, supporting vectorization and easy Hydra/CLI overrides.123
Why the Error Occurs
num_objects: int
to your scene config, the parser walks through each attribute o…