Quickstart
Synchronous datasets
Synchronous datasets (SemanticKITTI, GOOSE, Rellis-3D) index directly by frame number. Every ds[i] returns a complete set of co-captured modalities.
import apairo
ds = apairo.SemanticKittiDataset(
"/data/semantic_kitti",
keys=["lidar", "labels"],
split="train", # optional: filter by split directory
)
print(len(ds)) # total number of frames across all sequences
print(ds) # SemanticKittiDataset(n=..., sequences=..., keys=['lidar', 'labels'], root=...)
last = ds[-1] # negative indices count from the end
sample = ds[0]
print(sample.data["lidar"].shape) # (N, 4) numpy.ndarray -- x, y, z, intensity
print(sample.data["labels"].shape) # (N,) numpy.ndarray -- semantic class IDs
print(sample.timestamp) # None if clockless, else a float (per-frame clock)
The same API works for all synchronous datasets:
ds = apairo.Goose3DDataset("/data/goose", keys=["lidar", "labels"], split="train")
ds = apairo.Rellis3DDataset("/data/rellis", keys=["lidar"])
Asynchronous datasets
Asynchronous datasets (TartanDrive, a rosbag extraction) interleave multiple sensor streams into a single timestamp-ordered timeline. Every ds[i] returns one event from one sensor.
ds = apairo.TartanKittiDataset("/data/tartan/2024-01-01_forest")
print(ds.keys) # discovered channels: ["velodyne_0", "image_left", ...]
print(len(ds)) # total events across all channels
sample = ds[42]
print(sample.timestamp) # float -- seconds
print(list(sample.data.keys())) # ["velodyne_0"] -- exactly one channel per event
print(sample.data["velodyne_0"].shape)
The Sample object
Every __getitem__ call returns a Sample:
@dataclass
class Sample:
data: dict[str, np.ndarray] # key -> numpy array
timestamp: float | None # None when the dataset has no clock
A channel can also be read straight from the sample:
sample["lidar"] # same as sample.data["lidar"]
"lidar" in sample # True
sample.timestamp # the time is an attribute: sample["timestamp"] would be a channel
Channel names are free, so sample["timestamp"] reads a channel called
timestamp if there is one; otherwise the KeyError points to
sample.timestamp.
Iterating
All datasets are iterable:
Selecting keys
Pass keys= to load only the modalities you need -- useful when some channels are large or slow to load:
Available keys for each dataset class are exposed as a class attribute:
From the terminal
The apairo command inspects and checks a dataset without any Python:
apairo status /data/my_dataset # channels, rates, spans, issues
apairo check /data/my_dataset # exit 1 if loading would refuse something
The Command Line tab has a typical session, from ROS bags to a viewer, and every command.