Commit 63f585fc authored by Mayank Mittal's avatar Mayank Mittal

Fixes camera unittest by adding missing sim.step() calls

parent 78692be5
...@@ -98,11 +98,13 @@ class TestCamera(unittest.TestCase): ...@@ -98,11 +98,13 @@ class TestCamera(unittest.TestCase):
# Check if camera prim is set correctly and that it is a camera prim # 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.assertEqual(camera._sensor_prims[0].GetPath().pathString, self.camera_cfg.prim_path)
self.assertIsInstance(camera._sensor_prims[0], UsdGeom.Camera) self.assertIsInstance(camera._sensor_prims[0], UsdGeom.Camera)
# Simulate for a few steps # Simulate for a few steps
# note: This is a workaround to ensure that the textures are loaded. # note: This is a workaround to ensure that the textures are loaded.
# Check "Known Issues" section in the documentation for more details. # Check "Known Issues" section in the documentation for more details.
for _ in range(5): for _ in range(5):
self.sim.step() self.sim.step()
# Check buffers that exists and have correct shapes # Check buffers that exists and have correct shapes
self.assertEqual(camera.data.pos_w.shape, (1, 3)) self.assertEqual(camera.data.pos_w.shape, (1, 3))
self.assertEqual(camera.data.quat_w_ros.shape, (1, 4)) self.assertEqual(camera.data.quat_w_ros.shape, (1, 4))
...@@ -111,6 +113,7 @@ class TestCamera(unittest.TestCase): ...@@ -111,6 +113,7 @@ class TestCamera(unittest.TestCase):
self.assertEqual(camera.data.intrinsic_matrices.shape, (1, 3, 3)) 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.image_shape, (self.camera_cfg.height, self.camera_cfg.width))
self.assertEqual(camera.data.info, [{self.camera_cfg.data_types[0]: None}]) self.assertEqual(camera.data.info, [{self.camera_cfg.data_types[0]: None}])
# Simulate physics # Simulate physics
for _ in range(10): for _ in range(10):
# perform rendering # perform rendering
...@@ -184,6 +187,12 @@ class TestCamera(unittest.TestCase): ...@@ -184,6 +187,12 @@ class TestCamera(unittest.TestCase):
rtol=1e-5, 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 # 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.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) np.testing.assert_allclose(camera_ros.data.quat_w_ros[0].cpu().numpy(), QUAT_ROS, rtol=1e-5)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment