async_writer.h
Class
-
class AsyncWriter
OSF AsyncWriter wraps osf::Writer so that saving occurs in a background thread. Calls to save() return a std::future<void> instead of void to enable propagating exceptions from the save thread.
Public Functions
- Parameters:
filename – [in] The filename to output to.
info – [in] The sensor info vector to use for a multi stream OSF file.
fields_to_write – [in] The fields from scans to actually save into the OSF. If not provided uses the fields from the first saved lidar scan for this sensor. This parameter is optional.
chunk_size – [in] The chunksize to use for the OSF file, this parameter is optional.
encoder – [in] An optional Encoder instance for configuring how the Writer should encode the OSF.
-
~AsyncWriter()
Closes the writer and finalizes any pending writes.
-
std::future<void> save(uint32_t stream_index, const LidarScan &scan)
Save a single scan to the specified stream_index in an OSF file.
The concept of the stream_index is related to the sensor_info vector. Consider the following:
sensor_info info1; // The first sensor in this OSF file sensor_info info2; // The second sensor in this OSF file sensor_info info3; // The third sensor in this OSF file Writer output = Writer(filename, {info1, info2, info3}); LidarScan scan = RANDOM_SCAN_HERE; // To save the LidarScan of scan to the first sensor, you would do the // following output.save(0, scan); // To save the LidarScan of scan to the second sensor, you would do the // following output.save(1, scan); // To save the LidarScan of scan to the third sensor, you would do the // following output.save(2, scan);
- Throws:
std::logic_error – Will throw exception on writer being closed.
std::logic_error – ///< Will throw exception on ///< out of bound stream_index.
- Parameters:
stream_index – [in] The index of the corrosponding sensor_info to use.
scan – [in] The scan to save.
- Returns:
a future, which can propagate exceptions that may have occurred in the background from the save thread.
-
std::future<void> save(uint32_t stream_index, const LidarScan &scan, ouster::osf::ts_t timestamp)
Save a single scan with the specified timestamp to the specified stream_index in an OSF file.
- Throws:
std::logic_error – Will throw exception on writer being closed.
std::logic_error – ///< Will throw exception on ///< out of bound stream_index.
- Parameters:
stream_index – [in] The index of the corrosponding sensor_info to use.
scan – [in] The scan to save.
timestamp – [in] Receive timestamp to index this scan with.
- Returns:
a future, which can propagate exceptions that may have occurred in the background from the save thread.
-
std::vector<std::future<void>> save(const std::vector<LidarScan> &scans)
Save multiple scans to the OSF file.
The concept of the stream_index is related to the sensor_info vector. Consider the following:
sensor_info info1; // The first sensor in this OSF file sensor_info info2; // The second sensor in this OSF file sensor_info info3; // The third sensor in this OSF file Writer output = Writer(filename, {info1, info2, info3}); LidarScan sensor1_scan = RANDOM_SCAN_HERE; LidarScan sensor2_scan = RANDOM_SCAN_HERE; LidarScan sensor3_scan = RANDOM_SCAN_HERE; // To save the scans matched appropriately to their sensors, you would do // the following output.save({sensor1_scan, sensor2_scan, sensor3_scan});
- Throws:
std::logic_error – Will throw exception on writer being closed
- Parameters:
scans – [in] The vector of scans to save.
- Returns:
a vector of futures, which can propagate exceptions that may have occurred in the background from the save thread.
Structs
-
struct LidarScanMessage
Encapsulates everything that’s needed to encode and save the provided lidar scan into the OSF.