pcap_source.h

class PcapRawSource

Wrapper to process pcap files with lidar packet sensor data. Currently supports a single sensor, but can be extended easily for multisensor pcaps.

Public Types

using LidarDataHandler = std::function<void(const ts_t timestamp, const ouster::LidarScan &scan)>

Lidar data callbacks

Param timestamp:

[in] The timestamp for the scan.

Param scan:

[in] The LidarScan object.

using PacketHandler = std::function<void(const ouster::sensor_utils::packet_info &info, const uint8_t *buf)>

General pcap packet handler

Param info:

[in] The sensor_info for the packet.

Param buf:

[in] The raw buffer for the packet.

using PacketInfoPredicate = std::function<bool(const ouster::sensor_utils::packet_info &info)>

Predicate to control the bag run loop

Param info:

[in] The sensor_info for the packet.

Return:

True if the loop should continue, False if the loop should halt.

Public Functions

PcapRawSource(const std::string &filename)

Opens pcap file and checks available packets inside with heuristics applied to guess Ouster lidar port with data.

Parameters:

filename[in] The filename of the pcap file to open.

void addLidarDataHandler(int dst_port, const ouster::sensor::sensor_info &info, LidarDataHandler &&lidar_handler)

Attach lidar data handler to the port that receives already batched LidarScans with a timestamp of the first UDP lidar packet. LidarScan uses default field types by the profile

Parameters:
  • dst_port[in] The destination port for the target lidar stream.

  • info[in] The sensor info for the stream.

  • lidar_handler[in] The callback to call on packet.

void addLidarDataHandler(int dst_port, const ouster::sensor::sensor_info &info, const LidarScanFieldTypes &ls_field_types, LidarDataHandler &&lidar_handler)

Attach lidar data handler to the port that receives already batched LidarScans with a timestamp of the first UDP lidar packet. LidarScan uses default field types by the profile

Parameters:
  • dst_port[in] The destination port for the target lidar stream.

  • info[in] The sensor info for the stream.

  • lidar_handler[in] The callback to call on packet.

  • ls_field_types[in] The LidarScan field types to use.

void runAll()

Read all packets from pcap and pass data to the attached handlers based on dst_port from pcap packets.

void runWhile(const PacketInfoPredicate &pred)

Run the internal loop through all packets while the pred(pinfo) == true. pred function called before reading packet buffer and passing to the appropriate handlers.

Parameters:

pred[in] The predicate function to decide whether to continue or not.

~PcapRawSource()

Close the pcap file.