-
Notifications
You must be signed in to change notification settings - Fork 920
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
Fixes outdated sensor data after reset #1276
base: main
Are you sure you want to change the base?
Changes from 5 commits
9b4816a
4bc79ea
995b8da
345ffd1
5ab1f0b
5c0c725
5e3ea01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -251,6 +251,8 @@ def reset(self, seed: int | None = None, options: dict[str, Any] | None = None) | |||
indices = torch.arange(self.num_envs, dtype=torch.int64, device=self.device) | ||||
self._reset_idx(indices) | ||||
|
||||
# update articulation kinematics | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be called after the event manager is called to reset transforms (so all the other managers also get this change)
|
||||
self.sim.update_fabric_and_kinematics() | ||||
# if sensors are added to the scene, make sure we render to reflect changes in reset | ||||
if self.sim.has_rtx_sensors() and self.cfg.rerender_on_reset: | ||||
self.sim.render() | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,6 +194,8 @@ def step(self, action: torch.Tensor) -> VecEnvStepReturn: | |
reset_env_ids = self.reset_buf.nonzero(as_tuple=False).squeeze(-1) | ||
if len(reset_env_ids) > 0: | ||
self._reset_idx(reset_env_ids) | ||
# update articulation kinematics | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as the manager based env. |
||
self.sim.update_fabric_and_kinematics() | ||
# if sensors are added to the scene, make sure we render to reflect changes in reset | ||
if self.sim.has_rtx_sensors() and self.cfg.rerender_on_reset: | ||
self.sim.render() | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -394,6 +394,14 @@ def get_setting(self, name: str) -> Any: | |||||
""" | ||||||
return self._settings.get(name) | ||||||
|
||||||
def update_fabric_and_kinematics(self) -> None: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering if we should go for a more canonical terminology. Many simulators distinguish between kinematic and dynamics stepping through different terms. For example, Mujoco calls forward kinematics function as Something like this is more user-friendly.
Suggested change
|
||||||
"""Updates articulation kinematics and fabric for rendering.""" | ||||||
if self._fabric_iface is not None: | ||||||
if self.physics_sim_view is not None and self.is_playing(): | ||||||
# Update the articulations' link's poses before rendering | ||||||
self.physics_sim_view.update_articulations_kinematic() | ||||||
self._update_fabric(0.0, 0.0) | ||||||
|
||||||
""" | ||||||
Operations - Override (standalone) | ||||||
""" | ||||||
|
@@ -464,11 +472,7 @@ def render(self, mode: RenderMode | None = None): | |||||
self.set_setting("/app/player/playSimulations", True) | ||||||
else: | ||||||
# manually flush the fabric data to update Hydra textures | ||||||
if self._fabric_iface is not None: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm this would break non env workflows where users didn't need to call a forward function. Maybe we add a flag on whether forward was called and in-case it wasn't, we do it implicitly? |
||||||
if self.physics_sim_view is not None and self.is_playing(): | ||||||
# Update the articulations' link's poses before rendering | ||||||
self.physics_sim_view.update_articulations_kinematic() | ||||||
self._update_fabric(0.0, 0.0) | ||||||
self.update_fabric_and_kinematics() | ||||||
# render the simulation | ||||||
# note: we don't call super().render() anymore because they do above operation inside | ||||||
# and we don't want to do it twice. We may remove it once we drop support for Isaac Sim 2022.2. | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a good practice to explain what was happening before this change was made. For instance, "Earlier, non-rendering sensors still used older transforms which corrupted the obtained readings."
This way it isn't just a change but also the motivation for the change that gets documented :)