Class Zrb

Class Documentation

class Zrb

This class represents a zone as a pair of range images (with mm units) and associated metadata, which it encodes in the Zone Rendered Binary (ZRB) file format.

The ZRB file format is a compact representation of the near and far range images for a zone, along with metadata about the rendering process. The near and far range images are stored as 16-bit unsigned integers, with a scale factor (m_per_zmbin) used to convert the encoded values to actual ranges in meters. The ZRB file also includes information about the sensor that rendered the zone, including its serial number and an optional hash of the STL used during rendering.

The ZRB file format is designed to be efficient for storage and transmission, while still providing enough information to accurately reconstruct the zone’s geometry when needed. Note that the encoding of ranges into 16-bit values introduces a minor loss of range precision.

Public Functions

Zrb()

Default constructor for Zrb.

Initializes an empty Zrb object.

explicit Zrb(const std::string &path)

Constructs a Zrb object from a file path.

Parameters:

path[in] – The path to the ZRB file.

Throws:

std::runtime_error – if the file cannot be read or is not a valid ZRB file.

explicit Zrb(std::istream &input_stream)

Constructs a Zrb object from an input stream.

Parameters:

input_stream[in] – The input stream containing the ZRB file data.

Throws:

std::runtime_error – if the stream cannot be read or is not a valid ZRB file.

explicit Zrb(const std::vector<uint8_t> &blob)

Constructs a Zrb object from a binary blob.

Parameters:

blob[in] – The binary blob containing the ZRB file data.

Throws:

std::runtime_error – if the blob is not a valid ZRB file.

Zrb(uint32_t n_rows, uint32_t n_cols, float m_per_zmbin, uint64_t serial_number, Sha256 stl_hash, const mat4d &beam_to_lidar, const mat4d &lidar_to_sensor, const mat4d &sensor_to_body)

Constructs a Zrb object with the specified parameters.

Parameters:
  • n_rows[in] – The number of rows for near and far images.

  • n_cols[in] – The number of columns for near and far images. 16-bit unsigned values.

  • m_per_zmbin[in] – The scale factor for converting encoded ranges to Zrb.

  • serial_number[in] – The serial number of the sensor deploying the Zrb.

  • stl_hash[in] – A hash of the STL used during rendering.

  • beam_to_lidar[in] – The beam to lidar transform used during rendering.

  • lidar_to_sensor[in] – The lidar to sensor transform used during rendering.

  • sensor_to_body[in] – The sensor to body transform used during rendering.

std::vector<uint8_t> blob() const

Encodes the ZRB data into a binary blob and returns it.

Note

This operation is lossy due to the 16-bit encoding of ranges.

Returns:

A vector of bytes representing the ZRB file data.

void save(std::ostream &out) const

Writes the ZRB data to an output stream.

Note

This operation is lossy due to the 16-bit encoding of ranges.

Parameters:

out[in] – The output stream to write the ZRB data to.

void save(const std::string &file_path) const

Writes the ZRB data to a file.

Note

This operation is lossy due to the 16-bit encoding of ranges.

Parameters:

file_path[in] – The path to the file where the ZRB data will be written.

Sha256 hash() const

Computes the SHA-256 hash of the ZRB file data.

Note

This operation computes the hash on-the-fly and does not cache the result.

Returns:

The SHA-256 hash of the ZRB file data.

Public Members

img_t<uint32_t> near_range_mm

The near range image (units in mm)

img_t<uint32_t> far_range_mm

The far range image (units in mm)

nonstd::optional<Sha256> stl_hash

Optional hash of the STL used during rendering.

mat4d beam_to_lidar_transform = {mat4d::Zero()}

Beam to lidar transform used during rendering.

mat4d lidar_to_sensor_transform{mat4d::Zero()}

Lidar to sensor transform used during rendering.

mat4d sensor_to_body_transform{mat4d::Zero()}

Sensor to body transform used during rendering.

uint64_t serial_number = {0}

Serial number of the sensor that.

std::bitset<2048> valid_col_mask

Mask indicating which columns are valid.

Friends

friend bool operator==(const Zrb &lhs, const Zrb &rhs)

Compares two Zrb objects for equality.

Parameters:
  • lhs[in] – The first Zrb object.

  • rhs[in] – The second Zrb object.

Returns:

true if the two Zrb objects are equal, false otherwise.

friend bool operator!=(const Zrb &lhs, const Zrb &rhs)

Compares two Zrb objects for inequality.

Parameters:
  • lhs[in] – The first Zrb object.

  • rhs[in] – The second Zrb object.

Returns:

true if the two Zrb objects are not equal, false otherwise.