Skip to content

Commit

Permalink
Fixes camera unittest by adding missing sim.step() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayankm96 committed Apr 17, 2024
1 parent 78692be commit 63f585f
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ def test_camera_init(self):
# Check if camera prim is set correctly and that it is a camera prim
self.assertEqual(camera._sensor_prims[0].GetPath().pathString, self.camera_cfg.prim_path)
self.assertIsInstance(camera._sensor_prims[0], UsdGeom.Camera)

# Simulate for a few steps
# note: This is a workaround to ensure that the textures are loaded.
# Check "Known Issues" section in the documentation for more details.
for _ in range(5):
self.sim.step()

# Check buffers that exists and have correct shapes
self.assertEqual(camera.data.pos_w.shape, (1, 3))
self.assertEqual(camera.data.quat_w_ros.shape, (1, 4))
Expand All @@ -111,6 +113,7 @@ def test_camera_init(self):
self.assertEqual(camera.data.intrinsic_matrices.shape, (1, 3, 3))
self.assertEqual(camera.data.image_shape, (self.camera_cfg.height, self.camera_cfg.width))
self.assertEqual(camera.data.info, [{self.camera_cfg.data_types[0]: None}])

# Simulate physics
for _ in range(10):
# perform rendering
Expand Down Expand Up @@ -184,6 +187,12 @@ def test_camera_init_offset(self):
rtol=1e-5,
)

# Simulate for a few steps
# note: This is a workaround to ensure that the textures are loaded.
# Check "Known Issues" section in the documentation for more details.
for _ in range(5):
self.sim.step()

# check if transform correctly set in output
np.testing.assert_allclose(camera_ros.data.pos_w[0].cpu().numpy(), cam_cfg_offset_ros.offset.pos, rtol=1e-5)
np.testing.assert_allclose(camera_ros.data.quat_w_ros[0].cpu().numpy(), QUAT_ROS, rtol=1e-5)
Expand Down

0 comments on commit 63f585f

Please sign in to comment.