Skip to content

Commit 3dfcf3d

Browse files
kellyguo11AntoineRichardgreptile-apps[bot]
authored
Fixes failing tests from torch to warp updates (#4617)
# Description Fixes some more failing tests that were introduced in #4551 ## Type of change <!-- As you go through the list, delete the ones that are not applicable. --> - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [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 - [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there <!-- As you go through the checklist above, you can mark something as done by putting an x character in it For example, - [x] I have done this task - [ ] I have not done this task --> --------- Signed-off-by: Antoine RICHARD <antoiner@nvidia.com> Co-authored-by: Antoine Richard <antoiner@nvidia.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent 2e5cb25 commit 3dfcf3d

File tree

14 files changed

+320
-185
lines changed

14 files changed

+320
-185
lines changed

source/isaaclab/isaaclab/test/mock_interfaces/assets/mock_articulation.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def default_root_pose(self) -> wp.array:
163163
if self._default_root_pose is None:
164164
pose_np = np.zeros((self._num_instances, 7), dtype=np.float32)
165165
pose_np[..., 6] = 1.0 # identity quat qw=1, transformf layout: (px,py,pz,qx,qy,qz,qw)
166-
return wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
166+
self._default_root_pose = wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
167167
return self._default_root_pose
168168

169169
@property
@@ -355,7 +355,7 @@ def root_link_pose_w(self) -> wp.array:
355355
if self._root_link_pose_w is None:
356356
pose_np = np.zeros((self._num_instances, 7), dtype=np.float32)
357357
pose_np[..., 6] = 1.0 # identity quat qw=1, transformf layout: (px,py,pz,qx,qy,qz,qw)
358-
return wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
358+
self._root_link_pose_w = wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
359359
return self._root_link_pose_w
360360

361361
@property
@@ -381,7 +381,7 @@ def root_link_pos_w(self) -> wp.array:
381381

382382
@property
383383
def root_link_quat_w(self) -> wp.array:
384-
"""Root link orientation in world frame. Shape: (N,), dtype=wp.quatf."""
384+
"""Root link orientation in world frame (x, y, z, w). Shape: (N,), dtype=wp.quatf."""
385385
t = self.root_link_pose_w
386386
return wp.array(ptr=t.ptr + 3 * 4, shape=t.shape, dtype=wp.quatf, strides=t.strides, device=self.device)
387387

@@ -456,7 +456,7 @@ def body_link_pose_w(self) -> wp.array:
456456
if self._body_link_pose_w is None:
457457
pose_np = np.zeros((self._num_instances, self._num_bodies, 7), dtype=np.float32)
458458
pose_np[..., 6] = 1.0 # identity quat qw=1, transformf layout: (px,py,pz,qx,qy,qz,qw)
459-
return wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
459+
self._body_link_pose_w = wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
460460
return self._body_link_pose_w
461461

462462
@property
@@ -489,12 +489,14 @@ def body_link_quat_w(self) -> wp.array:
489489
@property
490490
def body_link_lin_vel_w(self) -> wp.array:
491491
"""Body link linear velocities in world frame. Shape: (N, num_bodies, 3)."""
492-
return self.body_link_vel_w[..., :3]
492+
vel_torch = wp.to_torch(self.body_link_vel_w)
493+
return wp.from_torch(vel_torch[..., :3].contiguous())
493494

494495
@property
495496
def body_link_ang_vel_w(self) -> wp.array:
496497
"""Body link angular velocities in world frame. Shape: (N, num_bodies, 3)."""
497-
return self.body_link_vel_w[..., 3:6]
498+
vel_torch = wp.to_torch(self.body_link_vel_w)
499+
return wp.from_torch(vel_torch[..., 3:6].contiguous())
498500

499501
# -- Body state properties (CoM frame) --
500502

@@ -539,7 +541,7 @@ def body_com_pose_b(self) -> wp.array:
539541
if self._body_com_pose_b is None:
540542
pose_np = np.zeros((self._num_instances, self._num_bodies, 7), dtype=np.float32)
541543
pose_np[..., 6] = 1.0 # identity quat qw=1, transformf layout: (px,py,pz,qx,qy,qz,qw)
542-
return wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
544+
self._body_com_pose_b = wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
543545
return self._body_com_pose_b
544546

545547
# Sliced properties (zero-copy pointer arithmetic on transformf)
@@ -558,22 +560,26 @@ def body_com_quat_w(self) -> wp.array:
558560
@property
559561
def body_com_lin_vel_w(self) -> wp.array:
560562
"""Body CoM linear velocities in world frame. Shape: (N, num_bodies, 3)."""
561-
return self.body_com_vel_w[..., :3]
563+
vel_torch = wp.to_torch(self.body_com_vel_w)
564+
return wp.from_torch(vel_torch[..., :3].contiguous())
562565

563566
@property
564567
def body_com_ang_vel_w(self) -> wp.array:
565568
"""Body CoM angular velocities in world frame. Shape: (N, num_bodies, 3)."""
566-
return self.body_com_vel_w[..., 3:6]
569+
vel_torch = wp.to_torch(self.body_com_vel_w)
570+
return wp.from_torch(vel_torch[..., 3:6].contiguous())
567571

568572
@property
569573
def body_com_lin_acc_w(self) -> wp.array:
570574
"""Body CoM linear accelerations in world frame. Shape: (N, num_bodies, 3)."""
571-
return self.body_com_acc_w[..., :3]
575+
acc_torch = wp.to_torch(self.body_com_acc_w)
576+
return wp.from_torch(acc_torch[..., :3].contiguous())
572577

573578
@property
574579
def body_com_ang_acc_w(self) -> wp.array:
575580
"""Body CoM angular accelerations in world frame. Shape: (N, num_bodies, 3)."""
576-
return self.body_com_acc_w[..., 3:6]
581+
acc_torch = wp.to_torch(self.body_com_acc_w)
582+
return wp.from_torch(acc_torch[..., 3:6].contiguous())
577583

578584
@property
579585
def body_com_pos_b(self) -> wp.array:
@@ -649,6 +655,16 @@ def root_com_ang_vel_b(self) -> wp.array:
649655
"""Root CoM angular velocity in body frame. Shape: (N, 3)."""
650656
return wp.clone(self.root_com_ang_vel_w, self.device)
651657

658+
@property
659+
def com_pos_b(self) -> wp.array:
660+
"""Convenience alias for root_com_pos_w. Shape: (N, 3)."""
661+
return wp.clone(self.root_com_pos_w, self.device)
662+
663+
@property
664+
def com_quat_b(self) -> wp.array:
665+
"""Convenience alias for root_com_quat_w. Shape: (N, 4)."""
666+
return wp.clone(self.root_com_quat_w, self.device)
667+
652668
# -- Fixed tendon properties --
653669

654670
@property

source/isaaclab/isaaclab/test/mock_interfaces/assets/mock_rigid_object.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def default_root_pose(self) -> wp.array:
9797
if self._default_root_pose is None:
9898
pose_np = np.zeros((self._num_instances, 7), dtype=np.float32)
9999
pose_np[..., 6] = 1.0 # identity quat qw=1, transformf layout: (px,py,pz,qx,qy,qz,qw)
100-
return wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
100+
self._default_root_pose = wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
101101
return self._default_root_pose
102102

103103
@property
@@ -122,7 +122,7 @@ def root_link_pose_w(self) -> wp.array:
122122
if self._root_link_pose_w is None:
123123
pose_np = np.zeros((self._num_instances, 7), dtype=np.float32)
124124
pose_np[..., 6] = 1.0 # identity quat qw=1, transformf layout: (px,py,pz,qx,qy,qz,qw)
125-
return wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
125+
self._root_link_pose_w = wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
126126
return self._root_link_pose_w
127127

128128
@property
@@ -146,6 +146,7 @@ def root_link_pos_w(self) -> wp.array:
146146
t = self.root_link_pose_w
147147
return wp.array(ptr=t.ptr, shape=t.shape, dtype=wp.vec3f, strides=t.strides, device=self.device)
148148

149+
# Sliced properties (convert through torch for simplicity in mock)
149150
@property
150151
def root_link_quat_w(self) -> wp.array:
151152
"""Root link orientation. Shape: (N,), dtype=wp.quatf."""
@@ -199,6 +200,7 @@ def root_com_pos_w(self) -> wp.array:
199200
t = self.root_com_pose_w
200201
return wp.array(ptr=t.ptr, shape=t.shape, dtype=wp.vec3f, strides=t.strides, device=self.device)
201202

203+
# Sliced properties (convert through torch for simplicity in mock)
202204
@property
203205
def root_com_quat_w(self) -> wp.array:
204206
"""Root CoM orientation. Shape: (N,), dtype=wp.quatf."""
@@ -223,7 +225,7 @@ def body_link_pose_w(self) -> wp.array:
223225
if self._body_link_pose_w is None:
224226
pose_np = np.zeros((self._num_instances, 1, 7), dtype=np.float32)
225227
pose_np[..., 6] = 1.0 # identity quat qw=1, transformf layout: (px,py,pz,qx,qy,qz,qw)
226-
return wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
228+
self._body_link_pose_w = wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
227229
return self._body_link_pose_w
228230

229231
@property
@@ -247,6 +249,7 @@ def body_link_pos_w(self) -> wp.array:
247249
t = self.body_link_pose_w
248250
return wp.array(ptr=t.ptr, shape=t.shape, dtype=wp.vec3f, strides=t.strides, device=self.device)
249251

252+
# Sliced properties (convert through torch for simplicity in mock)
250253
@property
251254
def body_link_quat_w(self) -> wp.array:
252255
"""Body link orientation. Shape: (N, 1), dtype=wp.quatf."""
@@ -256,12 +259,14 @@ def body_link_quat_w(self) -> wp.array:
256259
@property
257260
def body_link_lin_vel_w(self) -> wp.array:
258261
"""Body link linear velocity. Shape: (N, 1, 3)."""
259-
return self.body_link_vel_w[..., :3]
262+
vel_torch = wp.to_torch(self.body_link_vel_w)
263+
return wp.from_torch(vel_torch[..., :3].contiguous())
260264

261265
@property
262266
def body_link_ang_vel_w(self) -> wp.array:
263267
"""Body link angular velocity. Shape: (N, 1, 3)."""
264-
return self.body_link_vel_w[..., 3:6]
268+
vel_torch = wp.to_torch(self.body_link_vel_w)
269+
return wp.from_torch(vel_torch[..., 3:6].contiguous())
265270

266271
# -- Body state properties (CoM frame) --
267272

@@ -306,7 +311,7 @@ def body_com_pose_b(self) -> wp.array:
306311
if self._body_com_pose_b is None:
307312
pose_np = np.zeros((self._num_instances, 1, 7), dtype=np.float32)
308313
pose_np[..., 6] = 1.0 # identity quat qw=1, transformf layout: (px,py,pz,qx,qy,qz,qw)
309-
return wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
314+
self._body_com_pose_b = wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
310315
return self._body_com_pose_b
311316

312317
# Sliced properties (zero-copy pointer arithmetic on transformf)
@@ -325,22 +330,26 @@ def body_com_quat_w(self) -> wp.array:
325330
@property
326331
def body_com_lin_vel_w(self) -> wp.array:
327332
"""Body CoM linear velocity. Shape: (N, 1, 3)."""
328-
return self.body_com_vel_w[..., :3]
333+
vel_torch = wp.to_torch(self.body_com_vel_w)
334+
return wp.from_torch(vel_torch[..., :3].contiguous())
329335

330336
@property
331337
def body_com_ang_vel_w(self) -> wp.array:
332338
"""Body CoM angular velocity. Shape: (N, 1, 3)."""
333-
return self.body_com_vel_w[..., 3:6]
339+
vel_torch = wp.to_torch(self.body_com_vel_w)
340+
return wp.from_torch(vel_torch[..., 3:6].contiguous())
334341

335342
@property
336343
def body_com_lin_acc_w(self) -> wp.array:
337344
"""Body CoM linear acceleration. Shape: (N, 1, 3)."""
338-
return self.body_com_acc_w[..., :3]
345+
acc_torch = wp.to_torch(self.body_com_acc_w)
346+
return wp.from_torch(acc_torch[..., :3].contiguous())
339347

340348
@property
341349
def body_com_ang_acc_w(self) -> wp.array:
342350
"""Body CoM angular acceleration. Shape: (N, 1, 3)."""
343-
return self.body_com_acc_w[..., 3:6]
351+
acc_torch = wp.to_torch(self.body_com_acc_w)
352+
return wp.from_torch(acc_torch[..., 3:6].contiguous())
344353

345354
@property
346355
def body_com_pos_b(self) -> wp.array:
@@ -409,6 +418,17 @@ def root_com_ang_vel_b(self) -> wp.array:
409418
return wp.clone(self.root_com_ang_vel_w, self.device)
410419

411420
# -- Shorthand properties (root_pose_w, body_pos_w, com_pos_b, etc.) --
421+
422+
@property
423+
def com_pos_b(self) -> wp.array:
424+
"""Convenience alias for root_com_pos_w. Shape: (N, 3)."""
425+
return wp.clone(self.root_com_pos_w, self.device)
426+
427+
@property
428+
def com_quat_b(self) -> wp.array:
429+
"""Convenience alias for root_com_quat_w. Shape: (N, 4)."""
430+
return wp.clone(self.root_com_quat_w, self.device)
431+
412432
# Inherited from BaseRigidObjectData
413433

414434
# -- Deprecated properties (default_mass, default_inertia) --

source/isaaclab/isaaclab/test/mock_interfaces/assets/mock_rigid_object_collection.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def body_link_pose_w(self) -> wp.array:
121121
if self._body_link_pose_w is None:
122122
pose_np = np.zeros((self._num_instances, self._num_bodies, 7), dtype=np.float32)
123123
pose_np[..., 6] = 1.0 # identity quat qw=1, transformf layout: (px,py,pz,qx,qy,qz,qw)
124-
return wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
124+
self._body_link_pose_w = wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
125125
return self._body_link_pose_w
126126

127127
@property
@@ -145,6 +145,7 @@ def body_link_pos_w(self) -> wp.array:
145145
t = self.body_link_pose_w
146146
return wp.array(ptr=t.ptr, shape=t.shape, dtype=wp.vec3f, strides=t.strides, device=self.device)
147147

148+
# Sliced properties (convert through torch for simplicity in mock)
148149
@property
149150
def body_link_quat_w(self) -> wp.array:
150151
"""Body link orientations. Shape: (N, num_bodies), dtype=wp.quatf."""
@@ -154,12 +155,14 @@ def body_link_quat_w(self) -> wp.array:
154155
@property
155156
def body_link_lin_vel_w(self) -> wp.array:
156157
"""Body link linear velocities. Shape: (N, num_bodies, 3)."""
157-
return self.body_link_vel_w[..., :3]
158+
vel_torch = wp.to_torch(self.body_link_vel_w)
159+
return wp.from_torch(vel_torch[..., :3].contiguous())
158160

159161
@property
160162
def body_link_ang_vel_w(self) -> wp.array:
161163
"""Body link angular velocities. Shape: (N, num_bodies, 3)."""
162-
return self.body_link_vel_w[..., 3:6]
164+
vel_torch = wp.to_torch(self.body_link_vel_w)
165+
return wp.from_torch(vel_torch[..., 3:6].contiguous())
163166

164167
# -- Body state properties (CoM frame) --
165168

@@ -197,7 +200,7 @@ def body_com_pose_b(self) -> wp.array:
197200
if self._body_com_pose_b is None:
198201
pose_np = np.zeros((self._num_instances, self._num_bodies, 7), dtype=np.float32)
199202
pose_np[..., 6] = 1.0 # identity quat qw=1, transformf layout: (px,py,pz,qx,qy,qz,qw)
200-
return wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
203+
self._body_com_pose_b = wp.array(pose_np, dtype=wp.float32, device=self.device).view(wp.transformf)
201204
return self._body_com_pose_b
202205

203206
# Sliced properties (zero-copy pointer arithmetic on transformf)
@@ -216,22 +219,26 @@ def body_com_quat_w(self) -> wp.array:
216219
@property
217220
def body_com_lin_vel_w(self) -> wp.array:
218221
"""Body CoM linear velocities. Shape: (N, num_bodies, 3)."""
219-
return self.body_com_vel_w[..., :3]
222+
vel_torch = wp.to_torch(self.body_com_vel_w)
223+
return wp.from_torch(vel_torch[..., :3].contiguous())
220224

221225
@property
222226
def body_com_ang_vel_w(self) -> wp.array:
223227
"""Body CoM angular velocities. Shape: (N, num_bodies, 3)."""
224-
return self.body_com_vel_w[..., 3:6]
228+
vel_torch = wp.to_torch(self.body_com_vel_w)
229+
return wp.from_torch(vel_torch[..., 3:6].contiguous())
225230

226231
@property
227232
def body_com_lin_acc_w(self) -> wp.array:
228233
"""Body CoM linear accelerations. Shape: (N, num_bodies, 3)."""
229-
return self.body_com_acc_w[..., :3]
234+
acc_torch = wp.to_torch(self.body_com_acc_w)
235+
return wp.from_torch(acc_torch[..., :3].contiguous())
230236

231237
@property
232238
def body_com_ang_acc_w(self) -> wp.array:
233239
"""Body CoM angular accelerations. Shape: (N, num_bodies, 3)."""
234-
return self.body_com_acc_w[..., 3:6]
240+
acc_torch = wp.to_torch(self.body_com_acc_w)
241+
return wp.from_torch(acc_torch[..., 3:6].contiguous())
235242

236243
@property
237244
def body_com_pos_b(self) -> wp.array:

source/isaaclab/isaaclab/test/mock_interfaces/sensors/mock_contact_sensor.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(
6464
self._net_forces_w: wp.array | None = None
6565
self._net_forces_w_history: wp.array | None = None
6666
self._force_matrix_w: wp.array | None = None
67-
self._force_matrix_w_history: wp.array | None = None
67+
self._force_matrix_w_history: torch.Tensor | None = None # 5D, exceeds warp's 4D limit
6868
self._contact_pos_w: wp.array | None = None
6969
self._friction_forces_w: wp.array | None = None
7070
self._last_air_time: wp.array | None = None
@@ -133,14 +133,17 @@ def force_matrix_w(self) -> wp.array | None:
133133
return self._force_matrix_w
134134

135135
@property
136-
def force_matrix_w_history(self) -> wp.array | None:
137-
"""History of filtered forces. Shape: (N, T, B, M, 3)."""
136+
def force_matrix_w_history(self) -> torch.Tensor | None:
137+
"""History of filtered forces. Shape: (N, T, B, M, 3).
138+
139+
Note: Returns torch.Tensor instead of wp.array due to 5D shape limitation in warp (max 4D).
140+
"""
138141
if self._history_length == 0 or self._num_filter_bodies == 0:
139142
return None
140143
if self._force_matrix_w_history is None:
141-
return wp.zeros(
142-
shape=(self._num_instances, self._history_length, self._num_bodies, self._num_filter_bodies, 3),
143-
dtype=wp.float32,
144+
return torch.zeros(
145+
(self._num_instances, self._history_length, self._num_bodies, self._num_filter_bodies, 3),
146+
dtype=torch.float32,
144147
device=self.device,
145148
)
146149
return self._force_matrix_w_history
@@ -222,8 +225,11 @@ def set_force_matrix_w(self, value: torch.Tensor) -> None:
222225
self._force_matrix_w = wp.from_torch(value.to(self.device).contiguous(), dtype=wp.float32)
223226

224227
def set_force_matrix_w_history(self, value: torch.Tensor) -> None:
225-
"""Set filtered forces history."""
226-
self._force_matrix_w_history = wp.from_torch(value.to(self.device).contiguous(), dtype=wp.float32)
228+
"""Set filtered forces history.
229+
230+
Note: Stores as torch.Tensor instead of wp.array due to 5D shape limitation in warp (max 4D).
231+
"""
232+
self._force_matrix_w_history = value.to(self.device).contiguous()
227233

228234
def set_contact_pos_w(self, value: torch.Tensor) -> None:
229235
"""Set contact point positions."""

source/isaaclab/isaaclab/test/mock_interfaces/sensors/mock_imu.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ def pos_w(self) -> wp.array:
6464

6565
@property
6666
def quat_w(self) -> wp.array:
67-
"""Orientation (w, x, y, z) in world frame. Shape: (N, 4)."""
67+
"""Orientation (x, y, z, w) in world frame. Shape: (N, 4)."""
6868
if self._quat_w is None:
69-
# Default to identity quaternion (w, x, y, z) = (1, 0, 0, 0)
69+
# Default to identity quaternion (x, y, z, w) = (0, 0, 0, 1)
7070
quat_np = np.zeros((self._num_instances, 4), dtype=np.float32)
71-
quat_np[:, 0] = 1.0
71+
quat_np[:, 3] = 1.0 # w component is at index 3 in XYZW format
7272
return wp.array(quat_np, dtype=wp.float32, device=self.device)
7373
return self._quat_w
7474

@@ -162,7 +162,7 @@ def set_mock_data(
162162
163163
Args:
164164
pos_w: Position in world frame. Shape: (N, 3).
165-
quat_w: Orientation (w, x, y, z) in world frame. Shape: (N, 4).
165+
quat_w: Orientation (x, y, z, w) in world frame. Shape: (N, 4).
166166
projected_gravity_b: Gravity direction in body frame. Shape: (N, 3).
167167
lin_vel_b: Linear velocity in body frame. Shape: (N, 3).
168168
ang_vel_b: Angular velocity in body frame. Shape: (N, 3).

0 commit comments

Comments
 (0)