Class LidarFrame

Class Documentation

class LidarFrame

Data structure for efficient operations on aggregated lidar data.

Stores each field (range, intensity, etc.) contiguously as a H x W block of 4-byte unsigned integers, where H is the number of beams and W is the horizontal resolution (e.g. 512, 1024, 2048).

Note: this is the “staggered” representation where each column corresponds to a single measurement in time. Use the destagger() function to create an image where columns correspond to a single azimuth angle.

Public Types

template<typename T>
using Header = Eigen::Array<T, Eigen::Dynamic, 1>

Header typedef.

Public Functions

LidarFrame()

The default constructor creates an invalid 0 x 0 frame.

LidarFrame(const DataFormat &format)

Initialize a frame with fields configured from the data format.

Deprecated:

Use “LidarFrame(std::shared_ptr<SensorInfo>)” instead. The last supported version for this will be 1.0.0 .

Parameters:

format[in] data format

LidarFrame(size_t h, size_t w)

Initialize a frame with fields configured for the LEGACY udp profile.

Note, the number of columns per packet is set to the default (DEFAULT_COLUMNS_PER_PACKET).

Deprecated:

Use “LidarFrame(h, w, field_types, columns_per_packet)” instead. The last supported version for this will be 1.0.0 .

Parameters:
  • h[in] vertical resolution, i.e. the number of channels.

  • w[in] horizontal resolution, i.e. the number of measurements per frame.

LidarFrame(const SensorInfo &sensor_info)

Initialize a frame with fields configured as default for the provided SensorInfo’s configuration.

Deprecated:

Use “LidarFrame(std::shared_ptr<SensorInfo>)” instead. The last supported version for this will be 1.0.0 .

Parameters:

sensor_info[in] description of sensor to create frame for

LidarFrame(std::shared_ptr<SensorInfo> sensor_info)

Initialize a frame configured as default for the provided SensorInfo’s configuration.

Parameters:

sensor_info[in] a shared_ptr to the SensorInfo object

LidarFrame(std::shared_ptr<SensorInfo> sensor_info, const std::vector<FieldType> &field_types)

Initialize a frame for the given sensor info with either the default for the provided configuration or provided fields.

Parameters:
  • sensor_info[in] a shared_ptr to the SensorInfo object

  • field_types[in] fields to use in the lidar frame

LidarFrame(size_t h, size_t w, UDPProfileLidar profile, size_t columns_per_packet)

Initialize a frame with the default fields for a particular udp profile.

Deprecated:

Use “LidarFrame(h, w, field_types, columns_per_packet)” instead. The last supported version for this will be 1.0.0 .

Parameters:
  • h[in] vertical resolution, i.e. the number of channels.

  • w[in] horizontal resolution, i.e. the number of measurements per frame.

  • profile[in] udp profile.

  • columns_per_packet[in] The number of columns per packet, this argument is optional.

LidarFrame(size_t h, size_t w, const LidarFrameFieldTypes &field_types, size_t columns_per_packet)

Initialize a frame with a custom set of fields.

Parameters:
  • h[in] vertical resolution, i.e. the number of channels.

  • w[in] horizontal resoulution, i.e. the number of measurements per frame.

  • field_types[in] types and names of fields to add to the frame.

  • columns_per_packet[in] The number of columns per packet, this argument is optional.

LidarFrame(const LidarFrame &other)

Initialize a lidar frame from another lidar frame.

Parameters:

other[in] The other lidar frame to initialize from.

LidarFrame(const LidarFrame &other, const LidarFrameFieldTypes &fields)

Initialize a lidar frame from another with only the indicated fields.

Casts, zero pads or removes fields from the original frame if necessary.

Throws:

std::invalid_argument – if field dimensions are incompatible

Parameters:
  • other[in] The other lidar frame to initialize from.

  • fields[in] Fields to have in new lidar frame.

LidarFrame(LidarFrame &&other) noexcept

Initialize a lidar frame by moving from another lidar frame.

Note

after this operation the moved-from object is unusable.

Parameters:

other[in] The other lidar frame to initialize from.

LidarFrame &operator=(const LidarFrame &other)

Copy assignment.

Parameters:

other[in] The lidar frame to copy from.

LidarFrame &operator=(LidarFrame &&other) noexcept

Move assignment.

Note

after this operation the moved-from object is unusable.

Parameters:

other[in] The lidar frame to move from.

~LidarFrame()

Lidar frame destructor.

ShotLimitingStatus shot_limiting() const

Get frame shot limiting status.

Returns:

true if sensor is shot limiting

ThermalShutdownStatus thermal_shutdown() const

Get frame thermal shutdown status.

Returns:

true if sensor is in thermal shutdown state.

template<typename T>
inline Eigen::Ref<img_t<T>> field(const std::string &f)

Access a lidar data field.

Supported

field<T>() supports element types uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, float16_t, and double.

Throws:
  • std::invalid_argument – if T does not match the runtime field type.

  • std::out_of_range – if field is not present

Template Parameters:

T – The type parameter T must match the dynamic type of the field. See the constructor documentation for expected field types or query dynamically for generic operations.

Parameters:

f[in] the field to view.

Returns:

a view of the field data.

template<typename T>
inline Eigen::Ref<const img_t<T>> field(const std::string &f) const

Access a lidar data field.

Supported

Same element types as the non-const field() template above.

Throws:
  • std::invalid_argument – if T does not match the runtime field type.

  • std::out_of_range – if field is not present

Template Parameters:

T – The type parameter T must match the dynamic type of the field. See the constructor documentation for expected field types or query dynamically for generic operations.

Parameters:

f[in] the field to view.

Returns:

a view of the field data.

Field &field(const std::string &name)

Access a lidar data field.

Throws:

std::out_of_range – if field is not present

Parameters:

name[in] string key of the field to access

Returns:

Field reference of the requested field

const Field &field(const std::string &name) const

Access a lidar data field.

Throws:

std::out_of_range – if field is not present

Parameters:

name[in] string key of the field to access

Returns:

Field reference of the requested field

bool has_field(const std::string &name) const

Check if a field exists.

Parameters:

name[in] string key of the field to check

Returns:

true if the lidar frame has the field, else false

Field &add_field(const std::string &name, FieldDescriptor d, FieldClass field_class = FieldClass::PIXEL_FIELD)

Add a new zero-filled field to lidar frame.

Throws:

std::invalid_argument – if key duplicates a preexisting field, or if flags dimensional requirements are not met

Parameters:
  • name[in] string key of the field to add

  • d[in] descriptor of the field to add

  • field_class[in] class to be assigned to the field, e.g. PIXEL_FIELD

Returns:

field

Field &add_field(const FieldType &type)

Add a new zero-filled field to lidar frame.

Throws:

std::invalid_argument – if key duplicates a preexisting field

Parameters:

type[in] Descriptor of the field to add.

Returns:

field The value of the field added.

Field del_field(const std::string &name)

Release the field and remove it from lidar frame.

Throws:

std::invalid_argument – if field under key does not exist

Parameters:

name[in] string key of the field to remove

Returns:

field The deleted field.

FieldType field_type(const std::string &name) const

Get the type of the specified field.

Parameters:

name[in] the string key of the field to query.

Returns:

the type associated with the field.

LidarFrameFieldTypes field_types() const

Get the FieldType of all fields in the frame.

Returns:

The type associated with every field in the frame.

std::unordered_map<std::string, Field> &fields()

Reference to the internal fields map.

Returns:

The unordered map of field type and field.

const std::unordered_map<std::string, Field> &fields() const

Reference to the internal fields map.

Returns:

The unordered map of field type and field.

std::unordered_map<std::string, std::vector<Object>> &objects()

Reference to the internal objects map.

Returns:

The unordered map of names and object lists.

const std::unordered_map<std::string, std::vector<Object>> &objects() const

Reference to the internal objects map.

Returns:

The unordered map of names and object lists.

Eigen::Ref<Header<uint64_t>> timestamp()

Access the measurement timestamp headers.

Returns:

a view of timestamp as a w-element vector.

Eigen::Ref<const Header<uint64_t>> timestamp() const

Access the measurement timestamp headers.

Returns:

a view of timestamp as a w-element vector.

Eigen::Ref<Header<uint64_t>> packet_timestamp()

Access the packet timestamp headers (usually host time).

Returns:

a view of timestamp as a vector with w / columns-per-packet elements.

Eigen::Ref<const Header<uint64_t>> packet_timestamp() const

Access the host timestamp headers (usually host time).

Returns:

a view of timestamp as a vector with w / columns-per-packet elements.

Eigen::Ref<Header<uint8_t>> alert_flags()

Access the packet alert flags headers.

Returns:

a view of timestamp as a vector with w / columns-per-packet elements.

Eigen::Ref<const Header<uint8_t>> alert_flags() const

Access the packet alert flags headers.

Returns:

a view of timestamp as a vector with w / columns-per-packet elements.

ArrayView1<ZoneState> zones()

Access the zone monitor states.

If zone states are not present, returns an empty view.

Returns:

a view of zone monitor states

ConstArrayView1<ZoneState> zones() const

Access the zone monitor states.

If zone states are not present, returns an empty view.

Returns:

a view of zone monitor states

uint64_t get_first_valid_packet_timestamp() const

Return the first valid packet timestamp from any packet type.

Throws:

std::runtime_error – if no valid packets are available

Returns:

the first valid packet timestamp

uint64_t get_first_valid_packet_timestamp(PacketType stream) const

Return the first valid packet timestamp for a specific packet type.

Parameters:

stream[in] the packet type to query

Throws:

std::runtime_error – if no valid packets are available

Returns:

the first valid packet timestamp for the given type

uint64_t get_last_valid_packet_timestamp() const

Return the last valid packet timestamp from any packet type.

Throws:

std::runtime_error – if no valid packets are available

Returns:

the last valid packet timestamp

uint64_t get_last_valid_packet_timestamp(PacketType stream) const

Return the last valid packet timestamp for a specific packet type.

Parameters:

stream[in] the packet type to query

Throws:

std::runtime_error – if no valid packets are available

Returns:

the last valid packet timestamp for the given type

uint64_t get_min_valid_packet_timestamp() const

Return the min valid packet timestamp from any packet type.

Throws:

std::runtime_error – if no valid packets are available

Returns:

the min valid packet timestamp

uint64_t get_min_valid_packet_timestamp(PacketType stream) const

Return the min valid packet timestamp for a specific packet type.

Parameters:

stream[in] the packet type to query

Throws:

std::runtime_error – if no valid packets are available

Returns:

the min valid packet timestamp for the given type

uint64_t get_max_valid_packet_timestamp() const

Return the max valid packet timestamp from any packet type.

Throws:

std::runtime_error – if no valid packets are available

Returns:

the max valid packet timestamp

uint64_t get_max_valid_packet_timestamp(PacketType stream) const

Return the max valid packet timestamp for a specific packet type.

Parameters:

stream[in] the packet type to query

Throws:

std::runtime_error – if no valid packets are available

Returns:

the max valid packet timestamp for the given type

uint64_t get_first_valid_lidar_packet_timestamp() const

Return the first valid lidar packet timestamp.

Deprecated:

Use “LidarFrame::get_first_valid_packet_timestamp(PacketType::Lidar)” instead. The last supported version for this will be 1.0.0 .

Returns:

the first valid lidar packet timestamp, 0 if none available

uint64_t get_last_valid_lidar_packet_timestamp() const

Return the last valid lidar packet timestamp.

Deprecated:

Use “LidarFrame::get_last_valid_packet_timestamp(PacketType::Lidar)” instead. The last supported version for this will be 1.0.0 .

Returns:

the last valid lidar packet timestamp, 0 if none available

int get_first_valid_column() const

Return the first valid column index.

Throws:

std::runtime_error – if no valid columns are available

Returns:

the first valid column index

int get_last_valid_column() const

Return the last valid column index.

Throws:

std::runtime_error – if no valid columns are available

Returns:

the last valid column index

Eigen::Ref<Header<uint16_t>> measurement_id()

Access the measurement id headers.

Returns:

a view of measurement ids as a w-element vector.

Eigen::Ref<const Header<uint16_t>> measurement_id() const

Access the measurement id headers.

Returns:

a view of measurement ids as a w-element vector.

Eigen::Ref<Header<uint32_t>> status()

Access the measurement status headers.

Returns:

a view of measurement statuses as a w-element vector.

Eigen::Ref<const Header<uint32_t>> status() const

Access the measurement status headers.

Returns:

a view of measurement statuses as a w-element vector.

Field &body_to_world()

Access the array of body-to-world transforms (per each timestamp).

Cast to ArrayView3<double> in order to access as 3d

Returns:

3d field of homogenous pose matrices, shaped (w, 4, 4).

const Field &body_to_world() const

Access the array of body-to-world transforms (per each timestamp).

Cast to ArrayView3<double> in order to access as 3d

Returns:

3d field of homogenous pose matrices, shaped (w, 4, 4).

Field &pose()

Access the array of body-to-world transforms (per each timestamp).

Cast to ArrayView3<double> in order to access as 3d

Deprecated:

Deprecated:

Use “LidarFrame::body_to_world()” instead. The last supported version for this will be 1.0.0 .

Returns:

3d field of homogenous pose matrices, shaped (w, 4, 4).

const Field &pose() const

Access the array of body-to-world transforms (per each timestamp).

Cast to ArrayView3<double> in order to access as 3d

Deprecated:

Deprecated:

Use “LidarFrame::body_to_world()” instead. The last supported version for this will be 1.0.0 .

Deprecated:

Use “LidarFrame::body_to_world()” instead. The last supported version for this will be 1.0.0 .

Returns:

3d field of homogenous pose matrices, shaped (w, 4, 4).

void set_column_pose(int index, const Matrix4dR &pose)

Set accessor for a column pose.

Parameters:
  • index[in] The column index to set the pose for.

  • pose[in] The pose to set for the column as a 4x4 matrix

Throws:

std::out_of_range – if index is out of bounds

Matrix4dR get_column_pose(int index) const

Get accessor for a column pose.

Parameters:

index[in] The column index to get the pose for.

Throws:

std::out_of_range – if index is out of bounds

Returns:

The pose of the column (index) as a 4x4 matrix.

bool complete(ColumnWindow window) const

Assess completeness of frame.

Parameters:

window[in] The column window to use for validity assessment

Returns:

whether all columns within given column window were valid

bool complete() const

Assess completeness of frame.

Throws:

std::runtime_error – if the LidarFrame does not have an associated sensor_info

Returns:

whether all columns within the column window were valid

size_t packet_count() const

Returns the number of lidar packets needed to fill this frame.

Returns:

the number of packets

bool equals(const LidarFrame &other) const

Equality for frames.

Parameters:

other[in] The other frame to compare to.

Returns:

if a == b.

Public Members

size_t w = {0}

Frame horizontal resolution.

Warning

Members variables: use with caution, some of these will become private.

size_t h = {0}

Frame vertical resolution.

Warning

Members variables: use with caution, some of these will become private.

uint64_t frame_status = {0}

Frame status - information from the packet header which corresponds to a frame.

Warning

Member variables: use with caution, some of these will become private.

uint8_t shutdown_countdown = {0}

Thermal shutdown counter.

Please refer to the firmware documentation for more information.

uint8_t shot_limiting_countdown = {0}

Shot limiting counter.

Please refer to the firmware documentation for more information.

int64_t frame_id = {-1}

The current frame ID.

Warning

Members variables: use with caution, some of these will become private.

std::shared_ptr<SensorInfo> sensor_info

The associated sensor info for this lidar frame.