Timestamp for .pcd files

{ “scan_0000.pcd”: “1970-01-01 05:30:00”,
“scan_0001.pcd”: “2025-05-15 18:31:03.836641”,
“scan_0002.pcd”: “2025-05-15 18:31:03.936679”,
“scan_0003.pcd”: “2025-05-15 18:31:04.036767”,
“scan_0004.pcd”: “2025-05-15 18:31:04.136839”,
“scan_0005.pcd”: “2025-05-15 18:31:04.236961”,
“scan_0006.pcd”: “2025-05-15 18:31:04.336999”,
“scan_0007.pcd”: “2025-05-15 18:31:04.436982”,
“scan_0008.pcd”: “2025-05-15 18:31:04.536951”,
“scan_0009.pcd”: “2025-05-15 18:31:04.636932”}

This is the timestamp I got when I converted the .pcap to .pcd along with timestamp for each pcd files. why is there a discrepancy in the timestamp for first .pcd file. The below code is I used for conversion, correct me if anything is wrong.

info = client.SensorInfo(open(meta_path).read())
source = pcap.Pcap(pcap_path, info)
scans = client.Scans(source)
xyzlut = client.XYZLut(info)

timestamps = {}

for i, scan in enumerate(scans):
    xyz = xyzlut(scan.field(client.ChanField.RANGE))
    points = xyz.reshape(-1, 3)
    
    timestamp_ns = scan.timestamp # timestamp: nanoseconds
    if isinstance(timestamp_ns, np.ndarray):
        timestamp_ns = timestamp_ns[0]

    timestamps[f"scan_{i:04d}.pcd"] = str(datetime.datetime.fromtimestamp(timestamp_ns / 1e9))

You probably want to update this to the following:

    from ouster.sdk.client import first_valid_column_ts # alternatively you could use `first_valid_packet_ts`
    timestamp_ns = scan.timestamp # timestamp: nanoseconds
    if isinstance(timestamp_ns, np.ndarray):
        timestamp_ns = first_valid_column_ts(timestamp_ns)

The reason being is that some lidar may have missing packets from the frame and this is especially the case for very first frame of your capture. So by using the first_valid_column_ts you look for the first valid timestamp of the scan.

1 Like
for i, scan in enumerate(scans):
    xyz = client.XYZLut(info)(scan)
    points = xyz.reshape(-1, 3)
        
    timestamp_ns = client.first_valid_column_ts(scan) 

This is the right syntax, otherwise it will throw an error since it didn’t expect numpy array.

Another issue is like this timestamp is not matching with one which I obtained in wireshark tool(with the same pcap file).