|
livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
|
Pure-function protocol layer for the Livox Mid-360: framing, parsing and serialisation of control-command frames, point-cloud / IMU data packets and key-value lists. More...
#include <array>#include <cstddef>#include <cstdint>#include <expected>#include <span>#include <string_view>#include <vector>#include "livox/mid360/export.hpp"#include "livox/mid360/tag.hpp"Go to the source code of this file.
Classes | |
| struct | livox::mid360::CommandHeader |
| The 24-byte command frame header as decoded by parse_command_frame(). More... | |
| struct | livox::mid360::CommandFrameView |
| A validated, non-owning view over a command frame. More... | |
| struct | livox::mid360::CommandFrameSpec |
| What encode_command_frame() writes; length and both CRCs are computed from it. More... | |
| struct | livox::mid360::DataPacketHeader |
| The 36-byte data packet header as decoded by parse_data_packet(). More... | |
| struct | livox::mid360::DataPacketView |
| A validated, non-owning view over a data packet. More... | |
| struct | livox::mid360::CartesianPoint32 |
| One sample of data type 1 (kCartesian32). More... | |
| struct | livox::mid360::CartesianPoint16 |
| One sample of data type 2 (kCartesian16). More... | |
| struct | livox::mid360::SphericalPoint |
| One sample of data type 3 (kSpherical). More... | |
| struct | livox::mid360::ImuSample |
| The sample of an IMU packet (data type 0). More... | |
| struct | livox::mid360::KeyValue |
| One entry of a key-value list. Non-owning: value points into the parsed buffer. More... | |
| struct | livox::mid360::DiscoveryAck |
| Data of the 0x0000 discovery ACK. More... | |
| struct | livox::mid360::ParamConfigAck |
| Data of the 0x0100 parameter configuration ACK. More... | |
| struct | livox::mid360::ParamInquireAck |
| Data of the 0x0101 parameter inquire ACK. More... | |
| struct | livox::mid360::InfoPush |
| Data of the 0x0102 information push. More... | |
| struct | livox::mid360::SimpleAck |
| Data of an ACK that carries only a return code (0x0200, 0x0201, 0x0202, 0x0301, 0x0303). More... | |
Namespaces | |
| namespace | livox |
| Livox LiDAR drivers. | |
| namespace | livox::mid360 |
| The livox_mid360_core library: everything declared by the public headers. | |
Functions | |
Point cloud / IMU data packet | |
36-byte header + data. | |
| std::expected< DataPacketView, ParseError > | livox::mid360::parse_data_packet (std::span< const std::byte > packet, bool verify_crc=true) noexcept |
| Parses and validates a data packet (version, length, CRC32, data_type/dot_num consistency). | |
| constexpr std::size_t | livox::mid360::sample_size (DataType t) noexcept |
| Bytes per sample for a data type (0 for unknown). | |
| CartesianPoint32 | livox::mid360::decode_cartesian32 (const DataPacketView &p, std::size_t i) noexcept |
| Decodes the i-th sample. The caller guarantees data_type matches and i < dot_num. | |
| CartesianPoint16 | livox::mid360::decode_cartesian16 (const DataPacketView &p, std::size_t i) noexcept |
| Decodes the i-th sample, as decode_cartesian32() does for data type 2. | |
| SphericalPoint | livox::mid360::decode_spherical (const DataPacketView &p, std::size_t i) noexcept |
| Decodes the i-th sample, as decode_cartesian32() does for data type 3. | |
| ImuSample | livox::mid360::decode_imu (const DataPacketView &p, std::size_t i) noexcept |
| Decodes the i-th sample, as decode_cartesian32() does for data type 0. | |
| std::vector< CartesianPoint32 > | livox::mid360::decode_all_cartesian32 (const DataPacketView &p) |
| Whole-packet decoders (allocate). | |
| std::vector< CartesianPoint16 > | livox::mid360::decode_all_cartesian16 (const DataPacketView &p) |
| Whole-packet decoder for data type 2 (allocates). | |
| std::vector< SphericalPoint > | livox::mid360::decode_all_spherical (const DataPacketView &p) |
| Whole-packet decoder for data type 3 (allocates). | |
| std::vector< ImuSample > | livox::mid360::decode_all_imu (const DataPacketView &p) |
| Whole-packet decoder for data type 0 (allocates). | |
| std::uint64_t | livox::mid360::sample_timestamp_ns (const DataPacketHeader &h, std::size_t i) noexcept |
| Timestamp of the i-th sample: timestamp + i * time_interval / (dot_num - 1), in ns. | |
Key-value lists | |
0x0100 / 0x0101 / 0x0102 payloads. | |
| std::expected< std::vector< KeyValue >, ParseError > | livox::mid360::parse_key_value_list (std::span< const std::byte > in, std::size_t key_num) noexcept |
| Parses key_num consecutive {key u16, length u16, value[length]} entries. | |
| void | livox::mid360::append_key_value_list (std::vector< std::byte > &out, std::span< const KeyValue > kvs) |
| Encodes {key,length,value}* into out (appends). | |
| std::vector< std::byte > | livox::mid360::encode_param_config_request (std::span< const KeyValue > kvs) |
| 0x0100 REQ data: key_num u16, rsvd u16, key_value_list. | |
| std::vector< std::byte > | livox::mid360::encode_param_inquire_request (std::span< const std::uint16_t > keys) |
| 0x0101 REQ data: key_num u16, rsvd u16, key u16[key_num]. | |
| std::vector< std::byte > | livox::mid360::encode_reboot_request (std::uint16_t timeout_ms) |
| 0x0200 REQ data: timeout u16 (ms). | |
| std::vector< std::byte > | livox::mid360::encode_factory_reset_request () |
| 0x0201 REQ data: 16 reserved bytes (documented as "SN, reserved"). Zero-filled. | |
| std::vector< std::byte > | livox::mid360::encode_set_gps_timestamp_request (std::uint64_t pps_time_ns) |
| 0x0202 REQ data: type u8 (2 = GPS), time_set u64 (ns of last PPS rising edge). | |
| std::expected< DiscoveryAck, ParseError > | livox::mid360::parse_discovery_ack (std::span< const std::byte > data) noexcept |
| Parses the data of a discovery ACK (24 bytes). | |
| std::expected< ParamConfigAck, ParseError > | livox::mid360::parse_param_config_ack (std::span< const std::byte > data) noexcept |
| Parses the data of a parameter configuration ACK (3 bytes). | |
| std::expected< ParamInquireAck, ParseError > | livox::mid360::parse_param_inquire_ack (std::span< const std::byte > data) noexcept |
| Parses the data of a parameter inquire ACK: ret_code u8, key_num u16, key_value_list. | |
| std::expected< InfoPush, ParseError > | livox::mid360::parse_info_push (std::span< const std::byte > data) noexcept |
| Parses the data of a 0x0102 push: key_num u16, rsvd u16, key_value_list. | |
| std::expected< SimpleAck, ParseError > | livox::mid360::parse_simple_ack (std::span< const std::byte > data) noexcept |
| Parses the data of an ACK whose first byte is the return code. | |
Variables | |
Constants | |
| constexpr std::uint16_t | livox::mid360::kDiscoveryPort = 56000 |
| LiDAR discovery port (0x0000). | |
| constexpr std::uint16_t | livox::mid360::kCommandPort = 56100 |
| LiDAR control command port. | |
| constexpr std::uint16_t | livox::mid360::kPushPort = 56200 |
| LiDAR-side source port for 0x0102 push. | |
| constexpr std::uint16_t | livox::mid360::kPointCloudPort = 56300 |
| LiDAR-side source port for point cloud. | |
| constexpr std::uint16_t | livox::mid360::kImuPort = 56400 |
| LiDAR-side source port for IMU. | |
| constexpr std::uint16_t | livox::mid360::kLogPort = 56500 |
| LiDAR log port (0x03xx, #44). | |
| constexpr std::uint16_t | livox::mid360::kDebugDataPort = 60301 |
| LiDAR-side source port of the debug raw data stream (#93, verified in #106). | |
| constexpr std::uint16_t | livox::mid360::kDefaultHostCommandPort = 56101 |
| host port for commands | |
| constexpr std::uint16_t | livox::mid360::kDefaultHostPushPort = 56201 |
| host port for 0x0102 push | |
| constexpr std::uint16_t | livox::mid360::kDefaultHostPointCloudPort = 56301 |
| host port for point cloud | |
| constexpr std::uint16_t | livox::mid360::kDefaultHostImuPort = 56401 |
| host port for IMU | |
| constexpr std::uint16_t | livox::mid360::kDefaultHostLogPort = 56501 |
| firmware log (#44) | |
| constexpr std::uint16_t | livox::mid360::kDefaultHostDebugDataPort = 44332 |
| as SDK2 (#93) | |
| constexpr std::uint8_t | livox::mid360::kCommandSof = 0xAA |
| first byte of every command frame | |
| constexpr std::uint8_t | livox::mid360::kProtocolVersion = 0 |
| version of command frames and packets | |
| constexpr std::size_t | livox::mid360::kCommandHeaderSize = 24 |
| command frame header, sof .. crc32 | |
| constexpr std::size_t | livox::mid360::kCommandFrameMaxSize = 1400 |
| whole command frame | |
| constexpr std::size_t | livox::mid360::kCommandDataMaxSize = kCommandFrameMaxSize - kCommandHeaderSize |
| Largest command payload that fits a frame. | |
| constexpr std::size_t | livox::mid360::kDataPacketHeaderSize = 36 |
| version .. timestamp | |
| constexpr std::size_t | livox::mid360::kPointsPerPacket = 96 |
| N for data_type 1, 2 and 3. | |
Enumerations | |
| enum class | livox::mid360::CmdId : std::uint16_t { livox::mid360::kDiscovery = 0x0000 , livox::mid360::kParamConfig = 0x0100 , livox::mid360::kParamInquire = 0x0101 , livox::mid360::kInfoPush = 0x0102 , livox::mid360::kReboot = 0x0200 , livox::mid360::kFactoryReset = 0x0201 , livox::mid360::kSetGpsTimestamp = 0x0202 , livox::mid360::kPushLog = 0x0300 , livox::mid360::kCollectionLog = 0x0301 , livox::mid360::kDebugDataControl = 0x0303 } |
| Command IDs (cmd_id of the command frame header). More... | |
| enum class | livox::mid360::CmdType : std::uint8_t { livox::mid360::kReq = 0x00 , livox::mid360::kAck = 0x01 } |
| Request or acknowledgement (cmd_type of the command frame header). More... | |
| enum class | livox::mid360::SenderType : std::uint8_t { livox::mid360::kHost = 0x00 , livox::mid360::kLidar = 0x01 } |
| Originator of a command frame (sender_type of the header). More... | |
| enum class | livox::mid360::RetCode : std::uint8_t { kSuccess = 0x00 , kFailure = 0x01 , kNotPermitNow = 0x02 , kOutOfRange = 0x03 , kParamNotSupport = 0x20 , kParamRebootEffect = 0x21 , kParamReadOnly = 0x22 , kParamInvalidLen = 0x23 , kParamKeyNumErr = 0x24 , kUpgradePubKeyError = 0x30 , kUpgradeDigestError = 0x31 , kUpgradeFwTypeError = 0x32 , kUpgradeFwOutOfRange = 0x33 , kUpgradeFwErasing = 0x34 } |
| Result code carried as the first byte of every ACK. | |
| enum class | livox::mid360::WorkState : std::uint8_t { kSampling = 0x01 , kIdle = 0x02 , kError = 0x04 , kSelfCheck = 0x05 , kMotorStartup = 0x06 , kUpgrade = 0x08 , kReady = 0x09 } |
| LiDAR working state (key 0x8006 cur_work_state / 0x001A work_tgt_mode). More... | |
| enum class | livox::mid360::DataType : std::uint8_t { livox::mid360::kImu = 0 , livox::mid360::kCartesian32 = 1 , livox::mid360::kCartesian16 = 2 , livox::mid360::kSpherical = 3 } |
| Sample format of a data packet (data_type of the header). More... | |
| enum class | livox::mid360::TimeType : std::uint8_t { livox::mid360::kNoSync = 0 , livox::mid360::kPtp = 1 , livox::mid360::kGps = 2 } |
| Clock source of a data packet timestamp (time_type of the header). More... | |
| enum class | livox::mid360::ParseError : std::uint8_t { livox::mid360::kTooShort , livox::mid360::kBadSof , livox::mid360::kBadVersion , livox::mid360::kLengthMismatch , livox::mid360::kBadCrc16 , livox::mid360::kBadCrc32 , livox::mid360::kUnknownDataType , livox::mid360::kBadDotNum , livox::mid360::kTruncated , livox::mid360::kKeyNumMismatch } |
| Why a frame, packet or payload was rejected by the parsers in this header. More... | |
| std::string_view | livox::mid360::to_string (RetCode c) noexcept |
| Short name of a return code, for logs. | |
| std::string_view | livox::mid360::to_string (WorkState s) noexcept |
| Short name of a working state, for logs. | |
| std::string_view | livox::mid360::to_string (DataType t) noexcept |
| Short name of a data type, for logs. | |
| std::string_view | livox::mid360::to_string (TimeType t) noexcept |
| Short name of a time type, for logs. | |
| std::string_view | livox::mid360::to_string (ParseError e) noexcept |
| Short description of a parse error, for logs. | |
| std::string_view | livox::mid360::to_string (CmdId id) noexcept |
| Short name of a command ID, for logs. | |
Control command frame | |
24-byte header + data, max 1400 bytes. | |
| enum class | livox::mid360::EncodeError : std::uint8_t { livox::mid360::kDataTooLarge , livox::mid360::kBufferTooSmall } |
| Why encode_command_frame() or build_command_frame() failed. More... | |
| std::expected< CommandFrameView, ParseError > | livox::mid360::parse_command_frame (std::span< const std::byte > frame) noexcept |
| Parses and fully validates (SOF, version, length, CRC16, CRC32) one command frame. | |
| constexpr std::size_t | livox::mid360::command_frame_size (std::size_t data_size) noexcept |
| Total wire size of a frame carrying data_size payload bytes. | |
| std::expected< std::size_t, EncodeError > | livox::mid360::encode_command_frame (std::span< std::byte > out, const CommandFrameSpec &spec) noexcept |
| Serialises a frame into out, computing both CRCs. Returns bytes written. | |
| std::expected< std::vector< std::byte >, EncodeError > | livox::mid360::build_command_frame (const CommandFrameSpec &spec) |
| Convenience: allocate and serialise. | |
Pure-function protocol layer for the Livox Mid-360: framing, parsing and serialisation of control-command frames, point-cloud / IMU data packets and key-value lists.
Reference: "Livox LiDAR Communication Protocol - Mid360", wiki revision v1.4.12 (2026-09-21). Everything is UDP, little-endian. No I/O happens in this header.