def get_timestamps(files, idx):
    """Extract timestamps from a pose or relocalization file."""
    lines = []
    for p in files.parent.glob(files.name):
        with open(p) as f:
            lines += f.readlines()
    timestamps = set()
    for line in lines:
        line = line.rstrip('\n')
        if line[0] == '#' or line == '':
            continue
        ts = line.replace(',', ' ').split()[idx]
        timestamps.add(ts)
    return timestamps