From 98ef885835c912a5a3d17eadce7594d97f0cf903 Mon Sep 17 00:00:00 2001 From: Nicola Loi Date: Mon, 30 Dec 2024 11:56:47 +0100 Subject: [PATCH] Respawn only wrong object samples in repeated_objects_terrain - speed-up the terrain generation and fixes an infinite respawn loop if the object density is large. --- CONTRIBUTORS.md | 1 + .../omni.isaac.lab/config/extension.toml | 2 +- .../omni.isaac.lab/docs/CHANGELOG.rst | 9 ++++++++ .../lab/terrains/trimesh/mesh_terrains.py | 21 ++++++++++--------- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 5ae174987b..88c6f0958e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -66,6 +66,7 @@ Guidelines for modifications: * Michael Gussert * Michael Noseworthy * Muhong Guo +* Nicola Loi * Nuralem Abizov * Oyindamola Omotuyi * Özhan Özen diff --git a/source/extensions/omni.isaac.lab/config/extension.toml b/source/extensions/omni.isaac.lab/config/extension.toml index d0ce0dae38..d64f5d9f66 100644 --- a/source/extensions/omni.isaac.lab/config/extension.toml +++ b/source/extensions/omni.isaac.lab/config/extension.toml @@ -1,7 +1,7 @@ [package] # Note: Semantic Versioning is used: https://semver.org/ -version = "0.30.1" +version = "0.30.2" # Description title = "Isaac Lab framework for Robot Learning" diff --git a/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst b/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst index a96a1c2c04..7eeb14c774 100644 --- a/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst +++ b/source/extensions/omni.isaac.lab/docs/CHANGELOG.rst @@ -1,6 +1,15 @@ Changelog --------- +0.30.2 (2024-12-30) +~~~~~~~~~~~~~~~~~~~ + +Fixed +^^^^^ + +* Fixed the respawn of only wrong object samples in :func:`repeated_objects_terrain` of :mod:`omni.isaac.lab.terrains.trimesh` module. Previously, the function was respawning all objects in the scene instead of only the wrong object samples, which in worst case could lead to infinite respawn loop. + + 0.30.1 (2024-12-17) ~~~~~~~~~~~~~~~~~~~ diff --git a/source/extensions/omni.isaac.lab/omni/isaac/lab/terrains/trimesh/mesh_terrains.py b/source/extensions/omni.isaac.lab/omni/isaac/lab/terrains/trimesh/mesh_terrains.py index e5493ccee9..3b59b5ffce 100644 --- a/source/extensions/omni.isaac.lab/omni/isaac/lab/terrains/trimesh/mesh_terrains.py +++ b/source/extensions/omni.isaac.lab/omni/isaac/lab/terrains/trimesh/mesh_terrains.py @@ -816,21 +816,22 @@ def repeated_objects_terrain( platform_corners[0, :] *= 1 - platform_clearance platform_corners[1, :] *= 1 + platform_clearance # sample center for objects - while True: - object_centers = np.zeros((num_objects, 3)) - object_centers[:, 0] = np.random.uniform(0, cfg.size[0], num_objects) - object_centers[:, 1] = np.random.uniform(0, cfg.size[1], num_objects) + object_centers = np.zeros((num_objects, 3)) + mask_objects_left = np.ones((num_objects,), dtype=bool) + while np.any(mask_objects_left): + num_objects_left = mask_objects_left.sum() + object_centers[mask_objects_left, 0] = np.random.uniform(0, cfg.size[0], num_objects_left) + object_centers[mask_objects_left, 1] = np.random.uniform(0, cfg.size[1], num_objects_left) # filter out the centers that are on the platform is_within_platform_x = np.logical_and( - object_centers[:, 0] >= platform_corners[0, 0], object_centers[:, 0] <= platform_corners[1, 0] + object_centers[mask_objects_left, 0] >= platform_corners[0, 0], + object_centers[mask_objects_left, 0] <= platform_corners[1, 0], ) is_within_platform_y = np.logical_and( - object_centers[:, 1] >= platform_corners[0, 1], object_centers[:, 1] <= platform_corners[1, 1] + object_centers[mask_objects_left, 1] >= platform_corners[0, 1], + object_centers[mask_objects_left, 1] <= platform_corners[1, 1], ) - masks = np.logical_and(is_within_platform_x, is_within_platform_y) - # if there are no objects on the platform, break - if not np.any(masks): - break + mask_objects_left[mask_objects_left] = np.logical_and(is_within_platform_x, is_within_platform_y) # generate obstacles (but keep platform clean) for index in range(len(object_centers)):