|
livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
|
Key definitions and typed encoders/decoders for the Mid-360 key-value list (section "0x0102 LiDAR Information Push", table of keys). More...
#include <algorithm>#include <array>#include <cstddef>#include <cstdint>#include <expected>#include <optional>#include <span>#include <string>#include <string_view>#include <type_traits>#include <vector>#include "livox/mid360/export.hpp"#include "livox/mid360/protocol.hpp"Go to the source code of this file.
Namespaces | |
| namespace | livox |
| Livox LiDAR drivers. | |
| namespace | livox::mid360 |
| The livox_mid360_core library: everything declared by the public headers. | |
Concepts | |
| concept | livox::mid360::typed_key |
| Satisfied by every key that has key_traits. | |
| concept | livox::mid360::writable_key |
| Satisfied by keys that may be written with Device::set<K>(). | |
Typedefs | |
Key traits | |
key_traits<K> (issue #57): the C++ type of each key and its codec, used by Device::set<K>() / get<K>(). Writable keys have encode (bytes for a KeyValue) and decode; read-only keys only decode. Keys of the Mid-360S / 360L (kSpeedMode, kPcFreqMod) have no traits on purpose (project decision, docs/roadmap.md). | |
| template<Key K> | |
| using | livox::mid360::key_value_t = typename key_traits<K>::value_type |
| The C++ type of key K, e.g. key_value_t<Key::kPclDataType> is DataType. | |
Functions | |
| std::string_view | livox::mid360::to_string (Key k) noexcept |
| Wire name of the key, e.g. "pcl_data_type". | |
| constexpr bool | livox::mid360::is_read_only (Key k) noexcept |
| True for the 0x8000 range (inquire / push only). | |
| std::optional< std::size_t > | livox::mid360::key_value_length (Key k) noexcept |
| Fixed value length documented for the key, or nullopt if variable/unknown. | |
| std::optional< std::span< const std::byte > > | livox::mid360::find_key (std::span< const KeyValue > kvs, Key key) noexcept |
| Finds the first entry with key in a parsed list. | |
Encoders | |
Encoders: produce the raw value bytes for a key (to be wrapped in a KeyValue). | |
| std::array< std::byte, 1 > | livox::mid360::encode_u8 (std::uint8_t v) noexcept |
| One byte. | |
| std::array< std::byte, 1 > | livox::mid360::encode_bool (bool v) noexcept |
| u8 0 / 1. | |
| std::array< std::byte, 1 > | livox::mid360::encode_fov_enable (FovEnable e) noexcept |
| Key 0x0017 bitmask. | |
|
template<typename E> requires std::is_enum_v<E> && std::is_same_v<std::underlying_type_t<E>, std::uint8_t> | |
| std::array< std::byte, 1 > | livox::mid360::encode_enum_u8 (E v) noexcept |
| u8 enums (DataType, DetectMode, WorkState, ...). | |
| std::array< std::byte, 8 > | livox::mid360::encode_host_ip_config (const HostIpConfig &c) noexcept |
| Keys 0x0005 / 0x0006 / 0x0007 / 0x0009: ip, dst port, src port. | |
| std::array< std::byte, 12 > | livox::mid360::encode_lidar_ip_config (const LidarIpConfig &c) noexcept |
| Key 0x0004: ip, netmask, gateway. | |
| std::array< std::byte, 24 > | livox::mid360::encode_install_attitude (const InstallAttitude &a) noexcept |
| Key 0x0012: three float angles, then three int32 offsets. | |
| std::array< std::byte, 20 > | livox::mid360::encode_fov_config (const FovConfig &f) noexcept |
| Keys 0x0015 / 0x0016. | |
| std::array< std::byte, 4 > | livox::mid360::encode_func_io_config (const FuncIoConfig &c) noexcept |
| Key 0x0019: in0, in1, out0, out1. | |
| std::array< std::byte, 3 > | livox::mid360::encode_imu_sensor_config (const ImuSensorConfig &c) noexcept |
| Key 0x002B: rate, accel range, gyro range. | |
Decoders | |
Decoders: parse a key's raw value bytes. Length is validated. | |
| std::expected< std::uint8_t, KeyError > | livox::mid360::decode_u8 (std::span< const std::byte > v) noexcept |
| One byte. | |
| std::expected< std::uint16_t, KeyError > | livox::mid360::decode_u16 (std::span< const std::byte > v) noexcept |
| Little-endian u16. | |
| std::expected< std::uint32_t, KeyError > | livox::mid360::decode_u32 (std::span< const std::byte > v) noexcept |
| Little-endian u32. | |
| std::expected< std::int32_t, KeyError > | livox::mid360::decode_i32 (std::span< const std::byte > v) noexcept |
| Little-endian i32. | |
| std::expected< std::uint64_t, KeyError > | livox::mid360::decode_u64 (std::span< const std::byte > v) noexcept |
| Little-endian u64. | |
| std::expected< std::int64_t, KeyError > | livox::mid360::decode_i64 (std::span< const std::byte > v) noexcept |
| Little-endian i64. | |
| std::expected< HostIpConfig, KeyError > | livox::mid360::decode_host_ip_config (std::span< const std::byte > v) noexcept |
| Keys 0x0005 / 0x0006 / 0x0007 / 0x0009. | |
| std::expected< LidarIpConfig, KeyError > | livox::mid360::decode_lidar_ip_config (std::span< const std::byte > v) noexcept |
| Key 0x0004. Not checked with lidar_ip_config_valid(). | |
| std::expected< InstallAttitude, KeyError > | livox::mid360::decode_install_attitude (std::span< const std::byte > v) noexcept |
| Key 0x0012. Not checked with install_attitude_valid(). | |
| std::expected< FovConfig, KeyError > | livox::mid360::decode_fov_config (std::span< const std::byte > v) noexcept |
| Keys 0x0015 / 0x0016. Not checked with fov_in_range(). | |
| std::expected< FuncIoConfig, KeyError > | livox::mid360::decode_func_io_config (std::span< const std::byte > v) noexcept |
| Key 0x0019; a field outside its enum is kOutOfRange. | |
| std::expected< ImuSensorConfig, KeyError > | livox::mid360::decode_imu_sensor_config (std::span< const std::byte > v) noexcept |
| Key 0x002B; a field outside its enum is kOutOfRange. | |
| std::expected< Version, KeyError > | livox::mid360::decode_version (std::span< const std::byte > v) noexcept |
| Keys 0x8002 / 0x8003 / 0x8004. | |
| std::expected< std::array< std::uint8_t, 6 >, KeyError > | livox::mid360::decode_mac (std::span< const std::byte > v) noexcept |
| Key 0x8005. | |
| std::expected< WorkState, KeyError > | livox::mid360::decode_work_state (std::span< const std::byte > v) noexcept |
| Keys 0x001A / 0x8006; a value that is not a WorkState enumerator is kOutOfRange. | |
| std::expected< bool, KeyError > | livox::mid360::decode_bool (std::span< const std::byte > v) noexcept |
| u8 0 / 1; anything else is kOutOfRange. | |
| std::expected< DataType, KeyError > | livox::mid360::decode_data_type (std::span< const std::byte > v) noexcept |
| key 0x0000: 1, 2 or 3 (0 = IMU is not a point-cloud data type). | |
| std::expected< ScanPattern, KeyError > | livox::mid360::decode_scan_pattern (std::span< const std::byte > v) noexcept |
| Key 0x0001: 0, 1 or 2. | |
| std::expected< DetectMode, KeyError > | livox::mid360::decode_detect_mode (std::span< const std::byte > v) noexcept |
| Key 0x0018: 0 or 1. | |
| std::expected< TimeSyncType, KeyError > | livox::mid360::decode_time_sync_type (std::span< const std::byte > v) noexcept |
| Key 0x800C: 0, 1 or 2. | |
| std::expected< FwType, KeyError > | livox::mid360::decode_fw_type (std::span< const std::byte > v) noexcept |
| Key 0x8010: 0 or 1. | |
| std::expected< FovEnable, KeyError > | livox::mid360::decode_fov_enable (std::span< const std::byte > v) noexcept |
| key 0x0017; bits above bit 1 are kOutOfRange. | |
| std::expected< DiagStatus, KeyError > | livox::mid360::decode_diag_status (std::span< const std::byte > v) noexcept |
| Key 0x800E; a nibble above 3 is kOutOfRange. | |
| std::expected< std::array< std::uint32_t, 8 >, KeyError > | livox::mid360::decode_hms_codes (std::span< const std::byte > v) noexcept |
| Key 0x8011: the eight raw slots; see decode_hms(). | |
| std::string_view | livox::mid360::decode_string (std::span< const std::byte > v) noexcept |
| NUL-padded string keys (0x8000 sn, 0x8001 product_info). Returns the text before the first NUL. | |
Typed values | |
| enum class | livox::mid360::ScanPattern : std::uint8_t { kNonRepetitive = 0 , kRepetitive = 1 , kLowRateRepetitive = 2 } |
| key 0x0001. More... | |
| enum class | livox::mid360::DetectMode : std::uint8_t { kNormal = 0 , kSensitive = 1 } |
| Key 0x0018: detection sensitivity. | |
| enum class | livox::mid360::FuncIn0 : std::uint8_t { livox::mid360::kPps = 0 } |
| Pin functions of key 0x0019 (issue #52). More... | |
| enum class | livox::mid360::FuncIn1 : std::uint8_t { livox::mid360::kGps = 0 } |
| Function of pin IN1 (key 0x0019). More... | |
| enum class | livox::mid360::FuncOut : std::uint8_t { livox::mid360::kNone = 0 , livox::mid360::kFollowInput = 1 , livox::mid360::kSafetyZone = 2 } |
| Function of pins OUT0 / OUT1 (key 0x0019). More... | |
| enum class | livox::mid360::ImuOutputRate : std::uint8_t { k200Hz = 0 , k500Hz = 1 , k100Hz = 2 , k50Hz = 3 } |
| IMU output rate (key 0x002B byte 0). | |
| enum class | livox::mid360::ImuAccelRange : std::uint8_t { k4g = 0 , k8g = 1 , k16g = 2 , k32g = 3 } |
| Accelerometer full-scale range (key 0x002B byte 1). | |
| enum class | livox::mid360::ImuGyroRange : std::uint8_t { k2000dps = 0 , k1000dps = 1 , k500dps = 2 , k250dps = 3 , k125dps = 4 , k62_5dps = 5 , k31_25dps = 6 , k15_625dps = 7 } |
| Gyroscope full-scale range in degrees per second (key 0x002B byte 2). | |
| enum class | livox::mid360::TimeSyncType : std::uint8_t { kNone = 0 , kPtp = 1 , kGps = 2 } |
| Key 0x800C: the time source the LiDAR is synchronised to. | |
| enum class | livox::mid360::DiagLevel : std::uint8_t { kNormal = 0 , kWarning = 1 , kError = 2 , kSafetyError = 3 } |
| key 0x800E: per-module abnormality level 0 normal / 1 warning / 2 error / 3 safety_err. More... | |
| enum class | livox::mid360::FwType : std::uint8_t { kLoader = 0 , kApp = 1 } |
| Key 0x8010: which firmware image is running. | |
| using | livox::mid360::Ipv4 = std::array<std::uint8_t, 4> |
| IPv4 address in network order, e.g. {192, 168, 1, 12}. | |
| bool | livox::mid360::fov_in_range (const FovConfig &f) noexcept |
| What a Mid-360 accepts for a FOV window (#268): yaw in [0, 360] and pitch in [-10, 60], both ends included, and start <= stop for both. | |
| bool | livox::mid360::lidar_ip_config_valid (const LidarIpConfig &c) noexcept |
| Key 0x0004 sanity (issue #50): ip neither 0.0.0.0 nor 255.255.255.255 nor the subnet's network / broadcast address, netmask a contiguous prefix of 1 to 30 bits, gateway either 0.0.0.0 (none) or inside the subnet and different from ip. | |
| bool | livox::mid360::install_attitude_valid (const InstallAttitude &a) noexcept |
| Key 0x0012 sanity (issue #51): the three angles finite and within [-180, 180] degrees. | |
| bool | livox::mid360::func_io_config_valid (const FuncIoConfig &c) noexcept |
| Key 0x0019 sanity (issue #52): every field within its enum. | |
Key definitions and typed encoders/decoders for the Mid-360 key-value list (section "0x0102 LiDAR Information Push", table of keys).
Scope (v1): the base Mid-360 only. Keys that exist solely for Mid-360S/360L (0x0021 speed_mode, 0x0029 pc_freq_mod) are listed for completeness but not modelled.