From fbd5e9a2d8b1764d876940a51a4b708c77f6dd90 Mon Sep 17 00:00:00 2001 From: Jan Kowalczyk Date: Thu, 10 Jul 2025 09:10:10 +0200 Subject: [PATCH] fixed reindex in render2d --- tools/render2d.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/render2d.py b/tools/render2d.py index 911858d..6a5aa51 100644 --- a/tools/render2d.py +++ b/tools/render2d.py @@ -175,16 +175,29 @@ def process_frame(args) -> Tuple[int, np.ndarray, Optional[Path]]: lidar_data["normalized_range"] = 1 / np.sqrt( lidar_data["x"] ** 2 + lidar_data["y"] ** 2 + lidar_data["z"] ** 2 ) + # check for zero values in normalized_range and output the x y and z values for them + zero_range_indices = lidar_data[lidar_data["normalized_range"] == 0].index + if not zero_range_indices.empty: + print( + f"Warning: Found {len(zero_range_indices)} points with zero normalized range at indices: {zero_range_indices.tolist()}" + ) + print( + "X, Y, Z values for these points:", + lidar_data.loc[zero_range_indices, ["x", "y", "z"]].to_numpy(), + ) + # Set zero values to NaN to avoid issues with training + lidar_data.loc[zero_range_indices, "normalized_range"] = np.nan + projection_data = lidar_data.pivot( index="vertical_position", columns="horizontal_position", values="normalized_range", ) projection_data = projection_data.reindex( - columns=range(horizontal_resolution), fill_value=0 + columns=range(horizontal_resolution), fill_value=np.nan ) projection_data = projection_data.reindex( - index=range(vertical_resolution), fill_value=0 + index=range(vertical_resolution), fill_value=np.nan ) projection_data, output_horizontal_resolution = crop_projection_data_to_roi( projection_data, roi_angle_start, roi_angle_width, horizontal_resolution