IsaacLab icon indicating copy to clipboard operation
IsaacLab copied to clipboard

Adds support to spawn different assets in environments and spawn randomizations

Open pascal-roth opened this issue 1 year ago • 2 comments

Description

This PR introduces the option to spawn multiple assets in the same environment (e.g. env_0 has a sphere and env_1 a cube). Originally developed by @renezurbruegg

It additionally introduces Spawn Randomizations which are applied when an asset is spawned. This allows to Randomize properties such as joint offsets and scales, which is otherwise not possible with only reset randomization.

Run ./isaaclab -p source/standalone/demos/multi_object.py or ./isaaclab -p source/standalone/demos/multi_object.py --randomize to see an example (Screenshot)

Example Configuration:

# Simple environment with a rigid object that can be a sphere or cube in different environments:

@configclass
class MultiObjectSceneCfg(InteractiveSceneCfg):
    """Configuration for a multi-object scene."""
    
    # ground plane
    ground = AssetBaseCfg(prim_path="/World/defaultGroundPlane", spawn=sim_utils.GroundPlaneCfg())

    object: RigidObjectCfg = RigidObjectCfg(
        prim_path="/World/envs/env_.*/Objects",
        spawn=MultiAssetCfg(assets_cfg=[
            sim_utils.SphereCfg(
                radius=0.25,
                visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 0.0, 1.0)),
                rigid_props=sim_utils.RigidBodyPropertiesCfg(),
            ),
            sim_utils.CuboidCfg(
                size=(0.25, 0.25, 0.25),
                visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 1.0, 0.0)),
                rigid_props=sim_utils.RigidBodyPropertiesCfg(),
            ),
        ]),
    )

Example Config to also Randomize Scales:

# Simple environment with a rigid object that can be a sphere or cube in different environments:
@configclass
class MultiObjectSceneCfg(InteractiveSceneCfg):
    """Configuration for a multi-object scene."""

    # ground plane
    ground = AssetBaseCfg(
        prim_path="/World/defaultGroundPlane", spawn=sim_utils.GroundPlaneCfg()
    )

    object: RigidObjectCfg = RigidObjectCfg(
        prim_path="/World/envs/env_.*/Objects",
        spawn=MultiAssetCfg(
            assets_cfg=[
                AssetRandomizerCfg(
                    child_spawner_cfg=sim_utils.SphereCfg(...),
                    randomization_cfg=RandomizeScaleCfg(
                        x_range=(0.5, 1.25),
                        equal_scale=True,
                    ),
                    num_random_assets=100,
                ),
                AssetRandomizerCfg(
                    child_spawner_cfg=sim_utils.CuboidCfg(...),
                    randomization_cfg=RandomizeScaleCfg(
                        x_range=(0.5, 1.25),
                        equal_scale=True,
                    ),
                    num_random_assets=100,
                ),
            ]
        ),
    )

Type of change

  • New feature (non-breaking change which adds functionality)

Screenshots

Example for different Assets ./isaaclab -p source/standalone/demos/multi_object.py image

Example for different Assets with scale randomizations ./isaaclab -p source/standalone/demos/multi_object.py --randomize image

./isaaclab -p source/standalone/demos/multi_object.py

Please attach before and after screenshots of the change if applicable.

Checklist

  • [x] I have run the pre-commit checks with ./isaaclab.sh --format
  • [x] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have run all the tests with ./isaaclab.sh --test and they pass
  • [ ] I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • [ ] I have added my name to the CONTRIBUTORS.md or my name already exists there

pascal-roth avatar Aug 28 '24 16:08 pascal-roth

@Mayankm96 @Dhoeller19 @jsmith-bdai ping again about that PR and the discussion above

pascal-roth avatar Sep 06 '24 14:09 pascal-roth

@pascal-roth We'll look at this for the next release. Our hands are packed with more pressing tasks for the current release. Thanks for the effort on this!

Mayankm96 avatar Sep 06 '24 16:09 Mayankm96

Okay so I went over this MR and it seems to be mixing two different notions IMO:

  1. Spawning different assets at different prim paths
  2. Randomizing the asset properties

I think these two can be separated out as two concepts since randomizing asset properties is independent of how you spawn it.

After doing some more testing on my side, we can simplify Step 1 more. I made an MR #1164 in that direction. Would love to hear your thoughts.

For Step 2, I propose that we should make a new mode in the event manager. It will come at some cost over repeated for loops, but the code simplification is worth it, in my opinion.

Mayankm96 avatar Oct 06 '24 18:10 Mayankm96

@Mayankm96 thanks for the feedback, will adjust it accordingly

pascal-roth avatar Oct 07 '24 08:10 pascal-roth

Closing this MR in favor of #1164 and #1165

Mayankm96 avatar Oct 09 '24 10:10 Mayankm96