Class SensorScanSource

Inheritance Relationships

Base Types

  • public ouster::sdk::core::ScanSource (Class ScanSource)

  • private ouster::sdk::impl::ScanSourceBuilder< ouster::sdk::core::IoType::SENSOR, SensorScanSource >

Class Documentation

class SensorScanSource : public ouster::sdk::core::ScanSource, private ouster::sdk::impl::ScanSourceBuilder<ouster::sdk::core::IoType::SENSOR, SensorScanSource>

Provides a simple API for configuring sensors and retreiving LidarScans from them.

Public Functions

SensorScanSource(const std::string &source, SensorScanSourceOptions options)

Construct the SensorScanSource.

Parameters:
  • source[in] sensor hostname to connect to

  • options[in] scan source options

SensorScanSource(const std::vector<std::string> &source, SensorScanSourceOptions options)

Construct the SensorScanSource.

Parameters:
  • source[in] sensor hostnames to connect to

  • options[in] scan source options

SensorScanSource(const std::string &source, const std::function<void(SensorScanSourceOptions&)> &options = {})

construct the SensorScanSource

Parameters:
  • source[in] sensor hostname to connect to

  • options[in] scan source options

SensorScanSource(const std::vector<std::string> &source, const std::function<void(SensorScanSourceOptions&)> &options = {})

construct the SensorScanSource

Parameters:
  • source[in] sensor hostnames to connect

  • options[in] scan source options

SensorScanSource(const std::vector<Sensor> &sensors, double config_timeout = 45, unsigned int queue_size = 2, bool soft_id_check = false)

Construct a SensorScanSource to connect to the listed sensors.

Parameters:
  • sensors[in] sensors to connect to

  • config_timeout[in] timeout in seconds for configuring sensors

  • queue_size[in] maximum number of scans to queue

  • soft_id_check[in] if true, allow accepting packets with mismatched sensor serial numbers and init_ids

SensorScanSource(const std::vector<Sensor> &sensors, const std::vector<ouster::sdk::core::SensorInfo> &infos, double config_timeout = 45, unsigned int queue_size = 2, bool soft_id_check = false)

Construct a SensorScanSource to connect to the listed sensors If infos are provided, they are used instead of configuring the sensors and retrieving the sensor info from them.

Parameters:
  • sensors[in] sensors to connect to

  • infos[in] metadata for each sensor, if present used instead of configuring each sensor

  • config_timeout[in] timeout for sensor config

  • queue_size[in] maximum number of scans to queue

  • soft_id_check[in] if true, allow accepting packets with mismatched sensor serial numbers and init_ids

SensorScanSource(const std::vector<Sensor> &sensors, const std::vector<ouster::sdk::core::SensorInfo> &infos, const std::vector<ouster::sdk::core::LidarScanFieldTypes> &fields, double config_timeout = 45, unsigned int queue_size = 2, bool soft_id_check = false)

Construct a SensorScanSource to connect to the listed sensors If infos are provided, they are used instead of configuring the sensors and retrieving the sensor info from them.

Parameters:
  • sensors[in] sensors to connect to

  • infos[in] metadata for each sensor, if present used instead of configuring each sensor

  • fields[in] fields to batch into LidarScans for each lidar. If empty default fields for that profile are used.

  • config_timeout[in] timeout for sensor config

  • queue_size[in] maximum number of scans to queue

  • soft_id_check[in] if true, allow accepting packets with mismatched sensor serial numbers and init_ids

~SensorScanSource() override
void flush()

Flush any buffered scans.

inline uint64_t dropped_scans()

Get the number of scans that were dropped due to buffer overflow.

Returns:

the number of dropped scans

inline uint64_t id_error_count()

Get the number of packets that had an id verification error.

Returns:

the number of errors

std::pair<int, std::unique_ptr<ouster::sdk::core::LidarScan>> get_scan(double timeout_sec = 0.0)

Retrieves a scan from the queue or waits up to timeout_sec until one is available.

Important: may return a nullptr if the underlying condition var experiences a spurious wakeup.

Parameters:

timeout_sec[in] timeout for retrieving a scan

Returns:

the resulting lidar scan with the idx of the producing sensor if no result, the returned scan will be nullptr

inline virtual bool is_live() const override

Indicates if the source is streaming from a device, such as a sensor.

Returns:

if live or not

inline virtual const std::vector<std::shared_ptr<ouster::sdk::core::SensorInfo>> &sensor_info() const override

Get the sensor info for each sensor in this dataset.

Returns:

sensor info for each sensor

virtual ouster::sdk::core::ScanIterator begin() const override

Provides each scan from all sensors in time order.

Returns:

start iterator for all sensors

virtual ouster::sdk::core::ScanIterator begin(int sensor_index) const override

Provides scans from a single sensor in time order If idx < 0 provides scans from all sensors.

Parameters:
  • sensor_index[in] sensor index

  • sensor_index[in] – sensor index

Throws:

std::runtime_error – if sensor_idx >= number of sensors

Returns:

start iterator for the sensor with the given index

virtual size_t size_hint() const override

The approximate length of the source if unindexed, or the real size if indexed.

Live sources or sources with undefined length will return 0.

Returns:

approximate length of source

inline virtual std::unique_ptr<ScanSource> move() override

move into a newly allocated item

Returns:

a unique pointer to a newly allocated ScanSource instance containing the moved-from state.

static std::unique_ptr<ouster::sdk::core::ScanSource> create(const std::vector<std::string> &sources, const ScanSourceOptions &options, bool collate, int sensor_idx = -1)

open_source compatible factory.

Parameters:
  • sources[in] – source filenames

  • options[in] – source options

  • collate[in] – whether to collate the source or not

  • sensor_idx[in] – access specific sensor index in the osf

Returns:

unique_ptr of ScanSource type