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

Fixes outdated sensor data after reset #1276

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

Conversation

kellyguo11
Copy link
Contributor

Description

This change adds a call to update_articulations_kinematic() after performing reset in an environment to ensure that non-render sensors are updated after performing reset.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

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

Signed-off-by: Kelly Guo <[email protected]>
Signed-off-by: Kelly Guo <[email protected]>
Signed-off-by: Kelly Guo <[email protected]>
Signed-off-by: Kelly Guo <[email protected]>
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The 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.event_manager.apply(mode="reset", env_ids=env_ids, global_env_step_count=env_step_count)

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as the manager based env.

@@ -394,6 +394,14 @@ def get_setting(self, name: str) -> Any:
"""
return self._settings.get(name)

def update_fabric_and_kinematics(self) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The 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 forward and the simulation step as simulate.

Something like this is more user-friendly.

Suggested change
def update_fabric_and_kinematics(self) -> None:
def forward(self) -> None:

Changed
^^^^^^^

* Added call to update articulation kinematics after reset to ensure updated states in non-rendering sensors.
Copy link
Contributor

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

@Mayankm96
Copy link
Contributor

Mayankm96 commented Oct 21, 2024

From an understanding standpoint, if a user sets robot state for articulation, isn't the base pose also updated in non-rendering sensors because the "views" capture the same memory. What does the update fabric do? 👀

Also can we have some sort of test to make sure this behavior is always verified (for sensors)?

@@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

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

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