diff --git a/omniverse/extension/omni.viplanner/omni/viplanner/collectors/terrain_analysis.py b/omniverse/extension/omni.viplanner/omni/viplanner/collectors/terrain_analysis.py index 72783fe..07f1223 100644 --- a/omniverse/extension/omni.viplanner/omni/viplanner/collectors/terrain_analysis.py +++ b/omniverse/extension/omni.viplanner/omni/viplanner/collectors/terrain_analysis.py @@ -401,7 +401,9 @@ def _point_filter_wall_closeness( heights = heights[without_wall] return ray_origins, heights - def _point_filter_semantic_cost(self, ray_origins: torch.Tensor, heights: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]: + def _point_filter_semantic_cost( + self, ray_origins: torch.Tensor, heights: torch.Tensor + ) -> tuple[torch.Tensor, torch.Tensor]: # raycast vertically down and get the corresponding face id ray_directions = torch.zeros((ray_origins.shape[0], 3), dtype=torch.float32, device=self.device) ray_directions[:, 2] = -1.0 diff --git a/omniverse/extension/omni.viplanner/omni/viplanner/collectors/viewpoint_sampling.py b/omniverse/extension/omni.viplanner/omni/viplanner/collectors/viewpoint_sampling.py index 1cf85c8..b2b72ab 100644 --- a/omniverse/extension/omni.viplanner/omni/viplanner/collectors/viewpoint_sampling.py +++ b/omniverse/extension/omni.viplanner/omni/viplanner/collectors/viewpoint_sampling.py @@ -14,8 +14,8 @@ import cv2 import numpy as np -import torch import omni.isaac.lab.utils.math as math_utils +import torch from omni.isaac.lab.markers import VisualizationMarkers from omni.isaac.lab.markers.config import GREEN_ARROW_X_MARKER_CFG from omni.isaac.lab.scene import InteractiveScene @@ -78,7 +78,9 @@ def sample_viewpoints(self, nbr_viewpoints: int, seed: int = 1) -> torch.Tensor: while sample_locations_count < nbr_viewpoints: # get samples sample_idx = self.terrain_analyser.samples[:, 0] == curr_point_idx - sample_idx_select = torch.randperm(sample_idx.sum())[:min(nbr_samples_per_point, nbr_viewpoints - sample_locations_count)] + sample_idx_select = torch.randperm(sample_idx.sum())[ + : min(nbr_samples_per_point, nbr_viewpoints - sample_locations_count) + ] sample_locations[ sample_locations_count : sample_locations_count + sample_idx_select.shape[0] ] = self.terrain_analyser.samples[sample_idx][sample_idx_select, :2] @@ -165,7 +167,11 @@ def render_viewpoints(self, samples: torch.Tensor): np.savetxt(os.path.join(filedir, "intrinsics.txt"), intrinsics.reshape(-1, 12), delimiter=",") # save camera poses (format: x y z qx qy qz qw instead of x y z qw qx qy qz) - np.savetxt(os.path.join(filedir, "camera_extrinsic.txt"), samples[:, [0, 1, 2, 4, 5, 6, 3]].cpu().numpy(), delimiter=",") + np.savetxt( + os.path.join(filedir, "camera_extrinsic.txt"), + samples[:, [0, 1, 2, 4, 5, 6, 3]].cpu().numpy(), + delimiter=",", + ) # save images samples = samples.to(self.scene.device) @@ -217,12 +223,14 @@ def render_viewpoints(self, samples: torch.Tensor): # might not start from 0 as well as some data ids might not be present in the label ids unique_data_ids = np.unique(image_data_np) unique_data_ids.sort() - mapping = np.zeros((max(unique_data_ids.max() + 1, max(info.keys()) + 1), 3), dtype=np.uint8) + mapping = np.zeros( + (max(unique_data_ids.max() + 1, max(info.keys()) + 1), 3), dtype=np.uint8 + ) mapping[list(info.keys())] = np.array(list(info.values()), dtype=np.uint8) output = mapping[image_data_np[idx].squeeze(-1)] else: output = image_data_np[idx] - + assert cv2.imwrite( os.path.join(filedir, "semantics", f"{image_idx[cam_idx]}".zfill(4) + ".png"), cv2.cvtColor(output.astype(np.uint8), cv2.COLOR_RGB2BGR), @@ -233,8 +241,11 @@ def render_viewpoints(self, samples: torch.Tensor): os.path.join(filedir, "depth", f"{image_idx[cam_idx]}".zfill(4) + ".png"), np.uint16(image_data_np[idx] * self.cfg.depth_scale), ) - # save as npy - np.save(os.path.join(filedir, "depth", f"{image_idx[cam_idx]}".zfill(4) + ".npy"), image_data_np[idx] * self.cfg.depth_scale) + # save as npy + np.save( + os.path.join(filedir, "depth", f"{image_idx[cam_idx]}".zfill(4) + ".npy"), + image_data_np[idx] * self.cfg.depth_scale, + ) image_idx[cam_idx] += 1 diff --git a/omniverse/extension/omni.viplanner/omni/viplanner/utils/unreal_importer.py b/omniverse/extension/omni.viplanner/omni/viplanner/utils/unreal_importer.py index df8fbed..7f1cfa1 100644 --- a/omniverse/extension/omni.viplanner/omni/viplanner/utils/unreal_importer.py +++ b/omniverse/extension/omni.viplanner/omni/viplanner/utils/unreal_importer.py @@ -151,7 +151,9 @@ def _add_semantics(self): # assign class to mesh in ISAAC def recursive_semUpdate(prim, sem_class_name: str, update_submesh: bool) -> bool: # Necessary for Park Mesh - if prim.GetName() == "HierarchicalInstancedStaticMesh" or prim.GetTypeName() == "Mesh": # or "FoliageInstancedStaticMeshComponent" in prim.GetName(): + if ( + prim.GetName() == "HierarchicalInstancedStaticMesh" or prim.GetTypeName() == "Mesh" + ): # or "FoliageInstancedStaticMeshComponent" in prim.GetName(): add_update_semantics(prim, sem_class_name) update_submesh = True children = prim.GetChildren() diff --git a/omniverse/standalone/data_collect.py b/omniverse/standalone/data_collect.py index 30f6b38..8d484b5 100644 --- a/omniverse/standalone/data_collect.py +++ b/omniverse/standalone/data_collect.py @@ -73,7 +73,7 @@ def main(): cfg.terrain_analysis.dim_limiter_prim = "Road_Sidewalk" elif args_cli.scene == "warehouse": scene_cfg = WarehouseTerrainSceneCfg(args_cli.num_envs, env_spacing=1.0) - # overwrite semantic cost mapping + # overwrite semantic cost mapping cfg.terrain_analysis.semantic_cost_mapping = CarlaSemanticCostMapping() # limit space to be within the road network cfg.terrain_analysis.dim_limiter_prim = "Section" # name of the meshes of the walls diff --git a/viplanner/config/costmap_cfg.py b/viplanner/config/costmap_cfg.py index e92615c..092c7cb 100644 --- a/viplanner/config/costmap_cfg.py +++ b/viplanner/config/costmap_cfg.py @@ -158,13 +158,13 @@ class GeneralCostMapConfig: # smoothing parameters sigma_smooth: float = 3.0 # cost map expansion - x_min: Optional[float] = None # -8.05 + x_min: Optional[float] = None # [m] if None, the minimum of the point cloud is used None (carla town01: -8.05 matterport: None) - y_min: Optional[float] = None # -8.05 + y_min: Optional[float] = None # [m] if None, the minimum of the point cloud is used None (carla town01: -8.05 matterport: None) - x_max: Optional[float] = None # 346.22 + x_max: Optional[float] = None # [m] if None, the maximum of the point cloud is used None (carla town01: 346.22 matterport: None) - y_max: Optional[float] = None # 336.65 + y_max: Optional[float] = None # [m] if None, the maximum of the point cloud is used None (carla town01: 336.65 matterport: None) diff --git a/viplanner/depth_reconstruct.py b/viplanner/depth_reconstruct.py index 4c94a87..4dc207f 100644 --- a/viplanner/depth_reconstruct.py +++ b/viplanner/depth_reconstruct.py @@ -33,7 +33,7 @@ class DepthReconstruction: - semantics (optional) - xxxx.png (images should be named with 4 digits, e.g. 0000.png, 0001.png, etc., RGB images) - In the case that the semantic and depth images have an offset in their position (as typical on some robotic platforms), + In the case that the semantic and depth images have an offset in their position (as typical on some robotic platforms), define a sem_suffic and depth_suffix in ReconstructionCfg to differentiate between the two with the following structure: - env_name