Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support to spawn different assets in environments and spawn randomizations #895

Closed
wants to merge 2 commits into from

Conversation

pascal-roth
Copy link
Collaborator

@pascal-roth pascal-roth commented Aug 28, 2024

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

  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • 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 pascal-roth added enhancement New feature or request dev team Issue or pull request created by the dev team labels Aug 28, 2024
@pascal-roth pascal-roth self-assigned this Aug 28, 2024
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these only work for multi_asset spawners? If it can be used by other spawners should we move them out to the spawners or sim directory for easier access?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should rather be at the same positions as the modifiers for the observations? Both concepts are very close to each other. @Mayankm96 @Dhoeller19 @jsmith-bdai any opinions?

Co-authored-by: jtigue-bdai <[email protected]>
Signed-off-by: Pascal Roth <[email protected]>
@pascal-roth
Copy link
Collaborator Author

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

@Mayankm96
Copy link
Contributor

@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 Mayankm96 marked this pull request as draft September 9, 2024 15:49
@Mayankm96
Copy link
Contributor

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.

@pascal-roth
Copy link
Collaborator Author

@Mayankm96 thanks for the feedback, will adjust it accordingly

@Mayankm96
Copy link
Contributor

Closing this MR in favor of #1164 and #1165

@Mayankm96 Mayankm96 closed this Oct 9, 2024
@Mayankm96 Mayankm96 deleted the feature/muti-asset-spawn branch October 9, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev team Issue or pull request created by the dev team enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants