types.h

Type-defs

template<typename T>
using ouster::img_t = Eigen::Array<T, -1, -1, Eigen::RowMajor>

For image operations.

Template Parameters

T – The data type for the array.

using ouster::mat4d = Eigen::Matrix<double, 4, 4, Eigen::DontAlign>

Used for transformations.

using ouster::sensor::AzimuthWindow = std::pair<int, int>

Convenience type alias for azimuth windows, the window over which the sensor fires in millidegrees.

using ouster::sensor::ColumnWindow = std::pair<int, int>

Convenience type alias for column windows, the window over which the sensor fires in columns.

Helper Data

Lidar Mode

enum ouster::sensor::lidar_mode

Constants used for configuration. Refer to the sensor documentation for the meaning of each option.

Values:

enumerator MODE_UNSPEC

lidar mode: unspecified

enumerator MODE_512x10

lidar mode: 10 scans of 512 columns per second

enumerator MODE_512x20

lidar mode: 20 scans of 512 columns per second

enumerator MODE_1024x10

lidar mode: 10 scans of 1024 columns per second

enumerator MODE_1024x20

lidar mode: 20 scans of 1024 columsn per second

enumerator MODE_2048x10

lidar mode: 10 scans of 2048 columns per second

uint32_t ouster::sensor::n_cols_of_lidar_mode(lidar_mode mode)

Get number of columns in a scan for a lidar mode.

Parameters

mode[in] lidar_mode to get the number of columns for.

Returns

number of columns per rotation for the mode.

int ouster::sensor::frequency_of_lidar_mode(lidar_mode mode)

Get the lidar rotation frequency from lidar mode.

Parameters

mode[in] Lidar mode to get the rotation frequency from.

Returns

lidar rotation frequency in Hz.

std::string ouster::sensor::to_string(lidar_mode mode)

Get string representation of a lidar mode.

Parameters

mode[in] lidar_mode to get the string representation for.

Returns

string representation of the lidar mode, or “UNKNOWN”.

lidar_mode ouster::sensor::lidar_mode_of_string(const std::string &s)

Get lidar mode from string.

Parameters

s[in] String to decode.

Returns

lidar mode corresponding to the string, or 0 on error.

Timestamp Mode

enum ouster::sensor::timestamp_mode

Mode controlling timestamp method. Refer to the sensor documentation for the meaning of each option.

Values:

enumerator TIME_FROM_UNSPEC

Timestamp mode unspecified.

enumerator TIME_FROM_INTERNAL_OSC

Use the internal clock.

enumerator TIME_FROM_SYNC_PULSE_IN

