indexed_pcap_reader.h
Enums
Class
-
class IndexedPcapReader : public ouster::sensor_utils::PcapReader
A PcapReader that allows seeking to the start of a lidar frame.
The index must be computed by iterating through all packets and calling
update_index_for_current_packet()
for each one.Public Functions
-
IndexedPcapReader(const std::string &pcap_filename, const std::vector<std::string> &metadata_filenames)
- Parameters:
pcap_filename – [in] - A file path of the pcap to read
metadata_filenames – [in] - A vector of sensor metadata file paths
pcap_filename – [in] A file path of the pcap to read
metadata_filenames – [in] A vector of sensor metadata filepaths
-
IndexedPcapReader(const std::string &pcap_filename, const std::vector<ouster::sensor::sensor_info> &sensor_infos)
- Parameters:
pcap_filename – [in] A file path of the pcap to read
sensor_infos – [in] A vector of sensor info structures for each sensors
-
void build_index()
This method constructs the index. Call this method before requesting the index information using get_index()
-
const PcapIndex &get_index() const
Get index for the underlying pcap
- Returns:
returns a PcapIndex object
-
nonstd::optional<size_t> sensor_idx_for_current_packet(bool soft_id_check = false) const
Attempts to match the current packet to one of the sensor info objects and returns the appropriate packet format if there is one
- Parameters:
soft_id_check – [in] if id mismatches should be ignored
- Returns:
An optional sensor index for the current packet
-
std::pair<IdxErrorType, nonstd::optional<size_t>> check_sensor_idx_for_current_packet(bool soft_id_check) const
Attempts to match the current packet to one of the sensor info objects and returns the appropriate packet format if there is one
- Parameters:
soft_id_check – [in] if id mismatches should be ignored
- Returns:
An optional packet format for the current packet
-
nonstd::optional<uint16_t> current_frame_id() const
- Returns:
the current packet’s frame_id if the packet is associated with a sensor (and its corresponding packet format)
-
int update_index_for_current_packet()
Updates the frame index for the current packet
- Todo:
I recommend take this a private method, the problem with exposing this method is that it only yields right results if invoked sequentially ; the results are dependent on the internal state.
- Returns:
the progress of indexing as an int from [0, 100]
-
const std::vector<ouster::sensor::sensor_info> &sensor_info() const
Get the sensor_info for each sensor in this pcap.
- Returns:
the sensor_info for each sensor in this pcap
Public Static Functions
-
static bool frame_id_rolled_over(uint16_t previous, uint16_t current)
Return true if the frame_id from the packet stream has rolled over, hopefully avoiding spurious result that could occur from out of order or dropped packets.
- Parameters:
previous – [in] The previous frame id.
current – [in] The current frame id.
- Returns:
true if the frame id has rolled over.
-
IndexedPcapReader(const std::string &pcap_filename, const std::vector<std::string> &metadata_filenames)
-
class PcapDuplicatePortException : public std::runtime_error
-
class PcapIndex
Public Types
-
using frame_index = std::vector<uint64_t>
Maps a frame number to a file offset.
Public Functions
-
void clear()
Simple method to clear the index.
-
size_t frame_count(size_t sensor_index) const
Returns the number of frames in the frame index for the given sensor index.
- Parameters:
sensor_index – [in] The position of the sensor for which to retrieve the desired frame count.
- Returns:
The number of frames in the sensor’s frame index.
-
void seek_to_frame(PcapReader &reader, size_t sensor_index, unsigned int frame_number)
Seeks the given reader to the given frame number for the given sensor index
- Parameters:
reader – [inout] The reader to use for seeking.
sensor_index – [in] The position of the sensor for which to seek for.
frame_number – [in] The frame number to seek to.
Public Members
-
std::vector<frame_index> frame_indices_
frame index for each sensor
-
std::vector<GlobalIndex> global_frame_indices_
frame index for all sensors, contains the offset followed by the index of each sensor
-
using frame_index = std::vector<uint64_t>
Structs
-
struct GlobalIndex