Skip to content

Commit

Permalink
Remove lidar returns on the EGO vehicle by default
Browse files Browse the repository at this point in the history
  • Loading branch information
wljungbergh committed Oct 30, 2023
1 parent e48b6ff commit 3e91eb6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion zod/data_classes/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
from ._serializable import JSONSerializable
from .geometry import Pose

# we want to remove the points that get returns from the ego vehicle.
# we do this by removing all points that are within the box defined by
# EGO_RETURNS_BOX. This box is defined in the LiDAR frame.
EGO_RETURNS_BOX = np.array([[-1.5, -3.0, -1.5], [1.5, 3.0, 0.5]])


@dataclass
class LidarData:
Expand Down Expand Up @@ -48,10 +53,17 @@ def empty(cls) -> LidarData:
)

@classmethod
def from_npy(cls, path: str) -> LidarData:
def from_npy(cls, path: str, remove_ego_lidar_returns: bool = True) -> LidarData:
"""Load lidar data from a .npy file."""
data = np.load(path)
core_timestamp = parse_datetime_from_filename(path).timestamp()
if remove_ego_lidar_returns:
ego_returns_mask = np.ones(len(data), dtype=np.bool_)
for idim, dim in enumerate(("x", "y", "z")):
ego_returns_mask &= np.logical_and(
data[dim] > EGO_RETURNS_BOX[0, idim], data[dim] < EGO_RETURNS_BOX[1, idim]
)
data = data[~ego_returns_mask]
return cls(
points=np.vstack((data["x"], data["y"], data["z"])).T,
timestamps=core_timestamp + data["timestamp"] / 1e6,
Expand Down

0 comments on commit 3e91eb6

Please sign in to comment.