-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 reset of sensor drift inside the RayCaster sensor #1821
Conversation
@@ -110,7 +110,7 @@ def reset(self, env_ids: Sequence[int] | None = None): | |||
if env_ids is None: | |||
env_ids = slice(None) | |||
# resample the drift | |||
self.drift[env_ids].uniform_(*self.cfg.drift_range) | |||
self.drift[env_ids] = self.drift[env_ids].uniform_(*self.cfg.drift_range) |
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.
Is this required for uniform_
? I think that might be an inplace operation already.
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.
Thank you for being careful, I have checked again in my debugger
>self.drift[env_ids]
tensor([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
...,
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]], device='cuda:0')
>self.drift[env_ids].uniform_(*self.cfg.drift_range)
tensor([[-0.0657, 0.0741, -0.0464],
[-0.0895, 0.0378, 0.0849],
[ 0.0414, -0.0142, 0.0127],
...,
[ 0.0647, 0.0327, -0.0896],
[ 0.0268, -0.0399, -0.0197],
[ 0.0034, -0.0036, 0.0639]], device='cuda:0')
>self.drift[env_ids]
tensor([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
...,
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]], device='cuda:0')
as you see the self.drift is not updated after the uniform_ operation, though it returns a uniformly sampled values
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 do remember styles in pytorch where they use _ to indicate in place operation, it is indeed strange how it didn't work here. My torch version is 2.5.1+cu118
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.
The problem isn't with the in-place operation. Rther if you are indexing a torch tensor with explicit indices, it makes a "copy" of that tensor. So the original tensor isn't getting assigned but rather the copy of it.
Nice catch!
@kellyguo11 Comparing below two cases Case 1:
Case 2:
it seems like the advance indexing returns coped data instead of of original data's view, and |
Description
The drift in raycaster didn't update when reset. This MR now updates it correctly:
before:
now:
Fixes #1820
Type of change
Checklist
pre-commit
checks with./isaaclab.sh --format
config/extension.toml
fileCONTRIBUTORS.md
or my name already exists there