livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
Loading...
Searching...
No Matches
protocol.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
8#pragma once
9
10#include <array>
11#include <cstddef>
12#include <cstdint>
13#include <expected>
14#include <span>
15#include <string_view>
16#include <vector>
17
19#include "livox/mid360/tag.hpp"
20
21LIVOX_MID360_API_BEGIN
22namespace livox::mid360
23{
24
27
31inline constexpr std::uint16_t kDiscoveryPort = 56000;
32inline constexpr std::uint16_t kCommandPort = 56100;
33inline constexpr std::uint16_t kPushPort = 56200;
34inline constexpr std::uint16_t kPointCloudPort = 56300;
35inline constexpr std::uint16_t kImuPort = 56400;
36inline constexpr std::uint16_t kLogPort = 56500;
38inline constexpr std::uint16_t kDebugDataPort = 60301;
39
40inline constexpr std::uint16_t kDefaultHostCommandPort = 56101;
41inline constexpr std::uint16_t kDefaultHostPushPort = 56201;
42inline constexpr std::uint16_t kDefaultHostPointCloudPort = 56301;
43inline constexpr std::uint16_t kDefaultHostImuPort = 56401;
44inline constexpr std::uint16_t kDefaultHostLogPort = 56501;
45inline constexpr std::uint16_t kDefaultHostDebugDataPort = 44332;
46
47inline constexpr std::uint8_t kCommandSof = 0xAA;
48inline constexpr std::uint8_t kProtocolVersion = 0;
49inline constexpr std::size_t kCommandHeaderSize = 24;
50inline constexpr std::size_t kCommandFrameMaxSize = 1400;
53
54inline constexpr std::size_t kDataPacketHeaderSize = 36;
55inline constexpr std::size_t kPointsPerPacket = 96;
56
58
61
63enum class CmdId : std::uint16_t
64{
65 kDiscovery = 0x0000,
66 kParamConfig = 0x0100,
67 kParamInquire = 0x0101,
68 kInfoPush = 0x0102,
69 kReboot = 0x0200,
70 kFactoryReset = 0x0201,
72 kPushLog = 0x0300,
73 kCollectionLog = 0x0301,
74 // 0x0302 (log time sync) is defined by SDK2 but never used; 0x04xx (upgrade) is not modelled.
76};
77
79enum class CmdType : std::uint8_t
80{
81 kReq = 0x00,
82 kAck = 0x01
83};
84
85enum class SenderType : std::uint8_t
86{
87 kHost = 0x00,
88 kLidar = 0x01
89};
90
92enum class RetCode : std::uint8_t
93{
94 kSuccess = 0x00,
95 kFailure = 0x01,
96 kNotPermitNow = 0x02,
97 kOutOfRange = 0x03,
98 kParamNotSupport = 0x20,
99 kParamRebootEffect = 0x21,
100 kParamReadOnly = 0x22,
101 kParamInvalidLen = 0x23,
102 kParamKeyNumErr = 0x24,
103 kUpgradePubKeyError = 0x30,
104 kUpgradeDigestError = 0x31,
105 kUpgradeFwTypeError = 0x32,
106 kUpgradeFwOutOfRange = 0x33,
107 kUpgradeFwErasing = 0x34,
108};
109
112enum class WorkState : std::uint8_t
113{
114 kSampling = 0x01,
115 kIdle = 0x02,
116 kError = 0x04,
117 kSelfCheck = 0x05,
118 kMotorStartup = 0x06,
119 kUpgrade = 0x08,
120 kReady = 0x09,
121};
122
124enum class DataType : std::uint8_t
125{
126 kImu = 0,
130};
131
133enum class TimeType : std::uint8_t
134{
136 kPtp = 1,
137 kGps = 2,
138};
139
154
156[[nodiscard]] std::string_view to_string(RetCode c) noexcept;
158[[nodiscard]] std::string_view to_string(WorkState s) noexcept;
160[[nodiscard]] std::string_view to_string(DataType t) noexcept;
162[[nodiscard]] std::string_view to_string(TimeType t) noexcept;
164[[nodiscard]] std::string_view to_string(ParseError e) noexcept;
166[[nodiscard]] std::string_view to_string(CmdId id) noexcept;
167
169
173
176{
177 std::uint16_t length = 0;
178 std::uint32_t seq_num = 0;
179 std::uint16_t cmd_id = 0;
182 std::array<std::uint8_t, 6> resv{};
183 std::uint16_t crc16 = 0;
184 std::uint32_t crc32 = 0;
185};
186
189{
191 std::span<const std::byte> data;
192};
193
195[[nodiscard]] std::expected<CommandFrameView, ParseError> parse_command_frame(
196 std::span<const std::byte> frame) noexcept;
197
200{
201 std::uint32_t seq_num = 0;
202 std::uint16_t cmd_id = 0;
205 // The explicit {} keeps GCC -Wmissing-field-initializers quiet for designated initializers.
207 std::span<const std::byte> data{}; // NOLINT(readability-redundant-member-init)
208};
209
211enum class EncodeError : std::uint8_t
212{
215};
216
218[[nodiscard]] constexpr std::size_t command_frame_size(std::size_t data_size) noexcept
219{
220 return kCommandHeaderSize + data_size;
221}
222
224[[nodiscard]] std::expected<std::size_t, EncodeError> encode_command_frame(
225 std::span<std::byte> out, const CommandFrameSpec & spec) noexcept;
226
228[[nodiscard]] std::expected<std::vector<std::byte>, EncodeError> build_command_frame(
229 const CommandFrameSpec & spec);
230
232
236
239{
240 std::uint8_t version = 0;
241 std::uint16_t length = 0;
242 std::uint16_t time_interval = 0;
243 std::uint16_t dot_num = 0;
244 std::uint16_t udp_cnt = 0;
245 std::uint8_t frame_cnt = 0;
248 std::array<std::uint8_t, 12>
250 std::uint32_t crc32 = 0;
251 std::uint64_t timestamp_ns = 0;
252};
253
256{
258 std::span<const std::byte> data;
259};
260
264[[nodiscard]] std::expected<DataPacketView, ParseError> parse_data_packet(
265 std::span<const std::byte> packet, bool verify_crc = true) noexcept;
266
268[[nodiscard]] constexpr std::size_t sample_size(DataType t) noexcept
269{
270 switch (t) {
271 case DataType::kImu:
272 return 24;
274 return 14;
276 return 8;
278 return 10;
279 }
280 return 0;
281}
282
285{
286 std::int32_t x_mm;
287 std::int32_t y_mm;
288 std::int32_t z_mm;
289 std::uint8_t reflectivity;
290 std::uint8_t tag;
292 [[nodiscard]] constexpr TagInfo tag_info() const noexcept { return decode_tag(tag); }
293};
294
297{
298 std::int16_t x_cm;
299 std::int16_t y_cm;
300 std::int16_t z_cm;
301 std::uint8_t reflectivity;
302 std::uint8_t tag;
304 [[nodiscard]] constexpr TagInfo tag_info() const noexcept { return decode_tag(tag); }
305};
306
309{
310 std::uint32_t depth_mm;
311 std::uint16_t theta_centideg;
312 std::uint16_t phi_centideg;
313 std::uint8_t reflectivity;
314 std::uint8_t tag;
316 [[nodiscard]] constexpr TagInfo tag_info() const noexcept { return decode_tag(tag); }
317};
318
321{
322 float gyro_x;
323 float gyro_y;
324 float gyro_z;
325 float acc_x;
326 float acc_y;
327 float acc_z;
328};
329
331[[nodiscard]] CartesianPoint32 decode_cartesian32(const DataPacketView & p, std::size_t i) noexcept;
333[[nodiscard]] CartesianPoint16 decode_cartesian16(const DataPacketView & p, std::size_t i) noexcept;
335[[nodiscard]] SphericalPoint decode_spherical(const DataPacketView & p, std::size_t i) noexcept;
337[[nodiscard]] ImuSample decode_imu(const DataPacketView & p, std::size_t i) noexcept;
338
340[[nodiscard]] std::vector<CartesianPoint32> decode_all_cartesian32(const DataPacketView & p);
342[[nodiscard]] std::vector<CartesianPoint16> decode_all_cartesian16(const DataPacketView & p);
344[[nodiscard]] std::vector<SphericalPoint> decode_all_spherical(const DataPacketView & p);
346[[nodiscard]] std::vector<ImuSample> decode_all_imu(const DataPacketView & p);
347
350[[nodiscard]] std::uint64_t sample_timestamp_ns(const DataPacketHeader & h, std::size_t i) noexcept;
351
353
357
360{
361 std::uint16_t key;
362 std::span<const std::byte> value;
363};
364
366[[nodiscard]] std::expected<std::vector<KeyValue>, ParseError> parse_key_value_list(
367 std::span<const std::byte> in, std::size_t key_num) noexcept;
368
370void append_key_value_list(std::vector<std::byte> & out, std::span<const KeyValue> kvs);
371
373[[nodiscard]] std::vector<std::byte> encode_param_config_request(std::span<const KeyValue> kvs);
374
376[[nodiscard]] std::vector<std::byte> encode_param_inquire_request(
377 std::span<const std::uint16_t> keys);
378
380[[nodiscard]] std::vector<std::byte> encode_reboot_request(std::uint16_t timeout_ms);
381
383[[nodiscard]] std::vector<std::byte> encode_factory_reset_request();
384
386[[nodiscard]] std::vector<std::byte> encode_set_gps_timestamp_request(std::uint64_t pps_time_ns);
387
390{
392 std::uint8_t dev_type;
393 std::array<char, 16> serial_number;
394 std::array<std::uint8_t, 4> lidar_ip;
395 std::uint16_t cmd_port;
396
398 [[nodiscard]] std::string_view serial_number_view() const noexcept;
399};
400
403{
405 std::uint16_t error_key;
406};
407
410{
411 RetCode ret_code = RetCode::kSuccess;
412 std::vector<KeyValue> values;
413};
414
417{
418 std::vector<KeyValue> values;
419};
420
423{
425};
426
428[[nodiscard]] std::expected<DiscoveryAck, ParseError> parse_discovery_ack(
429 std::span<const std::byte> data) noexcept;
431[[nodiscard]] std::expected<ParamConfigAck, ParseError> parse_param_config_ack(
432 std::span<const std::byte> data) noexcept;
434[[nodiscard]] std::expected<ParamInquireAck, ParseError> parse_param_inquire_ack(
435 std::span<const std::byte> data) noexcept;
437[[nodiscard]] std::expected<InfoPush, ParseError> parse_info_push(
438 std::span<const std::byte> data) noexcept;
440[[nodiscard]] std::expected<SimpleAck, ParseError> parse_simple_ack(
441 std::span<const std::byte> data) noexcept;
442
444
445} // namespace livox::mid360
446LIVOX_MID360_API_END
Symbol visibility helpers.
The livox_mid360_core library: everything declared by the public headers.
Definition bytes.hpp:14
constexpr std::uint16_t kDebugDataPort
LiDAR-side source port of the debug raw data stream (#93, verified in #106).
Definition protocol.hpp:38
TimeType
Clock source of a data packet timestamp (time_type of the header).
Definition protocol.hpp:134
@ kNoSync
timestamp counts from LiDAR power-on
Definition protocol.hpp:135
std::expected< std::vector< KeyValue >, ParseError > 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 append_key_value_list(std::vector< std::byte > &out, std::span< const KeyValue > kvs)
Encodes {key,length,value}* into out (appends).
std::expected< CommandFrameView, ParseError > parse_command_frame(std::span< const std::byte > frame) noexcept
Parses and fully validates (SOF, version, length, CRC16, CRC32) one command frame.
constexpr std::uint16_t kDiscoveryPort
LiDAR discovery port (0x0000).
Definition protocol.hpp:31
constexpr std::size_t kPointsPerPacket
N for data_type 1, 2 and 3.
Definition protocol.hpp:55
constexpr std::uint16_t kDefaultHostImuPort
host port for IMU
Definition protocol.hpp:43
constexpr std::uint8_t kProtocolVersion
version of command frames and packets
Definition protocol.hpp:48
constexpr std::size_t kCommandDataMaxSize
Largest command payload that fits a frame.
Definition protocol.hpp:52
std::expected< InfoPush, ParseError > 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.
SenderType
Originator of a command frame (sender_type of the header).
Definition protocol.hpp:86
@ kHost
the host computer
Definition protocol.hpp:87
std::uint64_t 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.
constexpr std::uint16_t kDefaultHostCommandPort
host port for commands
Definition protocol.hpp:40
@ kGps
GPS input (M12 pin 10).
Definition keys.hpp:157
CartesianPoint16 decode_cartesian16(const DataPacketView &p, std::size_t i) noexcept
Decodes the i-th sample, as decode_cartesian32() does for data type 2.
std::expected< ParamConfigAck, ParseError > parse_param_config_ack(std::span< const std::byte > data) noexcept
Parses the data of a parameter configuration ACK (3 bytes).
std::vector< std::byte > encode_factory_reset_request()
0x0201 REQ data: 16 reserved bytes (documented as "SN, reserved"). Zero-filled.
std::expected< std::size_t, EncodeError > encode_command_frame(std::span< std::byte > out, const CommandFrameSpec &spec) noexcept
Serialises a frame into out, computing both CRCs. Returns bytes written.
constexpr std::uint16_t kPointCloudPort
LiDAR-side source port for point cloud.
Definition protocol.hpp:34
std::vector< std::byte > encode_param_inquire_request(std::span< const std::uint16_t > keys)
0x0101 REQ data: key_num u16, rsvd u16, key u16[key_num].
constexpr std::size_t kDataPacketHeaderSize
version .. timestamp
Definition protocol.hpp:54
std::expected< std::vector< std::byte >, EncodeError > build_command_frame(const CommandFrameSpec &spec)
Convenience: allocate and serialise.
std::vector< std::byte > encode_param_config_request(std::span< const KeyValue > kvs)
0x0100 REQ data: key_num u16, rsvd u16, key_value_list.
CartesianPoint32 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.
constexpr std::uint16_t kImuPort
LiDAR-side source port for IMU.
Definition protocol.hpp:35
std::vector< SphericalPoint > decode_all_spherical(const DataPacketView &p)
Whole-packet decoder for data type 3 (allocates).
std::expected< DiscoveryAck, ParseError > parse_discovery_ack(std::span< const std::byte > data) noexcept
Parses the data of a discovery ACK (24 bytes).
CmdId
Command IDs (cmd_id of the command frame header).
Definition protocol.hpp:64
@ kSetGpsTimestamp
set the time of the last PPS edge
Definition protocol.hpp:71
@ kPushLog
LiDAR → host on the log port; see firmware_log.hpp (#44).
Definition protocol.hpp:72
@ kFactoryReset
restore factory settings
Definition protocol.hpp:70
@ kInfoPush
LiDAR → host state push (key-value list).
Definition protocol.hpp:68
@ kParamInquire
read a list of keys
Definition protocol.hpp:67
@ kParamConfig
write a key-value list
Definition protocol.hpp:66
@ kDebugDataControl
host → LiDAR: start / stop debug raw data; debug_data.hpp (#93)
Definition protocol.hpp:75
@ kReboot
reboot after a timeout
Definition protocol.hpp:69
@ kCollectionLog
host → LiDAR port 56500: start / stop a log type
Definition protocol.hpp:73
@ kDiscovery
discovery request; the ACK is a DiscoveryAck
Definition protocol.hpp:65
std::expected< ParamInquireAck, ParseError > 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.
constexpr std::uint16_t kLogPort
LiDAR log port (0x03xx, #44).
Definition protocol.hpp:36
DataType
Sample format of a data packet (data_type of the header).
Definition protocol.hpp:125
@ kCartesian32
int32 mm, 14 bytes/point, default
Definition protocol.hpp:127
@ kCartesian16
int16 10 mm, 8 bytes/point
Definition protocol.hpp:128
@ kSpherical
depth mm + theta/phi 0.01 deg, 10 bytes/point
Definition protocol.hpp:129
@ kImu
ImuSample, 24 bytes, one per packet.
Definition protocol.hpp:126
constexpr std::size_t sample_size(DataType t) noexcept
Bytes per sample for a data type (0 for unknown).
Definition protocol.hpp:268
ImuSample decode_imu(const DataPacketView &p, std::size_t i) noexcept
Decodes the i-th sample, as decode_cartesian32() does for data type 0.
constexpr std::size_t kCommandFrameMaxSize
whole command frame
Definition protocol.hpp:50
constexpr std::size_t kCommandHeaderSize
command frame header, sof .. crc32
Definition protocol.hpp:49
std::vector< std::byte > encode_reboot_request(std::uint16_t timeout_ms)
0x0200 REQ data: timeout u16 (ms).
RetCode
Result code carried as the first byte of every ACK.
Definition protocol.hpp:93
std::expected< SimpleAck, ParseError > parse_simple_ack(std::span< const std::byte > data) noexcept
Parses the data of an ACK whose first byte is the return code.
constexpr std::uint8_t kCommandSof
first byte of every command frame
Definition protocol.hpp:47
constexpr std::uint16_t kCommandPort
LiDAR control command port.
Definition protocol.hpp:32
WorkState
LiDAR working state (key 0x8006 cur_work_state / 0x001A work_tgt_mode).
Definition protocol.hpp:113
std::expected< DataPacketView, ParseError > 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::uint16_t kPushPort
LiDAR-side source port for 0x0102 push.
Definition protocol.hpp:33
constexpr TagInfo decode_tag(std::uint8_t tag) noexcept
Splits a raw tag byte into its four fields.
Definition tag.hpp:40
SphericalPoint decode_spherical(const DataPacketView &p, std::size_t i) noexcept
Decodes the i-th sample, as decode_cartesian32() does for data type 3.
EncodeError
Why encode_command_frame() or build_command_frame() failed.
Definition protocol.hpp:212
@ kBufferTooSmall
output span cannot hold the frame
Definition protocol.hpp:214
@ kDataTooLarge
data exceeds kCommandDataMaxSize
Definition protocol.hpp:213
constexpr std::size_t command_frame_size(std::size_t data_size) noexcept
Total wire size of a frame carrying data_size payload bytes.
Definition protocol.hpp:218
constexpr std::uint16_t kDefaultHostDebugDataPort
as SDK2 (#93)
Definition protocol.hpp:45
CmdType
Request or acknowledgement (cmd_type of the command frame header).
Definition protocol.hpp:80
@ kReq
request
Definition protocol.hpp:81
@ kAck
acknowledgement of a request
Definition protocol.hpp:82
constexpr std::uint16_t kDefaultHostLogPort
firmware log (#44)
Definition protocol.hpp:44
constexpr std::uint16_t kDefaultHostPointCloudPort
host port for point cloud
Definition protocol.hpp:42
constexpr std::uint16_t kDefaultHostPushPort
host port for 0x0102 push
Definition protocol.hpp:41
@ kLidar
packet timestamp as is (use with PTP / GPS synchronisation)
Definition frame.hpp:103
ParseError
Why a frame, packet or payload was rejected by the parsers in this header.
Definition protocol.hpp:142
@ kTooShort
buffer shorter than the minimal header
Definition protocol.hpp:143
@ kBadVersion
protocol version != 0
Definition protocol.hpp:145
@ kKeyNumMismatch
key_num does not match the number of entries present
Definition protocol.hpp:152
@ kLengthMismatch
length field disagrees with the buffer size or exceeds 1400
Definition protocol.hpp:146
@ kBadSof
command frame does not start with 0xAA
Definition protocol.hpp:144
@ kBadDotNum
dot_num inconsistent with payload size / data_type
Definition protocol.hpp:150
@ kUnknownDataType
data_type not in 0..3
Definition protocol.hpp:149
@ kBadCrc16
command header CRC mismatch
Definition protocol.hpp:147
@ kBadCrc32
payload CRC mismatch
Definition protocol.hpp:148
@ kTruncated
a key-value list or fixed-layout payload ended early
Definition protocol.hpp:151
std::vector< std::byte > 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::string_view to_string(Event::Kind kind) noexcept
Name of an event kind, e.g. "state_changed".
@ kOutOfRange
a field is outside its enum or documented range
Definition keys.hpp:86
std::vector< CartesianPoint16 > decode_all_cartesian16(const DataPacketView &p)
Whole-packet decoder for data type 2 (allocates).
std::vector< CartesianPoint32 > decode_all_cartesian32(const DataPacketView &p)
Whole-packet decoders (allocate).
std::vector< ImuSample > decode_all_imu(const DataPacketView &p)
Whole-packet decoder for data type 0 (allocates).
One sample of data type 2 (kCartesian16).
Definition protocol.hpp:297
constexpr TagInfo tag_info() const noexcept
The decoded tag byte.
Definition protocol.hpp:304
std::uint8_t reflectivity
0-255
Definition protocol.hpp:301
std::int16_t x_cm
unit 10 mm
Definition protocol.hpp:298
std::int16_t y_cm
unit 10 mm
Definition protocol.hpp:299
std::int16_t z_cm
unit 10 mm
Definition protocol.hpp:300
std::uint8_t tag
raw tag byte
Definition protocol.hpp:302
One sample of data type 1 (kCartesian32).
Definition protocol.hpp:285
std::int32_t x_mm
mm
Definition protocol.hpp:286
std::int32_t y_mm
mm
Definition protocol.hpp:287
std::uint8_t reflectivity
0-255
Definition protocol.hpp:289
std::int32_t z_mm
mm
Definition protocol.hpp:288
constexpr TagInfo tag_info() const noexcept
The decoded tag byte.
Definition protocol.hpp:292
std::uint8_t tag
raw tag byte
Definition protocol.hpp:290
What encode_command_frame() writes; length and both CRCs are computed from it.
Definition protocol.hpp:200
std::uint16_t cmd_id
raw command ID, see CmdId
Definition protocol.hpp:202
CmdType cmd_type
request or ACK
Definition protocol.hpp:203
std::uint32_t seq_num
echoed by the ACK
Definition protocol.hpp:201
SenderType sender_type
host or LiDAR
Definition protocol.hpp:204
std::span< const std::byte > data
Payload, at most kCommandDataMaxSize bytes.
Definition protocol.hpp:207
A validated, non-owning view over a command frame.
Definition protocol.hpp:189
CommandHeader header
the validated header
Definition protocol.hpp:190
std::span< const std::byte > data
payload after the 24-byte header
Definition protocol.hpp:191
The 24-byte command frame header as decoded by parse_command_frame().
Definition protocol.hpp:176
std::uint32_t crc32
data CRC as carried on the wire (0 when data is empty)
Definition protocol.hpp:184
std::array< std::uint8_t, 6 > resv
reserved bytes, as carried on the wire
Definition protocol.hpp:182
SenderType sender_type
host or LiDAR
Definition protocol.hpp:181
std::uint16_t cmd_id
raw; compare against CmdId
Definition protocol.hpp:179
std::uint16_t crc16
header CRC as carried on the wire
Definition protocol.hpp:183
std::uint16_t length
sof .. end of data
Definition protocol.hpp:177
std::uint32_t seq_num
the ACK echoes the request's value
Definition protocol.hpp:178
CmdType cmd_type
request or ACK
Definition protocol.hpp:180
The 36-byte data packet header as decoded by parse_data_packet().
Definition protocol.hpp:239
std::uint8_t frame_cnt
invalid for non-repetitive scan
Definition protocol.hpp:245
TimeType time_type
clock source of timestamp_ns
Definition protocol.hpp:247
std::uint16_t length
whole UDP payload, from version
Definition protocol.hpp:241
std::uint64_t timestamp_ns
time of the first sample
Definition protocol.hpp:251
std::uint16_t udp_cnt
+1 per packet
Definition protocol.hpp:244
std::uint8_t version
kProtocolVersion
Definition protocol.hpp:240
std::uint16_t dot_num
number of samples in data
Definition protocol.hpp:243
std::uint16_t time_interval
unit 0.1 us; last point time - first point time
Definition protocol.hpp:242
DataType data_type
format of the samples in data
Definition protocol.hpp:246
std::uint32_t crc32
over timestamp + data
Definition protocol.hpp:250
std::array< std::uint8_t, 12 > reserved
wiki: "reserved"; diagram labels part of it pack_info
Definition protocol.hpp:249
A validated, non-owning view over a data packet.
Definition protocol.hpp:256
DataPacketHeader header
the validated header
Definition protocol.hpp:257
std::span< const std::byte > data
payload after the 36-byte header
Definition protocol.hpp:258
Data of the 0x0000 discovery ACK.
Definition protocol.hpp:390
std::uint16_t cmd_port
LiDAR command port.
Definition protocol.hpp:395
std::array< char, 16 > serial_number
NUL-padded.
Definition protocol.hpp:393
std::array< std::uint8_t, 4 > lidar_ip
IPv4 address, first octet first.
Definition protocol.hpp:394
std::uint8_t dev_type
raw device type; see DeviceType in session.hpp
Definition protocol.hpp:392
std::string_view serial_number_view() const noexcept
serial_number up to the first NUL.
RetCode ret_code
result of the request
Definition protocol.hpp:391
The sample of an IMU packet (data type 0).
Definition protocol.hpp:321
float acc_y
g
Definition protocol.hpp:326
float gyro_x
rad/s
Definition protocol.hpp:322
float gyro_y
rad/s
Definition protocol.hpp:323
float acc_x
g
Definition protocol.hpp:325
float gyro_z
rad/s
Definition protocol.hpp:324
float acc_z
g
Definition protocol.hpp:327
Data of the 0x0102 information push.
Definition protocol.hpp:417
std::vector< KeyValue > values
spans point into the input buffer
Definition protocol.hpp:418
One entry of a key-value list. Non-owning: value points into the parsed buffer.
Definition protocol.hpp:360
std::uint16_t key
raw key; see keys.hpp
Definition protocol.hpp:361
std::span< const std::byte > value
raw little-endian value bytes
Definition protocol.hpp:362
Data of the 0x0100 parameter configuration ACK.
Definition protocol.hpp:403
std::uint16_t error_key
only meaningful when ret_code != kSuccess
Definition protocol.hpp:405
RetCode ret_code
result of the request
Definition protocol.hpp:404
Data of the 0x0101 parameter inquire ACK.
Definition protocol.hpp:410
RetCode ret_code
result of the request
Definition protocol.hpp:411
std::vector< KeyValue > values
spans point into the input buffer
Definition protocol.hpp:412
Data of an ACK that carries only a return code (0x0200, 0x0201, 0x0202, 0x0301, 0x0303).
Definition protocol.hpp:423
RetCode ret_code
result of the request
Definition protocol.hpp:424
One sample of data type 3 (kSpherical).
Definition protocol.hpp:309
std::uint16_t phi_centideg
azimuth, [0, 36000], unit 0.01 deg
Definition protocol.hpp:312
std::uint8_t tag
raw tag byte
Definition protocol.hpp:314
std::uint32_t depth_mm
distance, mm
Definition protocol.hpp:310
std::uint16_t theta_centideg
zenith, [0, 18000], unit 0.01 deg
Definition protocol.hpp:311
std::uint8_t reflectivity
0-255
Definition protocol.hpp:313
constexpr TagInfo tag_info() const noexcept
The decoded tag byte.
Definition protocol.hpp:316
Decoded tag byte: bit 0-1 adjacent glue, 2-3 rain / fog / dust, 4-5 other, 6-7 reserved.
Definition tag.hpp:28
Point tag byte (issue #34): four 2-bit confidence fields, section "Tag Information".