A free running counter synced to the SYNC_PULSE_IN input counts seconds (# of pulses) and nanoseconds since sensor turn on.

enumerator TIME_FROM_PTP_1588

Synchronize with an external PTP master.

std::string ouster::sensor::to_string(timestamp_mode mode)

Get string representation of a timestamp mode.

Parameters

mode[in] timestamp_mode to get the string representation for.

Returns

string representation of the timestamp mode, or “UNKNOWN”.

timestamp_mode ouster::sensor::timestamp_mode_of_string(const std::string &s)

Get timestamp mode from string.

Parameters

s[in] String to decode into a timestamp mode.

Returns

timestamp mode corresponding to the string, or 0 on error.

Operating Mode

enum ouster::sensor::OperatingMode

Mode controlling sensor operation. Refer to the sensor documentation for the meaning of each option.

Values:

enumerator OPERATING_NORMAL

Normal sensor operation.

enumerator OPERATING_STANDBY

Standby.

std::string ouster::sensor::to_string(OperatingMode mode)

Get string representation of an operating mode.

Parameters

mode[in] Operating mode to get the string representation from.

Returns

string representation of the operating mode, or “UNKNOWN”.

optional<OperatingMode> ouster::sensor::operating_mode_of_string(const std::string &s)

Get operating mode from string.

Parameters

s – String to get the operating mode from.

Returns

operating mode corresponding to the string, or 0 on error.

Multipurpose IO Mode

enum ouster::sensor::MultipurposeIOMode

Mode controlling ways to input timesync information. Refer to the sensor documentation for the meaning of each option.

Values:

enumerator MULTIPURPOSE_OFF

Multipurpose IO is turned off (default)

enumerator MULTIPURPOSE_INPUT_NMEA_UART

Used in conjunction with timestamp_mode::TIME_FROM_SYNC_PULSE_IN to enable time pulses in on the multipurpose io input.

enumerator MULTIPURPOSE_OUTPUT_FROM_INTERNAL_OSC

Output a SYNC_PULSE_OUT signal synchronized with the internal clock.

enumerator MULTIPURPOSE_OUTPUT_FROM_SYNC_PULSE_IN

Output a SYNC_PULSE_OUT signal synchronized with a SYNC_PULSE_IN provided to the unit.

enumerator MULTIPURPOSE_OUTPUT_FROM_PTP_1588

Output a SYNC_PULSE_OUT signal synchronized with an external PTP IEEE 1588 master.

enumerator MULTIPURPOSE_OUTPUT_FROM_ENCODER_ANGLE

Output a SYNC_PULSE_OUT signal with a user defined rate in an integer number of degrees.

std::string ouster::sensor::to_string(MultipurposeIOMode mode)

Get string representation of a multipurpose io mode.

Parameters

mode[in] Multipurpose io mode to get a string representation from.

Returns

string representation of the multipurpose io mode, or “UNKNOWN”.

optional<MultipurposeIOMode> ouster::sensor::multipurpose_io_mode_of_string(const std::string &s)

Get multipurpose io mode from string.

Parameters

s[in] String to decode into a multipurpose io mode.

Returns

multipurpose io mode corresponding to the string, or 0 on error.

Polarity

enum ouster::sensor::Polarity

Polarity represents polarity of NMEA UART and SYNC_PULSE inputs and outputs. See sensor docs for more details.

Values:

enumerator POLARITY_ACTIVE_LOW

ACTIVE_LOW.

enumerator POLARITY_ACTIVE_HIGH

ACTIVE_HIGH.

std::string ouster::sensor::to_string(Polarity polarity)

Get string representation of a polarity.

Parameters

polarity[in] The polarity to get the string representation of.

Returns

string representation of the polarity, or “UNKNOWN”.

optional<Polarity> ouster::sensor::polarity_of_string(const std::string &s)

Get polarity from string.

Parameters

s[in] The string to decode into a polarity.

Returns

polarity corresponding to the string, or 0 on error.

NMEA Baud Rate

enum ouster::sensor::NMEABaudRate

Baud rate the sensor attempts for NMEA UART input $GPRMC messages See sensor docs for more details.

Values:

enumerator BAUD_9600

9600 bits per second UART baud rate

enumerator BAUD_115200

115200 bits per second UART baud rate

std::string ouster::sensor::to_string(NMEABaudRate rate)

Get string representation of a NMEA Baud Rate.

Parameters

rate[in] The NNEABaudRate to get the string representation of.

Returns

string representation of the NMEA baud rate, or “UNKNOWN”.

optional<NMEABaudRate> ouster::sensor::nmea_baud_rate_of_string(const std::string &s)

Get nmea baud rate from string.

Parameters

s[in] The string to decode into a NMEA baud rate.

Returns

nmea baud rate corresponding to the string, or 0 on error.

UDP Profile Lidar

enum ouster::sensor::UDPProfileLidar

Profile indicating packet format of lidar data.

Values:

enumerator PROFILE_LIDAR_LEGACY

Legacy lidar data

enumerator PROFILE_RNG19_RFL8_SIG16_NIR16_DUAL

Dual Returns data

enumerator PROFILE_RNG19_RFL8_SIG16_NIR16

Single Returns data

enumerator PROFILE_RNG15_RFL8_NIR8

Single Returns Low Data Rate

std::string ouster::sensor::to_string(UDPProfileLidar profile)

Get string representation of a lidar profile.

Parameters

profile[in] The profile to get the string representation of.

Returns

string representation of the lidar profile.

optional<UDPProfileLidar> ouster::sensor::udp_profile_lidar_of_string(const std::string &s)

Get lidar profile from string.

Parameters

s[in] The string to decode into a lidar profile.

Returns

lidar profile corresponding to the string, or nullopt on error.

UDP Profile IMU

enum ouster::sensor::UDPProfileIMU

Profile indicating packet format of IMU data.

Values:

enumerator PROFILE_IMU_LEGACY

Legacy IMU data.

std::string ouster::sensor::to_string(UDPProfileIMU profile)

Get string representation of an IMU profile.

Parameters

profile[in] The profile to get the string representation of.

Returns

string representation of the lidar profile.

optional<UDPProfileIMU> ouster::sensor::udp_profile_imu_of_string(const std::string &s)

Get imu profile from string

Parameters

s[in] The string to decode into an imu profile.

Returns

imu profile corresponding to the string, or nullopt on error.

Chan Field

enum ouster::sensor::ChanFieldType

Types of channel fields.

Values:

enumerator VOID
enumerator UINT8
enumerator UINT16
enumerator UINT32
enumerator UINT64
enum ouster::sensor::ChanField

Tag to identitify a paricular value reported in the sensor channel data block.

Values:

enumerator RANGE

1st return range

enumerator RANGE2

2nd return range

enumerator INTENSITY

Deprecated:

(gcc 5.4 doesn’t support annotations here)

enumerator SIGNAL

1st return signal

enumerator SIGNAL2

2nd return signal

enumerator REFLECTIVITY

1st return reflectivity

enumerator REFLECTIVITY2

2nd return reflectivity

enumerator AMBIENT
enumerator NEAR_IR

near_ir

enumerator FLAGS

1st return flags

enumerator FLAGS2

2nd return flags

enumerator RAW32_WORD1

raw word access to packet for dev use

enumerator RAW32_WORD2

raw word access to packet for dev use

enumerator RAW32_WORD3

raw word access to packet for dev use

enumerator RAW32_WORD4

raw word access to packet for dev use

enumerator CHAN_FIELD_MAX

max which allows us to introduce future fields

std::string ouster::sensor::to_string(ChanField field)

Get string representation of a channel field.

Parameters

field[in] The field to get the string representation of.

Returns

string representation of the channel field.

Sensor Info

struct ouster::sensor::sensor_info

Stores necessary information from sensor to parse and project sensor data.

Public Members

std::string name

Deprecated:

: will be removed in the next version

std::string sn

sensor serial number

std::string fw_rev

fw revision

lidar_mode mode

lidar mode of sensor

std::string prod_line

prod line

data_format format

data format of sensor

std::vector<double> beam_azimuth_angles

beam azimuth angles for 3D projection

std::vector<double> beam_altitude_angles

beam altitude angles for 3D projection

double lidar_origin_to_beam_origin_mm

distance between lidar origin and beam origin in mm

mat4d imu_to_sensor_transform

transform between sensor coordinate frame and imu

mat4d lidar_to_sensor_transform

transform between lidar and sensor coordinate frames

mat4d extrinsic

extrinsic matrix

uint32_t init_id

initialization ID updated every reinit

uint16_t udp_port_lidar

the lidar destination port

uint16_t udp_port_imu

the imu destination port

sensor_info ouster::sensor::default_sensor_info(lidar_mode mode)

Get a default sensor_info for the given lidar mode.

Parameters

mode[in] lidar mode to generate default sensor_info for.

Returns

default sensor_info for the OS1-64.

sensor_info ouster::sensor::parse_metadata(const std::string &metadata)

Parse metadata text blob from the sensor into a sensor_info struct.

String and vector fields will have size 0 if the parameter cannot be found or parsed, while lidar_mode will be set to 0 (invalid).

Throws

runtime_error – if the text is not valid json

Parameters

metadata[in] a text blob returned by get_metadata from client.h.

Returns

a sensor_info struct populated with a subset of the metadata.

sensor_info ouster::sensor::metadata_from_json(const std::string &json_file)

Parse metadata given path to a json file.

Throws

runtime_error – if json file does not exist or is malformed.

Parameters

json_file[in] path to a json file containing sensor metadata.

Returns

a sensor_info struct populated with a subset of the metadata.

std::string ouster::sensor::convert_to_legacy(const std::string &metadata)

Convert non-legacy string representation of metadata to legacy.

Parameters

metadata[in] non-legacy string representation of metadata.

Returns

legacy string representation of metadata.

bool ouster::sensor::operator==(const sensor_info &lhs, const sensor_info &rhs)

Equality for sensor_info.

Parameters
  • lhs[in] The first object to compare.

  • rhs[in] The second object to compare.

Returns

lhs == rhs

bool ouster::sensor::operator!=(const sensor_info &lhs, const sensor_info &rhs)

Not-Equality for sensor_info.

Parameters
  • lhs[in] The first object to compare.

  • rhs[in] The second object to compare.

Returns

lhs != rhs

std::string ouster::sensor::to_string(const sensor_info &info)

Get a string representation of metadata. All fields included.

Parameters

info[in] sensor_info struct

Returns

a json metadata string

Sensor Config

struct ouster::sensor::sensor_config

Struct for sensor configuration parameters.

Public Members

optional<std::string> udp_dest

The destination address for the lidar/imu data to be sent to

optional<int> udp_port_lidar

The destination port for the lidar data to be sent to

optional<int> udp_port_imu

The destination port for the imu data to be sent to.

optional<timestamp_mode> ts_mode

The timestamp mode for the sensor to use. Refer to timestamp_mode for more details.

optional<lidar_mode> ld_mode

The lidar mode for the sensor to use. Refer to lidar_mode for more details.

optional<OperatingMode> operating_mode

The operating mode for the sensor to use. Refer to OperatingMode for more details.

optional<MultipurposeIOMode> multipurpose_io_mode

The multipurpose io mode for the sensor to use. Refer to MultipurposeIOMode for more details.

optional<AzimuthWindow> azimuth_window

The azimuth window for the sensor to use. Refer to AzimuthWindow for more details.

optional<int> signal_multiplier

Multiplier for signal strength of sensor. See the sensor docs for more details on usage.

optional<Polarity> nmea_in_polarity

The nmea polarity for the sensor to use. Refer to Polarity for more details.

optional<bool> nmea_ignore_valid_char

Whether NMEA UART input $GPRMC messages should be ignored. Refer to the sensor docs for more details.

optional<NMEABaudRate> nmea_baud_rate

The nmea baud rate for the sensor to use. Refer to Polarity> for more details.

optional<int> nmea_leap_seconds

Number of leap seconds added to UDP timestamp. See the sensor docs for more details.

optional<Polarity> sync_pulse_in_polarity

Polarity of SYNC_PULSE_IN input. See Polarity for more details.

optional<Polarity> sync_pulse_out_polarity

Polarity of SYNC_PULSE_OUT output. See Polarity for more details.

optional<int> sync_pulse_out_angle

Angle in degrees that sensor traverses between each SYNC_PULSE_OUT pulse. See senor docs for more details.

optional<int> sync_pulse_out_pulse_width

Width of SYNC_PULSE_OUT pulse in ms. See sensor docs for more details.

optional<int> sync_pulse_out_frequency

Frequency of SYNC_PULSE_OUT pulse in Hz. See sensor docs for more details.

optional<bool> phase_lock_enable

Whether phase locking is enabled. See sensor docs for more details.

optional<int> phase_lock_offset

Angle that sensors are locked to in millidegrees. See sensor docs for more details.

optional<int> columns_per_packet

Columns per packet. See sensor docs for more details.

optional<UDPProfileLidar> udp_profile_lidar

The lidar profile for the sensor to use. Refer to UDPProfileLidar for more details.

optional<UDPProfileIMU> udp_profile_imu

The imu profile for the sensor to use. Refer to UDPProfileIMU for more details.

sensor_config ouster::sensor::parse_config(const std::string &config)

Parse config text blob from the sensor into a sensor_config struct.

All fields are optional, and will only be set if found.

Throws

runtime_error – if the text is not valid json.

Parameters

config[in] a text blob given by get_config from client.h.

Returns

a sensor_config struct populated with the sensor config. parameters.

bool ouster::sensor::operator==(const sensor_config &lhs, const sensor_config &rhs)

Equality for sensor config.

Parameters
  • lhs[in] The first object to compare.

  • rhs[in] The second object to compare.

Returns

lhs == rhs

bool ouster::sensor::operator!=(const sensor_config &lhs, const sensor_config &rhs)

Not-Equality for sensor config.

Parameters
  • lhs[in] The first object to compare.

  • rhs[in] The second object to compare.

Returns

lhs != rhs

std::string ouster::sensor::to_string(const sensor_config &config)

Get a string representation of sensor config. Only set fields will be represented.

Parameters

config[in] a struct of sensor config.

Returns

a json sensor config string.

Data Format

struct ouster::sensor::data_format

Stores data format information.

Public Members

uint32_t pixels_per_column

pixels per column

uint32_t columns_per_packet

columns per packet

uint32_t columns_per_frame

columns per frame, should match with lidar mode

std::vector<int> pixel_shift_by_row

shift of pixels by row to enable destagger

ColumnWindow column_window

window of columns over which sensor fires

UDPProfileLidar udp_profile_lidar

profile of lidar packet

UDPProfileIMU udp_profile_imu

profile of imu packet

bool ouster::sensor::operator==(const data_format &lhs, const data_format &rhs)

Equality for data_format.

Parameters
  • lhs[in] The first object to compare.

  • rhs[in] The second object to compare.

Returns

lhs == rhs

bool ouster::sensor::operator!=(const data_format &lhs, const data_format &rhs)

Not-Equality for data_format.

Parameters
  • lhs[in] The first object to compare.

  • rhs[in] The second object to compare.

Returns

lhs != rhs

Packet Format

class ouster::sensor::packet_format

Table of accessors for extracting data from imu and lidar packets.

In the user guide, refer to section 9 for the lidar packet format and section 10 for imu packets.

For 0 <= n < columns_per_packet, nth_col(n, packet_buf) returns a pointer to the nth measurement block. For 0 <= m < pixels_per_column, nth_px(m, col_buf) returns the mth channel data block.

Use imu_la_{x,y,z} to access the acceleration in the corresponding direction. Use imu_av_{x,y,z} to read the angular velocity.

Public Types

FieldIter = decltype(field_types_)::const_iterator

iterator over field types of packet

Public Functions

uint16_t packet_type(const uint8_t *lidar_buf) const

Read the packet type packet header.

Parameters

lidar_buf[in] the lidar buf.

Returns

the packet type.

uint16_t frame_id(const uint8_t *lidar_buf) const

Read the frame_id packet header.

Parameters

lidar_buf[in] the lidar buf.

Returns

the frame id.

uint32_t init_id(const uint8_t *lidar_buf) const

Read the initialization id packet header.

Parameters

lidar_buf[in] the lidar buf.

Returns

the init id.

uint64_t prod_sn(const uint8_t *lidar_buf) const

Read the packet serial number header.

Parameters

lidar_buf[in] the lidar buf.

Returns

the serial number.

ChanFieldType field_type(ChanField f) const

Get the bit width of the specified channel field.

Parameters

f[in] the channel field to query.

Returns

a type tag specifying the bitwidth of the requested field or ChannelFieldType::VOID if it is not supported by the packet format.

FieldIter begin() const

A const forward iterator over field / type pairs.

FieldIter end() const

A const forward iterator over field / type pairs.

const uint8_t *nth_col(int n, const uint8_t *lidar_buf) const

Get pointer to nth column of a lidar buffer.

Parameters
  • n[in] which column.

  • lidar_buf[in] the lidar buffer.

Returns

pointer to nth column of lidar buffer.

uint64_t col_timestamp(const uint8_t *col_buf) const

Read column timestamp from column buffer.

Parameters

col_buf[in] the column buffer.

Returns

column timestamp.

uint16_t col_measurement_id(const uint8_t *col_buf) const

Read measurement id from column buffer.

Parameters

col_buf[in] the column buffer.

Returns

column measurement id.

uint32_t col_status(const uint8_t *col_buf) const

Read column status from column buffer.

Parameters

col_buf[in] the column buffer.

Returns

column status.

uint32_t col_encoder(const uint8_t *col_buf) const

Deprecated:

uint16_t col_frame_id(const uint8_t *col_buf) const

Deprecated:

template<typename T, typename std::enable_if<std::is_unsigned<T>::value, T>::type = 0>
void col_field(const uint8_t *col_buf, ChanField f, T *dst, int dst_stride = 1) const

Copy the specified channel field out of a packet measurement block.

Template Parameters

T – T should be an unsigned integer type large enough to store values of the specified field. Otherwise, data will be truncated.

Parameters
  • col_buf[in] a measurement block pointer returned by nth_col().

  • f[in] the channel field to copy.

  • dst[out] destination array of size pixels_per_column * dst_stride.

  • dst_stride[in] stride for writing to the destination array.

const uint8_t *nth_px(int n, const uint8_t *col_buf) const

Get pointer to nth pixel of a column buffer.

Parameters
  • n[in] which pixel.

  • col_buf[in] the column buffer.

Returns

pointer to nth pixel of a column buffer.

uint32_t px_range(const uint8_t *px_buf) const

Read range from pixel buffer.

Parameters

px_buf[in] the pixel buffer.

Returns

range from pixel buffer.

uint16_t px_reflectivity(const uint8_t *px_buf) const

Read reflectivity from pixel buffer.

Parameters

px_buf[in] the pixel buffer.

Returns

reflectivity from pixel buffer.

uint16_t px_signal(const uint8_t *px_buf) const

Read signal from pixel buffer.

Parameters

px_buf[in] the pixel buffer.

Returns

signal from pixel buffer.

uint16_t px_ambient(const uint8_t *px_buf) const

Read ambient from pixel buffer.

Parameters

px_buf[in] the pixel buffer.

Returns

ambient from pixel buffer.

uint64_t imu_sys_ts(const uint8_t *imu_buf) const

Read sys ts from imu packet buffer.

Parameters

imu_buf[in] the imu packet buffer.

Returns

sys ts from imu pacet buffer.

uint64_t imu_accel_ts(const uint8_t *imu_buf) const

Read acceleration timestamp.

Parameters

imu_buf[in] the imu packet buffer.

Returns

acceleration ts from imu packet buffer.

uint64_t imu_gyro_ts(const uint8_t *imu_buf) const

Read gyro timestamp.

Parameters

imu_buf[in] the imu packet buffer.

Returns

gyro ts from imu packet buffer.

float imu_la_x(const uint8_t *imu_buf) const

Read acceleration in x.

Parameters

imu_buf[in] the imu packet buffer.

Returns

acceleration in x.

float imu_la_y(const uint8_t *imu_buf) const

Read acceleration in y.

Parameters

imu_buf[in] the imu packet buffer.

Returns

acceleration in y.

float imu_la_z(const uint8_t *imu_buf) const

Read acceleration in z.

Parameters

imu_buf[in] the imu packet buffer.

Returns

acceleration in z.

float imu_av_x(const uint8_t *imu_buf) const

Read angular velocity in x.

Parameters

imu_buf[in] the imu packet buffer.

Returns

angular velocity in x.

float imu_av_y(const uint8_t *imu_buf) const

Read angular velocity in y.

Parameters

imu_buf[in] the imu packet buffer.

Returns

angular velocity in y.

float imu_av_z(const uint8_t *imu_buf) const

Read angular velocity in z.

Parameters

imu_buf[in] the imu packet buffer.

Returns

angular velocity in z.

Public Members

const UDPProfileLidar udp_profile_lidar

udp lidar profile of packet format

const size_t lidar_packet_size

lidar packet size

const size_t imu_packet_size

imu packet size

const int columns_per_packet

columns per lidar packet

const int pixels_per_column

pixels per column for lidar

const int encoder_ticks_per_rev

Deprecated:

Friends

friend const packet_format &get_format(const sensor_info &info)

Declare get_format as friend.

Get a packet parser for a particular data format.

Parameters

info[in] parameters provided by the sensor.

Returns

a packet_format suitable for parsing UDP packets sent by the sensor.

struct Impl
const packet_format &ouster::sensor::get_format(const sensor_info &info)

Get a packet parser for a particular data format.

Parameters

info[in] parameters provided by the sensor.

Returns

a packet_format suitable for parsing UDP packets sent by the sensor.

MISC

std::string ouster::sensor::client_version()

Get client version.

Returns

client version string

double ouster::sensor::range_unit = 0.001

Unit of range from sensor packet, in meters.