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 option for default plane color to terrain importer #1791

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

KyleM73
Copy link
Contributor

@KyleM73 KyleM73 commented Feb 4, 2025

Description

The default plane configuration supports setting the plane color, but this option is not currently exposed via the terrain importer. This PR adds a ``color'' field to the terrain importer that is only used for configuring a plane.

Type of change

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

Screenshots

image image

Configuration:

terrain = TerrainImporterCfg(
            prim_path="/World/ground",
            terrain_type="plane",
            terrain_generator=None,
            max_init_terrain_level=None,
            collision_group=-1,
            physics_material=sim_utils.RigidBodyMaterialCfg(
                friction_combine_mode="multiply",
                restitution_combine_mode="multiply",
                static_friction=1.0,
                dynamic_friction=1.0,
            ),
            color=(1.0, 0.0, 0.0), # Red
            debug_vis=False,
        )

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 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

@KyleM73 KyleM73 requested a review from Mayankm96 as a code owner February 4, 2025 16:32
Copy link
Contributor

@Mayankm96 Mayankm96 left a comment

Choose a reason for hiding this comment

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

Alternate proposal: Maybe we can allow the passing of visual_material parameter instead to the ground plane? This provides more flexbility to change this plane to other texture materials.

To just change the color of the grid, perhaps we can use the diffuse_color of the default PbrMaterial.

This should avoid the need of yet another parameter and cover broader usecases

@KyleM73
Copy link
Contributor Author

KyleM73 commented Feb 12, 2025

I had thought of that but wasn't sure if the ground plane supported setting material types, I just saw the option for color. I can make it pick up the diffuse_color field of the visual material to avoid adding another option though. I'll revise and request review once updated.

@Mayankm96
Copy link
Contributor

That would be amazing! Thanks a lot :)

@KyleM73
Copy link
Contributor Author

KyleM73 commented Feb 13, 2025

Is there any desire to allow changing properties beyond the diffuse color? in spawn_ground_plane() the color is updated here:

# Change the color of the plane
    # Warning: This is specific to the default grid plane asset.
    if cfg.color is not None:
        prop_path = f"{prim_path}/Looks/theGrid/Shader.inputs:diffuse_tint"
        # change the color
        omni.kit.commands.execute(
            "ChangePropertyCommand",
            prop_path=Sdf.Path(prop_path),
            value=Gf.Vec3f(*cfg.color),
            prev=None,
            type_to_create_if_not_exist=Sdf.ValueTypeNames.Color3f,
        )

If so, is there documentation anywhere over the corresponding property paths in PreviewSurfaceCfg? Otherwise I'll push my changes in a moment to just pick up the color from the visual material config.

@KyleM73
Copy link
Contributor Author

KyleM73 commented Feb 13, 2025

Ok changes are pushed, the color for a plane can now be configured as follows:

terrain = TerrainImporterCfg(
        prim_path="/World/ground",
        terrain_type="plane",
        terrain_generator=None,
        collision_group=-1,
        physics_material=sim_utils.RigidBodyMaterialCfg(
            friction_combine_mode="multiply",
            restitution_combine_mode="multiply",
            static_friction=1.0,
            dynamic_friction=1.0,
        ),
        visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(1.0, 0.0, 0.0)), # red
        debug_vis=False,
    )

This allows changing the color of the ground plane but does not permit changing the material. If desired I could work on a PR expanding this to include e.g. setting Mdl file textures to the ground plane, but it would require some additional work in the ground plane spawner (and I would need some documentation on the corresponding property paths).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants