livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
Loading...
Searching...
No Matches
keys.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
8#pragma once
9
10#include <algorithm>
11#include <array>
12#include <cstddef>
13#include <cstdint>
14#include <expected>
15#include <optional>
16#include <span>
17#include <string>
18#include <string_view>
19#include <type_traits>
20#include <vector>
21
24
25LIVOX_MID360_API_BEGIN
26namespace livox::mid360
27{
28
31enum class Key : std::uint16_t
32{
33 // ---- writable (0x0100) -------------------------------------------------
34 kPclDataType = 0x0000,
35 kPatternMode = 0x0001,
36 kLidarIpCfg = 0x0004,
39 kImuHostIpCfg = 0x0007,
40 kLogHostIpCfg = 0x0009,
42 kFovCfg0 = 0x0015,
43 kFovCfg1 = 0x0016,
44 kFovCfgEn = 0x0017,
45 kDetectMode = 0x0018,
46 kFuncIoCfg = 0x0019,
47 kWorkTgtMode = 0x001A,
48 kImuDataEn = 0x001C,
49 kSpeedMode = 0x0021,
50 kTimeFilter = 0x0026,
51 kPcFreqMod = 0x0029,
52 kImuSensorCfg = 0x002B,
53 // ---- read-only -----------------------------------------------------------
54 kSn = 0x8000,
55 kProductInfo = 0x8001,
56 kVersionApp = 0x8002,
57 kVersionLoader = 0x8003,
59 kMac = 0x8005,
60 kCurWorkState = 0x8006,
61 kCoreTemp = 0x8007,
62 kPowerupCnt = 0x8008,
63 kLocalTimeNow = 0x8009,
64 kLastSyncTime = 0x800A,
65 kTimeOffset = 0x800B,
66 kTimeSyncType = 0x800C,
68 kFwType = 0x8010,
69 kHmsCode = 0x8011,
70};
71
73[[nodiscard]] std::string_view to_string(Key k) noexcept;
75[[nodiscard]] constexpr bool is_read_only(Key k) noexcept
76{
77 return (static_cast<std::uint16_t>(k) & 0x8000u) != 0;
78}
79
80[[nodiscard]] std::optional<std::size_t> key_value_length(Key k) noexcept;
81
83enum class KeyError : std::uint8_t
84{
87};
88
91
93using Ipv4 = std::array<std::uint8_t, 4>;
94
97{
98 Ipv4 ip{};
99 std::uint16_t dst_port = 0;
100 std::uint16_t src_port = 0;
101};
102
110
113{
114 float roll_deg = 0;
115 float pitch_deg = 0;
116 float yaw_deg = 0;
117 std::int32_t x_mm = 0;
118 std::int32_t y_mm = 0;
119 std::int32_t z_mm = 0;
120};
121
124{
125 std::int32_t yaw_start_deg = 0;
126 std::int32_t yaw_stop_deg = 0;
127 std::int32_t pitch_start_deg = 0;
128 std::int32_t pitch_stop_deg = 0;
129 std::uint32_t rsvd = 0;
130};
131
134enum class ScanPattern : std::uint8_t
135{
136 kNonRepetitive = 0,
137 kRepetitive = 1,
138 kLowRateRepetitive = 2
139};
140
142enum class DetectMode : std::uint8_t
143{
144 kNormal = 0,
145 kSensitive = 1
146};
147
150enum class FuncIn0 : std::uint8_t
151{
152 kPps = 0,
153};
154
155enum class FuncIn1 : std::uint8_t
156{
157 kGps = 0,
158};
159
160enum class FuncOut : std::uint8_t
161{
162 kNone = 0,
165};
166
175
177enum class ImuOutputRate : std::uint8_t
178{
179 k200Hz = 0,
180 k500Hz = 1,
181 k100Hz = 2,
182 k50Hz = 3
183};
184
185enum class ImuAccelRange : std::uint8_t
186{
187 k4g = 0,
188 k8g = 1,
189 k16g = 2,
190 k32g = 3
191};
192
193enum class ImuGyroRange : std::uint8_t
194{
195 k2000dps = 0,
196 k1000dps = 1,
197 k500dps = 2,
198 k250dps = 3,
199 k125dps = 4,
200 k62_5dps = 5,
201 k31_25dps = 6,
202 k15_625dps = 7,
203};
204
206{
207 ImuOutputRate output_rate = ImuOutputRate::k200Hz;
208 ImuAccelRange accel_range = ImuAccelRange::k4g;
209 ImuGyroRange gyro_range = ImuGyroRange::k2000dps;
210};
211
214{
215 std::array<std::uint8_t, 4> v{};
216};
217
219enum class TimeSyncType : std::uint8_t
220{
221 kNone = 0,
222 kPtp = 1,
223 kGps = 2
224};
225
229enum class DiagLevel : std::uint8_t
230{
231 kNormal = 0,
232 kWarning = 1,
233 kError = 2,
234 kSafetyError = 3
235};
236
240{
241 DiagLevel system = DiagLevel::kNormal;
242 DiagLevel scan = DiagLevel::kNormal;
243 DiagLevel ranging = DiagLevel::kNormal;
244 DiagLevel communication = DiagLevel::kNormal;
245
247 [[nodiscard]] constexpr bool operator==(const DiagStatus &) const noexcept = default;
249 [[nodiscard]] constexpr DiagLevel worst() const noexcept
250 {
251 return std::max({system, scan, ranging, communication});
252 }
253
254 [[nodiscard]] constexpr bool normal() const noexcept { return worst() == DiagLevel::kNormal; }
255};
256
258enum class FwType : std::uint8_t
259{
260 kLoader = 0,
261 kApp = 1
262};
263
266{
267 bool fov0 = false;
268 bool fov1 = false;
269};
270
275{
276 std::optional<FovConfig> fov0;
277 std::optional<FovConfig> fov1;
278 std::optional<FovEnable> enable;
279};
280
285[[nodiscard]] bool fov_in_range(const FovConfig & f) noexcept;
290[[nodiscard]] bool lidar_ip_config_valid(const LidarIpConfig & c) noexcept;
294[[nodiscard]] bool install_attitude_valid(const InstallAttitude & a) noexcept;
298[[nodiscard]] bool func_io_config_valid(const FuncIoConfig & c) noexcept;
300
304
306[[nodiscard]] std::array<std::byte, 1> encode_u8(std::uint8_t v) noexcept;
308[[nodiscard]] std::array<std::byte, 1> encode_bool(bool v) noexcept;
310[[nodiscard]] std::array<std::byte, 1> encode_fov_enable(FovEnable e) noexcept;
312template <typename E>
313 requires std::is_enum_v<E> && std::is_same_v<std::underlying_type_t<E>, std::uint8_t>
314[[nodiscard]] std::array<std::byte, 1> encode_enum_u8(E v) noexcept
315{
316 return encode_u8(static_cast<std::uint8_t>(v));
317}
318
319[[nodiscard]] std::array<std::byte, 8> encode_host_ip_config(const HostIpConfig & c) noexcept;
321[[nodiscard]] std::array<std::byte, 12> encode_lidar_ip_config(const LidarIpConfig & c) noexcept;
323[[nodiscard]] std::array<std::byte, 24> encode_install_attitude(const InstallAttitude & a) noexcept;
325[[nodiscard]] std::array<std::byte, 20> encode_fov_config(const FovConfig & f) noexcept;
327[[nodiscard]] std::array<std::byte, 4> encode_func_io_config(const FuncIoConfig & c) noexcept;
329[[nodiscard]] std::array<std::byte, 3> encode_imu_sensor_config(const ImuSensorConfig & c) noexcept;
331
335
337[[nodiscard]] std::expected<std::uint8_t, KeyError> decode_u8(
338 std::span<const std::byte> v) noexcept;
340[[nodiscard]] std::expected<std::uint16_t, KeyError> decode_u16(
341 std::span<const std::byte> v) noexcept;
343[[nodiscard]] std::expected<std::uint32_t, KeyError> decode_u32(
344 std::span<const std::byte> v) noexcept;
346[[nodiscard]] std::expected<std::int32_t, KeyError> decode_i32(
347 std::span<const std::byte> v) noexcept;
349[[nodiscard]] std::expected<std::uint64_t, KeyError> decode_u64(
350 std::span<const std::byte> v) noexcept;
352[[nodiscard]] std::expected<std::int64_t, KeyError> decode_i64(
353 std::span<const std::byte> v) noexcept;
355[[nodiscard]] std::expected<HostIpConfig, KeyError> decode_host_ip_config(
356 std::span<const std::byte> v) noexcept;
358[[nodiscard]] std::expected<LidarIpConfig, KeyError> decode_lidar_ip_config(
359 std::span<const std::byte> v) noexcept;
361[[nodiscard]] std::expected<InstallAttitude, KeyError> decode_install_attitude(
362 std::span<const std::byte> v) noexcept;
364[[nodiscard]] std::expected<FovConfig, KeyError> decode_fov_config(
365 std::span<const std::byte> v) noexcept;
367[[nodiscard]] std::expected<FuncIoConfig, KeyError> decode_func_io_config(
368 std::span<const std::byte> v) noexcept;
370[[nodiscard]] std::expected<ImuSensorConfig, KeyError> decode_imu_sensor_config(
371 std::span<const std::byte> v) noexcept;
373[[nodiscard]] std::expected<Version, KeyError> decode_version(
374 std::span<const std::byte> v) noexcept;
376[[nodiscard]] std::expected<std::array<std::uint8_t, 6>, KeyError> decode_mac(
377 std::span<const std::byte> v) noexcept;
379[[nodiscard]] std::expected<WorkState, KeyError> decode_work_state(
380 std::span<const std::byte> v) noexcept;
382[[nodiscard]] std::expected<bool, KeyError> decode_bool(std::span<const std::byte> v) noexcept;
384[[nodiscard]] std::expected<DataType, KeyError> decode_data_type(
385 std::span<const std::byte> v) noexcept;
387[[nodiscard]] std::expected<ScanPattern, KeyError> decode_scan_pattern(
388 std::span<const std::byte> v) noexcept;
390[[nodiscard]] std::expected<DetectMode, KeyError> decode_detect_mode(
391 std::span<const std::byte> v) noexcept;
393[[nodiscard]] std::expected<TimeSyncType, KeyError> decode_time_sync_type(
394 std::span<const std::byte> v) noexcept;
396[[nodiscard]] std::expected<FwType, KeyError> decode_fw_type(std::span<const std::byte> v) noexcept;
398[[nodiscard]] std::expected<FovEnable, KeyError> decode_fov_enable(
399 std::span<const std::byte> v) noexcept;
401[[nodiscard]] std::expected<DiagStatus, KeyError> decode_diag_status(
402 std::span<const std::byte> v) noexcept;
404[[nodiscard]] std::expected<std::array<std::uint32_t, 8>, KeyError> decode_hms_codes(
405 std::span<const std::byte> v) noexcept;
407[[nodiscard]] std::string_view decode_string(std::span<const std::byte> v) noexcept;
409
411[[nodiscard]] std::optional<std::span<const std::byte>> find_key(
412 std::span<const KeyValue> kvs, Key key) noexcept;
413
420
421template <Key K>
422struct key_traits; // primary template: undefined for keys without a typed mapping
423
425template <Key K>
426concept typed_key = requires { typename key_traits<K>::value_type; };
428template <Key K>
430
432template <Key K>
435
436namespace detail
437{
438template <typename T, auto Enc, auto Dec>
439struct WritableTraits
440{
441 using value_type = T;
442 static constexpr bool writable = true;
443 [[nodiscard]] static auto encode(const T & v) noexcept { return Enc(v); }
444 [[nodiscard]] static std::expected<T, KeyError> decode(std::span<const std::byte> v) noexcept
445 {
446 return Dec(v);
447 }
448};
449template <typename T, auto Dec>
450struct ReadOnlyTraits
451{
452 using value_type = T;
453 static constexpr bool writable = false;
454 [[nodiscard]] static std::expected<T, KeyError> decode(std::span<const std::byte> v) noexcept
455 {
456 return Dec(v);
457 }
458};
459[[nodiscard]] inline std::expected<std::string, KeyError> decode_string_owned(
460 std::span<const std::byte> v) noexcept
461{
462 return std::string(decode_string(v));
463}
464} // namespace detail
465
466// clang-format off
467template <> struct key_traits<Key::kPclDataType>
468: detail::WritableTraits<DataType, encode_enum_u8<DataType>, decode_data_type> {};
469template <> struct key_traits<Key::kPatternMode>
470: detail::WritableTraits<ScanPattern, encode_enum_u8<ScanPattern>, decode_scan_pattern> {};
471template <> struct key_traits<Key::kLidarIpCfg>
472: detail::WritableTraits<LidarIpConfig, encode_lidar_ip_config, decode_lidar_ip_config> {};
474: detail::WritableTraits<HostIpConfig, encode_host_ip_config, decode_host_ip_config> {};
476: detail::WritableTraits<HostIpConfig, encode_host_ip_config, decode_host_ip_config> {};
477template <> struct key_traits<Key::kImuHostIpCfg>
478: detail::WritableTraits<HostIpConfig, encode_host_ip_config, decode_host_ip_config> {};
479template <> struct key_traits<Key::kLogHostIpCfg>
480: detail::WritableTraits<HostIpConfig, encode_host_ip_config, decode_host_ip_config> {};
481template <> struct key_traits<Key::kInstallAttitude>
482: detail::WritableTraits<InstallAttitude, encode_install_attitude, decode_install_attitude> {};
483template <> struct key_traits<Key::kFovCfg0>
484: detail::WritableTraits<FovConfig, encode_fov_config, decode_fov_config> {};
485template <> struct key_traits<Key::kFovCfg1>
486: detail::WritableTraits<FovConfig, encode_fov_config, decode_fov_config> {};
487template <> struct key_traits<Key::kFovCfgEn>
488: detail::WritableTraits<FovEnable, encode_fov_enable, decode_fov_enable> {};
489template <> struct key_traits<Key::kDetectMode>
490: detail::WritableTraits<DetectMode, encode_enum_u8<DetectMode>, decode_detect_mode> {};
491template <> struct key_traits<Key::kFuncIoCfg>
492: detail::WritableTraits<FuncIoConfig, encode_func_io_config, decode_func_io_config> {};
493template <> struct key_traits<Key::kWorkTgtMode>
494: detail::WritableTraits<WorkState, encode_enum_u8<WorkState>, decode_work_state> {};
495template <> struct key_traits<Key::kImuDataEn>
496: detail::WritableTraits<bool, encode_bool, decode_bool> {};
497template <> struct key_traits<Key::kTimeFilter>
498: detail::WritableTraits<bool, encode_bool, decode_bool> {};
499template <> struct key_traits<Key::kImuSensorCfg>
500: detail::WritableTraits<ImuSensorConfig, encode_imu_sensor_config, decode_imu_sensor_config> {};
501template <> struct key_traits<Key::kSn>
502: detail::ReadOnlyTraits<std::string, detail::decode_string_owned> {};
503template <> struct key_traits<Key::kProductInfo>
504: detail::ReadOnlyTraits<std::string, detail::decode_string_owned> {};
505template <> struct key_traits<Key::kVersionApp>
506: detail::ReadOnlyTraits<Version, decode_version> {};
507template <> struct key_traits<Key::kVersionLoader>
508: detail::ReadOnlyTraits<Version, decode_version> {};
509template <> struct key_traits<Key::kVersionHardware>
510: detail::ReadOnlyTraits<Version, decode_version> {};
511template <> struct key_traits<Key::kMac>
512: detail::ReadOnlyTraits<std::array<std::uint8_t, 6>, decode_mac> {};
513template <> struct key_traits<Key::kCurWorkState>
514: detail::ReadOnlyTraits<WorkState, decode_work_state> {};
515template <> struct key_traits<Key::kCoreTemp> // raw 0.01 degC units, not converted
516: detail::ReadOnlyTraits<std::int32_t, decode_i32> {};
517template <> struct key_traits<Key::kPowerupCnt>
518: detail::ReadOnlyTraits<std::uint32_t, decode_u32> {};
519template <> struct key_traits<Key::kLocalTimeNow>
520: detail::ReadOnlyTraits<std::uint64_t, decode_u64> {};
521template <> struct key_traits<Key::kLastSyncTime>
522: detail::ReadOnlyTraits<std::uint64_t, decode_u64> {};
523template <> struct key_traits<Key::kTimeOffset>
524: detail::ReadOnlyTraits<std::int64_t, decode_i64> {};
525template <> struct key_traits<Key::kTimeSyncType>
526: detail::ReadOnlyTraits<TimeSyncType, decode_time_sync_type> {};
527template <> struct key_traits<Key::kLidarDiagStatus>
528: detail::ReadOnlyTraits<DiagStatus, decode_diag_status> {};
529template <> struct key_traits<Key::kFwType>
530: detail::ReadOnlyTraits<FwType, decode_fw_type> {};
531template <> struct key_traits<Key::kHmsCode>
532: detail::ReadOnlyTraits<std::array<std::uint32_t, 8>, decode_hms_codes> {};
533// clang-format on
534
535} // namespace livox::mid360
536LIVOX_MID360_API_END
Satisfied by every key that has key_traits.
Definition keys.hpp:426
Satisfied by keys that may be written with Device::set<K>().
Definition keys.hpp:429
Symbol visibility helpers.
The livox_mid360_core library: everything declared by the public headers.
Definition bytes.hpp:14
DiagLevel
key 0x800E: per-module abnormality level 0 normal / 1 warning / 2 error / 3 safety_err.
Definition keys.hpp:230
std::array< std::byte, 1 > encode_bool(bool v) noexcept
u8 0 / 1.
std::expected< FuncIoConfig, KeyError > decode_func_io_config(std::span< const std::byte > v) noexcept
Key 0x0019; a field outside its enum is kOutOfRange.
std::optional< std::span< const std::byte > > find_key(std::span< const KeyValue > kvs, Key key) noexcept
Finds the first entry with key in a parsed list.
std::expected< HostIpConfig, KeyError > decode_host_ip_config(std::span< const std::byte > v) noexcept
Keys 0x0005 / 0x0006 / 0x0007 / 0x0009.
std::array< std::byte, 12 > encode_lidar_ip_config(const LidarIpConfig &c) noexcept
Key 0x0004: ip, netmask, gateway.
std::expected< WorkState, KeyError > 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< ScanPattern, KeyError > decode_scan_pattern(std::span< const std::byte > v) noexcept
Key 0x0001: 0, 1 or 2.
FuncOut
Function of pins OUT0 / OUT1 (key 0x0019).
Definition keys.hpp:161
@ kSafetyZone
safety zone output 0 / 1
Definition keys.hpp:164
@ kNone
output unused
Definition keys.hpp:162
@ kFollowInput
OUT0 follows IN0, OUT1 follows IN1.
Definition keys.hpp:163
bool 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,...
std::expected< bool, KeyError > decode_bool(std::span< const std::byte > v) noexcept
u8 0 / 1; anything else is kOutOfRange.
FuncIn1
Function of pin IN1 (key 0x0019).
Definition keys.hpp:156
@ kGps
GPS input (M12 pin 10).
Definition keys.hpp:157
std::expected< ImuSensorConfig, KeyError > decode_imu_sensor_config(std::span< const std::byte > v) noexcept
Key 0x002B; a field outside its enum is kOutOfRange.
Key
Keys of the key-value list (0x0100 configure, 0x0101 inquire, 0x0102 push).
Definition keys.hpp:32
@ kProductInfo
char[64]
Definition keys.hpp:55
@ kFuncIoCfg
u8[4] IN0, IN1, OUT0, OUT1
Definition keys.hpp:46
@ kVersionHardware
u8[4]
Definition keys.hpp:58
@ kStateInfoHostIpCfg
u8[8] ip, dst port, src port
Definition keys.hpp:37
@ kPclDataType
u8, DataType 1/2/3
Definition keys.hpp:34
@ kLidarDiagStatus
u16 bitfield
Definition keys.hpp:67
@ kImuHostIpCfg
u8[8]
Definition keys.hpp:39
@ kPcFreqMod
u8, 360L only (not modelled)
Definition keys.hpp:51
@ kVersionLoader
u8[4]
Definition keys.hpp:57
@ kDetectMode
u8 0 normal / 1 sensitive
Definition keys.hpp:45
@ kSn
char[16]
Definition keys.hpp:54
@ kFovCfgEn
u8 bitmask
Definition keys.hpp:44
@ kFwType
u8 0 loader / 1 app
Definition keys.hpp:68
@ kSpeedMode
u8, 360S/360L only (not modelled)
Definition keys.hpp:49
@ kLogHostIpCfg
u8[8] firmware log host (#44); SDK2 only reads it
Definition keys.hpp:40
@ kCurWorkState
u8 WorkState
Definition keys.hpp:60
@ kCoreTemp
i32, 0.01 degC
Definition keys.hpp:61
@ kPointCloudHostIpCfg
u8[8]
Definition keys.hpp:38
@ kFovCfg1
20 bytes
Definition keys.hpp:43
@ kPowerupCnt
u32
Definition keys.hpp:62
@ kTimeFilter
u8 0/1
Definition keys.hpp:50
@ kTimeOffset
i64 ns, local - source
Definition keys.hpp:65
@ kLocalTimeNow
u64 ns
Definition keys.hpp:63
@ kLastSyncTime
u64 ns
Definition keys.hpp:64
@ kPatternMode
u8 ScanPattern; a change restarts the motor
Definition keys.hpp:35
@ kHmsCode
u32[8]
Definition keys.hpp:69
@ kMac
u8[6]
Definition keys.hpp:59
@ kInstallAttitude
24 bytes: 3 float deg + 3 int mm
Definition keys.hpp:41
@ kImuSensorCfg
u8[3] rate, accel range, gyro range
Definition keys.hpp:52
@ kImuDataEn
u8 0/1
Definition keys.hpp:48
@ kLidarIpCfg
u8[12] ip, mask, gateway
Definition keys.hpp:36
@ kTimeSyncType
u8 0 none / 1 PTP / 2 GPS
Definition keys.hpp:66
@ kWorkTgtMode
u8 WorkState (1 SAMPLING, 2 IDLE, 9 READY)
Definition keys.hpp:47
@ kVersionApp
u8[4]
Definition keys.hpp:56
@ kFovCfg0
20 bytes
Definition keys.hpp:42
std::expected< std::uint16_t, KeyError > decode_u16(std::span< const std::byte > v) noexcept
Little-endian u16.
std::array< std::byte, 1 > encode_enum_u8(E v) noexcept
u8 enums (DataType, DetectMode, WorkState, ...).
Definition keys.hpp:314
std::array< std::byte, 24 > encode_install_attitude(const InstallAttitude &a) noexcept
Key 0x0012: three float angles, then three int32 offsets.
std::expected< std::uint32_t, KeyError > decode_u32(std::span< const std::byte > v) noexcept
Little-endian u32.
bool func_io_config_valid(const FuncIoConfig &c) noexcept
Key 0x0019 sanity (issue #52): every field within its enum.
@ kNone
not disconnected (or the event is not a disconnect / reconnect)
Definition event.hpp:82
bool 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 / broa...
ImuGyroRange
Gyroscope full-scale range in degrees per second (key 0x002B byte 2).
Definition keys.hpp:194
std::expected< std::uint64_t, KeyError > decode_u64(std::span< const std::byte > v) noexcept
Little-endian u64.
FuncIn0
Pin functions of key 0x0019 (issue #52).
Definition keys.hpp:151
@ kPps
PPS input (M12 pin 8).
Definition keys.hpp:152
std::array< std::uint8_t, 4 > Ipv4
IPv4 address in network order, e.g. {192, 168, 1, 12}.
Definition keys.hpp:93
FwType
Key 0x8010: which firmware image is running.
Definition keys.hpp:259
ScanPattern
key 0x0001.
Definition keys.hpp:135
std::expected< DataType, KeyError > 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< FovConfig, KeyError > decode_fov_config(std::span< const std::byte > v) noexcept
Keys 0x0015 / 0x0016. Not checked with fov_in_range().
DetectMode
Key 0x0018: detection sensitivity.
Definition keys.hpp:143
typename key_traits< K >::value_type key_value_t
The C++ type of key K, e.g. key_value_t<Key::kPclDataType> is DataType.
Definition keys.hpp:433
bool install_attitude_valid(const InstallAttitude &a) noexcept
Key 0x0012 sanity (issue #51): the three angles finite and within [-180, 180] degrees.
std::expected< Version, KeyError > decode_version(std::span< const std::byte > v) noexcept
Keys 0x8002 / 0x8003 / 0x8004.
std::expected< std::array< std::uint32_t, 8 >, KeyError > decode_hms_codes(std::span< const std::byte > v) noexcept
Key 0x8011: the eight raw slots; see decode_hms().
std::expected< std::array< std::uint8_t, 6 >, KeyError > decode_mac(std::span< const std::byte > v) noexcept
Key 0x8005.
std::expected< std::uint8_t, KeyError > decode_u8(std::span< const std::byte > v) noexcept
One byte.
std::array< std::byte, 1 > encode_u8(std::uint8_t v) noexcept
One byte.
TimeSyncType
Key 0x800C: the time source the LiDAR is synchronised to.
Definition keys.hpp:220
std::array< std::byte, 1 > encode_fov_enable(FovEnable e) noexcept
Key 0x0017 bitmask.
std::expected< DiagStatus, KeyError > decode_diag_status(std::span< const std::byte > v) noexcept
Key 0x800E; a nibble above 3 is kOutOfRange.
std::expected< DetectMode, KeyError > decode_detect_mode(std::span< const std::byte > v) noexcept
Key 0x0018: 0 or 1.
std::expected< InstallAttitude, KeyError > decode_install_attitude(std::span< const std::byte > v) noexcept
Key 0x0012. Not checked with install_attitude_valid().
std::expected< FovEnable, KeyError > decode_fov_enable(std::span< const std::byte > v) noexcept
key 0x0017; bits above bit 1 are kOutOfRange.
std::expected< LidarIpConfig, KeyError > decode_lidar_ip_config(std::span< const std::byte > v) noexcept
Key 0x0004. Not checked with lidar_ip_config_valid().
std::optional< std::size_t > key_value_length(Key k) noexcept
Fixed value length documented for the key, or nullopt if variable/unknown.
std::expected< std::int32_t, KeyError > decode_i32(std::span< const std::byte > v) noexcept
Little-endian i32.
std::array< std::byte, 4 > encode_func_io_config(const FuncIoConfig &c) noexcept
Key 0x0019: in0, in1, out0, out1.
std::array< std::byte, 8 > encode_host_ip_config(const HostIpConfig &c) noexcept
Keys 0x0005 / 0x0006 / 0x0007 / 0x0009: ip, dst port, src port.
ImuOutputRate
IMU output rate (key 0x002B byte 0).
Definition keys.hpp:178
std::expected< FwType, KeyError > decode_fw_type(std::span< const std::byte > v) noexcept
Key 0x8010: 0 or 1.
ImuAccelRange
Accelerometer full-scale range (key 0x002B byte 1).
Definition keys.hpp:186
std::expected< std::int64_t, KeyError > decode_i64(std::span< const std::byte > v) noexcept
Little-endian i64.
std::string_view to_string(Event::Kind kind) noexcept
Name of an event kind, e.g. "state_changed".
KeyError
Why a key value did not decode.
Definition keys.hpp:84
@ kWrongLength
the value's length differs from the key's fixed length
Definition keys.hpp:85
@ kOutOfRange
a field is outside its enum or documented range
Definition keys.hpp:86
std::array< std::byte, 3 > encode_imu_sensor_config(const ImuSensorConfig &c) noexcept
Key 0x002B: rate, accel range, gyro range.
std::string_view 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.
std::array< std::byte, 20 > encode_fov_config(const FovConfig &f) noexcept
Keys 0x0015 / 0x0016.
constexpr bool is_read_only(Key k) noexcept
True for the 0x8000 range (inquire / push only).
Definition keys.hpp:75
std::expected< TimeSyncType, KeyError > decode_time_sync_type(std::span< const std::byte > v) noexcept
Key 0x800C: 0, 1 or 2.
Pure-function protocol layer for the Livox Mid-360: framing, parsing and serialisation of control-com...
Key 0x800E, u16 bitfield split into four subsystem levels (issue #55).
Definition keys.hpp:240
DiagLevel system
bit 0-3
Definition keys.hpp:241
constexpr bool normal() const noexcept
worst() == kNormal.
Definition keys.hpp:254
DiagLevel ranging
bit 8-11
Definition keys.hpp:243
DiagLevel communication
bit 12-15
Definition keys.hpp:244
constexpr bool operator==(const DiagStatus &) const noexcept=default
Field-wise equality.
constexpr DiagLevel worst() const noexcept
Highest level among the four subsystems.
Definition keys.hpp:249
DiagLevel scan
bit 4-7
Definition keys.hpp:242
Keys 0x0015 / 0x0016: one FOV window in degrees.
Definition keys.hpp:124
std::int32_t yaw_start_deg
[0, 360]
Definition keys.hpp:125
std::int32_t yaw_stop_deg
[0, 360]
Definition keys.hpp:126
std::int32_t pitch_stop_deg
[-10, 60]
Definition keys.hpp:128
std::int32_t pitch_start_deg
[-10, 60]
Definition keys.hpp:127
std::uint32_t rsvd
reserved; encoded as given
Definition keys.hpp:129
Key 0x0017 bitmask: bit 0 enables fov_cfg0, bit 1 enables fov_cfg1.
Definition keys.hpp:266
bool fov1
bit 1: window 0x0016 crops the point cloud
Definition keys.hpp:268
bool fov0
bit 0: window 0x0015 crops the point cloud
Definition keys.hpp:267
The three FOV keys together (issue #39): Device::set_fov() sends the present ones in one 0x0100,...
Definition keys.hpp:275
std::optional< FovConfig > fov0
key 0x0015
Definition keys.hpp:276
std::optional< FovConfig > fov1
key 0x0016
Definition keys.hpp:277
std::optional< FovEnable > enable
key 0x0017
Definition keys.hpp:278
Key 0x0019; M12 pins 8, 10, 12, 11. Same layout as the 4 raw bytes.
Definition keys.hpp:169
FuncIn1 in1
IN1, M12 pin 10.
Definition keys.hpp:171
FuncOut out0
OUT0, M12 pin 12.
Definition keys.hpp:172
FuncOut out1
OUT1, M12 pin 11.
Definition keys.hpp:173
FuncIn0 in0
IN0, M12 pin 8.
Definition keys.hpp:170
Keys 0x0005 / 0x0006 / 0x0007 / 0x0009: where the LiDAR sends one kind of data.
Definition keys.hpp:97
Ipv4 ip
host address
Definition keys.hpp:98
std::uint16_t src_port
LiDAR-side source port.
Definition keys.hpp:100
std::uint16_t dst_port
host-side listening port
Definition keys.hpp:99
Key 0x002B: IMU output rate and ranges.
Definition keys.hpp:206
ImuGyroRange gyro_range
byte 2
Definition keys.hpp:209
ImuOutputRate output_rate
byte 0
Definition keys.hpp:207
ImuAccelRange accel_range
byte 1
Definition keys.hpp:208
Key 0x0012: mounting rotation (degrees) and offset (millimetres) of the LiDAR.
Definition keys.hpp:113
std::int32_t z_mm
offset along z
Definition keys.hpp:119
float pitch_deg
rotation about y
Definition keys.hpp:115
float roll_deg
rotation about x
Definition keys.hpp:114
float yaw_deg
rotation about z
Definition keys.hpp:116
std::int32_t y_mm
offset along y
Definition keys.hpp:118
std::int32_t x_mm
offset along x
Definition keys.hpp:117
Key 0x0004: the LiDAR's own network configuration.
Definition keys.hpp:105
Ipv4 gateway
gateway; 0.0.0.0 = none
Definition keys.hpp:108
Ipv4 ip
LiDAR address.
Definition keys.hpp:106
Ipv4 netmask
subnet mask
Definition keys.hpp:107
Keys 0x8002 / 0x8003 / 0x8004, "aa.bb.cc.dd".
Definition keys.hpp:214
std::array< std::uint8_t, 4 > v
aa, bb, cc, dd
Definition keys.hpp:215
Definition keys.hpp:422