Repository navigation
Conversation
32db208 to
d3b0605
Compare
|
I already spent a day trying to figure out multiple ways to initialize the event manager before the sim starts playing. The scene entity config resolution is impossible until physics parses the scene (since we need the PhysX body and joint ordering). It is rather unfortunate, but that's how it is right now. The functionality still works, so if it makes sense, we can move forward with it. |
Signed-off-by: Mayank Mittal <[email protected]>
|
@Mayankm96 thanks for the great work. wonder if you have plans to merge these functions into the main branch? |
|
|
||
| .. attention:: | ||
| Since this function modifies USD properties, it should only be used before the simulation starts | ||
| playing. This corresponds to the event mode named "spawn". Using it at simulation time, may lead to |
There was a problem hiding this comment.
should we add a check for simulation running and throw an error or warning if it's used while simulation is running?
| prim_spec = Sdf.CreatePrimInLayer(stage.GetRootLayer(), prim_paths[env_id]) | ||
|
|
||
| # get the attribute to randomize | ||
| scale_spec = prim_spec.GetAttributeAtPath(prim_paths[env_id] + ".xformOp:scale") |
There was a problem hiding this comment.
what happens if xformOp:scale is not on the prim?
| prim_spec = Sdf.CreatePrimInLayer(stage.GetRootLayer(), prim_paths[env_id]) | ||
|
|
||
| # get the attribute to randomize | ||
| color_spec = prim_spec.GetAttributeAtPath( |
There was a problem hiding this comment.
would it make sense to also support DisplayColor attribute? primitive shapes might not always have materials assigned.
There was a problem hiding this comment.
@kellyguo11 Quick question about the DisplayColor Attribute. In case the material was not assigned to the mesh, I tried to default to randomizing the color of the DisplayColor Attribute, however I was unable to access it through code or even manually through the GUI. It was grayed out even if no material was bounded. Any ideas about how to get around this?
There was a problem hiding this comment.
oh interesting, I was thinking of this attribute https://openusd.org/dev/api/class_usd_geom_gprim.html#a7fd86a311b27d9b4fdd82736bb423056, but maybe that has changed? do you see any other relevant attributes for updating color without using a material?
There was a problem hiding this comment.
I looked through all the available properties and can't seem to find one that's relevant outside the material. So my current code doesn't account for this, but if I come across anything I will be sure to update it. Thanks for the reply : )
| color_spec = prim_spec.GetAttributeAtPath( | ||
| prim_paths[env_id] + "/geometry/material/Shader.inputs:diffuseColor" | ||
| ) | ||
| color_spec.default = Gf.Vec3f(*rand_samples[i]) |
There was a problem hiding this comment.
maybe we can handle missing attributes more gracefully than just erroring out. I feel like printing a message and continuing might be more user friendly
jsmith-bdai
left a comment
There was a problem hiding this comment.
Overall, LGTM, but I think we can consolidate the apply_randomization method as it looks identical.
Also, would be good to add a unit test for this functionality
| self.scene = InteractiveScene(self.cfg.scene) | ||
| print("[INFO]: Scene manager: ", self.scene) | ||
|
|
||
| # randomization at scene level |
There was a problem hiding this comment.
Can you add a note here why this is needed here for future reference?
| applied_scene_randomization = False | ||
| # iterate over all event terms | ||
| for term_name, term_cfg in self.cfg.events.__dict__.items(): | ||
| # check for non config |
There was a problem hiding this comment.
| # check for non config | |
| # check for none config |
| Helper functions. | ||
| """ | ||
|
|
||
| def _apply_scene_randomization(self): |
There was a problem hiding this comment.
Can we make this a static helper method so that all 3 implementations can share it? It would need to take in an env of any of the three types and do the same operation on each
| unpredictable behaviors. | ||
|
|
||
| .. note:: | ||
| When randomizing the scale of individual assets, please make sure to set |
There was a problem hiding this comment.
Should we just throw an exception if replicate_physics is True here?
|
|
||
| - "startup": Event is applied once at the beginning of the training. | ||
| - "scene": Event is applied once after designing the scene. | ||
| - "startup": Event is applied once after the simulation starts playing. |
There was a problem hiding this comment.
Double check that this doesn't need to be updated in any tutorials or how-tos
| # check if sim is playing and resolve the entity | ||
| # joint and body names are only available once the sim is playing | ||
| # hence, we do not resolve the entity if the sim is not playing |
There was a problem hiding this comment.
When do the entities get resolved if the sim is not playing?
| print("[INFO]: Scene manager: ", self.scene) | ||
|
|
||
| # randomization at scene level | ||
| if not self.cfg.events: |
There was a problem hiding this comment.
@Mayankm96 can you explain the logic behind this statement. You have it present in direct_marl_env.py and direct_rl_env.py. but not in manager_based_env.py. The fucntion call to _apply_scene_randomization() is causing some tests because there is an attempted iteration on self.cfg.events of type None.
|
|
||
| This function randomizes the color of USD shapes created using :class:`omni.isaac.lab.sim.spawn.ShapeCfg` | ||
| class. It modifies the attribute: "geometry/material/Shader.inputs:diffuseColor" under the prims | ||
| corresponding to the asset. If the attribute does not exist, the function errors out. |
There was a problem hiding this comment.
hmm I'm still concerned that the assumption of "geometry/material/Shader.inputs:diffuseColor" will cause issues for users. It might not be obvious that they need to make sure there's a material defined for the prim and it has to be under this particular path. Would it make sense to automatically create a material if one doesn't exist instead of just erroring out?
# Description Certain scene-level randomizations (such as randomizing the scale) must happen before the simulation starts playing. To this end, the MR adds a new event mode called "prestartup," which gets called right after the scene design is complete and before the simulation is played. Since the scene entities cannot be resolved before the simulation starts playing (as we currently rely on PhysX to provide us with the joint/body ordering), the MR adds a callback to resolve the scene entity configurations separately once the simulation plays. This MR replaces the prior implementation in #1165 ## Type of change - New feature (non-breaking change which adds functionality) - This change requires a documentation update ## Screenshots If you execute: ```bash ./isaaclab.sh -p scripts/tutorials/03_envs/create_cube_base_env.py --num_envs 32 ``` Output:  ## 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 - [ ] 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 --------- Signed-off-by: Mayank Mittal <[email protected]> Co-authored-by: James Smith <[email protected]> Co-authored-by: Kelly Guo <[email protected]>
# Description Certain scene-level randomizations (such as randomizing the scale) must happen before the simulation starts playing. To this end, the MR adds a new event mode called "prestartup," which gets called right after the scene design is complete and before the simulation is played. Since the scene entities cannot be resolved before the simulation starts playing (as we currently rely on PhysX to provide us with the joint/body ordering), the MR adds a callback to resolve the scene entity configurations separately once the simulation plays. This MR replaces the prior implementation in #1165 ## Type of change - New feature (non-breaking change which adds functionality) - This change requires a documentation update ## Screenshots If you execute: ```bash ./isaaclab.sh -p scripts/tutorials/03_envs/create_cube_base_env.py --num_envs 32 ``` Output:  ## 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 - [ ] 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 --------- Signed-off-by: Mayank Mittal <[email protected]> Co-authored-by: James Smith <[email protected]> Co-authored-by: Kelly Guo <[email protected]>
# Description Certain scene-level randomizations (such as randomizing the scale) must happen before the simulation starts playing. To this end, the MR adds a new event mode called "prestartup," which gets called right after the scene design is complete and before the simulation is played. Since the scene entities cannot be resolved before the simulation starts playing (as we currently rely on PhysX to provide us with the joint/body ordering), the MR adds a callback to resolve the scene entity configurations separately once the simulation plays. This MR replaces the prior implementation in isaac-sim#1165 ## Type of change - New feature (non-breaking change which adds functionality) - This change requires a documentation update ## Screenshots If you execute: ```bash ./isaaclab.sh -p scripts/tutorials/03_envs/create_cube_base_env.py --num_envs 32 ``` Output:  ## 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 - [ ] 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 --------- Signed-off-by: Mayank Mittal <[email protected]> Co-authored-by: James Smith <[email protected]> Co-authored-by: Kelly Guo <[email protected]>
# Description Certain scene-level randomizations (such as randomizing the scale) must happen before the simulation starts playing. To this end, the MR adds a new event mode called "prestartup," which gets called right after the scene design is complete and before the simulation is played. Since the scene entities cannot be resolved before the simulation starts playing (as we currently rely on PhysX to provide us with the joint/body ordering), the MR adds a callback to resolve the scene entity configurations separately once the simulation plays. This MR replaces the prior implementation in isaac-sim#1165 ## Type of change - New feature (non-breaking change which adds functionality) - This change requires a documentation update ## Screenshots If you execute: ```bash ./isaaclab.sh -p scripts/tutorials/03_envs/create_cube_base_env.py --num_envs 32 ``` Output:  ## 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 - [ ] 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 --------- Signed-off-by: Mayank Mittal <[email protected]> Co-authored-by: James Smith <[email protected]> Co-authored-by: Kelly Guo <[email protected]>
Description
Certain scene-level randomizations (such as randomizing the scale) must happen before the simulation starts playing. To this end, the MR adds a new event mode called "scene," which gets called right after the scene design is complete.
Since the event manager CANNOT be initialized before the simulation starts playing, the current implementation hacks the event mode into the environment constructor directly. This is not ideal but at this point, there is no other way around it.
Type of change
Screenshots
If you execute:
Output:
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there