Unverified Commit e4a852eb authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Adds replicator event for randomizing colors (#2153)

# Description

This MR adds a replicator event to randomize the color of meshes on an
asset. Currently, this supports only a single mesh.

## Type of change

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

## Screenshots

```bash
python scripts/tutorials/03_envs/create_cube_base_env.py
```


![image](https://github.com/user-attachments/assets/b525b858-bb2d-4f52-a7a8-d65703b2553d)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] 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
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
parent 324bb8c3
...@@ -192,7 +192,7 @@ class MySceneCfg(InteractiveSceneCfg): ...@@ -192,7 +192,7 @@ class MySceneCfg(InteractiveSceneCfg):
# lights # lights
light = AssetBaseCfg( light = AssetBaseCfg(
prim_path="/World/light", prim_path="/World/light",
spawn=sim_utils.DistantLightCfg(color=(0.75, 0.75, 0.75), intensity=3000.0), spawn=sim_utils.DomeLightCfg(color=(0.75, 0.75, 0.75), intensity=2000.0),
) )
...@@ -261,6 +261,20 @@ class EventCfg: ...@@ -261,6 +261,20 @@ class EventCfg:
}, },
) )
# This event term randomizes the visual color of the cube.
# Similar to the scale randomization, this is also a USD-level randomization and requires the flag
# 'replicate_physics' to be set to False.
randomize_color = EventTerm(
func=mdp.randomize_visual_color,
mode="prestartup",
params={
"colors": {"r": (0.0, 1.0), "g": (0.0, 1.0), "b": (0.0, 1.0)},
"asset_cfg": SceneEntityCfg("cube"),
"mesh_name": "geometry/mesh",
"event_name": "rep_cube_randomize_color",
},
)
## ##
# Environment configuration # Environment configuration
...@@ -290,6 +304,9 @@ class CubeEnvCfg(ManagerBasedEnvCfg): ...@@ -290,6 +304,9 @@ class CubeEnvCfg(ManagerBasedEnvCfg):
self.sim.dt = 0.01 self.sim.dt = 0.01
self.sim.physics_material = self.scene.terrain.physics_material self.sim.physics_material = self.scene.terrain.physics_material
self.sim.render_interval = 2 # render interval should be a multiple of decimation self.sim.render_interval = 2 # render interval should be a multiple of decimation
# viewer settings
self.viewer.eye = (5.0, 5.0, 5.0)
self.viewer.lookat = (0.0, 0.0, 2.0)
def main(): def main():
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment