Module ouster.pcap
- record(packets, pcap_path, *, src_ip='127.0.0.1', dst_ip='127.0.0.1', lidar_port=7502, imu_port=7503, use_sll_encapsulation=False)[source]
Record a sequence of sensor packets to a pcap file.
- Parameters:
packets (
Iterable
[Union
[ImuPacket
,LidarPacket
]]) – A (finite!) sequence of packetspcap_path (
str
) – Path of the output pcap filesrc_ip (
str
) – Source IP to use for all packetsdst_ip (
str
) – Destination IP to use for all packetslidar_port (
int
) – Src/dst port to use for lidar packetsimu_port (
int
) – Src/dst port to use for imu packetsuse_sll_encapsulation (
bool
) – Use sll encapsulation
- Return type:
int
- Returns:
Number of packets captured
- class Pcap(pcap_path, info, *, rate=0.0, lidar_port=None, imu_port=None, loop=False, soft_id_check=False)[source]
Read a sensor packet stream out of a pcap file as an iterator.
Read a single sensor data stream from a packet capture.
Packet captures can contain arbitrary network traffic or even multiple valid sensor data streams. To avoid passing invalid data to the user, this class assumes that lidar and/or imu packets are associated with distinct destination ports, which may be recorded in the sensor metadata or specified explicitly.
When not specified, ports are guessed by sampling some packets and looking for the expected packet size based on the sensor metadata. If packets that might be valid sensor data appear on multiple ports, one is chosen arbitrarily. See
_guess_ports
for details. on the heuristics.Packets with the selected destination port that clearly don’t match the metadata (e.g. wrong size or init_id) will be silently ignored.
When a rate is specified, output packets in (a multiple of) real time using the pcap packet capture timestamps.
- Parameters:
info (
SensorInfo
) – Sensor metadatapcap_path (
str
) – File path of recorded pcaprate (
float
) – Output packets in real time, if non-zerolidar_port (
Optional
[int
]) – Specify the destination port of lidar packetsimu_port (
Optional
[int
]) – Specify the destination port of imu packetsloop (
bool
) – Specify whether to reload the PCAP file when the end is reachedsoft_id_check (
bool
) – if True, don’t skip lidar packets buffers on init_id/sn mismatch
- property metadata: SensorInfo
Metadata associated with the packet stream.
- property ports: Tuple[int, int]
Specified or inferred ports associated with lidar and imu data.
Values <= 0 indicate that no lidar or imu data will be read.
- property closed: bool
Check if source is closed. Thread-safe.