livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
Loading...
Searching...
No Matches
lidar_info.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
8#pragma once
9
10#include <array>
11#include <cstdint>
12#include <optional>
13#include <span>
14#include <string>
15
17#include "livox/mid360/hms.hpp"
18#include "livox/mid360/keys.hpp"
20
21LIVOX_MID360_API_BEGIN
22namespace livox::mid360
23{
24
26[[nodiscard]] std::string to_string(const Version & v);
27
31{
32 std::string serial_number;
33 std::string product_info;
37 std::array<std::uint8_t, 6> mac{};
38};
39
44
46[[nodiscard]] DeviceIdentity decode_identity(std::span<const KeyValue> kvs) noexcept;
48[[nodiscard]] std::string to_string(const DeviceIdentity & id);
49
53
55[[nodiscard]] std::string_view to_string(ScanPattern p) noexcept;
57[[nodiscard]] std::string_view to_string(DetectMode m) noexcept;
59[[nodiscard]] std::string_view to_string(TimeSyncType t) noexcept;
61[[nodiscard]] std::string_view to_string(FwType t) noexcept;
63[[nodiscard]] std::string_view to_string(ImuOutputRate r) noexcept;
65[[nodiscard]] std::string_view to_string(ImuAccelRange r) noexcept;
67[[nodiscard]] std::string_view to_string(ImuGyroRange r) noexcept;
69[[nodiscard]] std::string to_string(const HostIpConfig & c);
71[[nodiscard]] std::string to_string(const LidarIpConfig & c);
73[[nodiscard]] std::string to_string(const InstallAttitude & a);
75[[nodiscard]] std::string to_string(const FovConfig & f);
77[[nodiscard]] std::string to_string(const FovEnable & e);
79[[nodiscard]] std::string to_string(const FovSettings & s);
81[[nodiscard]] std::string_view to_string(FuncIn0 f) noexcept;
83[[nodiscard]] std::string_view to_string(FuncIn1 f) noexcept;
85[[nodiscard]] std::string_view to_string(FuncOut f) noexcept;
87[[nodiscard]] std::string to_string(const FuncIoConfig & c);
89[[nodiscard]] std::string to_string(const ImuSensorConfig & c);
91[[nodiscard]] std::string_view to_string(DiagLevel level) noexcept;
93[[nodiscard]] std::string to_string(const DiagStatus & d);
95
99
104{
105 std::optional<DataType> pcl_data_type;
106 std::optional<ScanPattern> pattern_mode;
107 std::optional<LidarIpConfig> lidar_ipcfg;
108 std::optional<HostIpConfig> state_info_host_ipcfg;
109 std::optional<HostIpConfig> pointcloud_host_ipcfg;
110 std::optional<HostIpConfig> imu_host_ipcfg;
111 std::optional<InstallAttitude> install_attitude;
112 std::optional<FovConfig> fov_cfg0;
113 std::optional<FovConfig> fov_cfg1;
114 std::optional<FovEnable> fov_cfg_en;
115 std::optional<DetectMode> detect_mode;
116 std::optional<FuncIoConfig> func_io_cfg;
117 std::optional<WorkState> work_tgt_mode;
118 std::optional<bool> imu_data_en;
119 std::optional<bool> time_filter;
120 std::optional<ImuSensorConfig> imu_sensor_cfg;
121};
122
141
143[[nodiscard]] LidarSettings decode_settings(std::span<const KeyValue> kvs) noexcept;
145[[nodiscard]] std::string to_string(const LidarSettings & s);
147
151
155{
158 std::uint64_t time_ns = 0;
159 std::optional<WorkState> cur_work_state;
160 std::optional<std::int32_t> core_temp;
161 std::optional<std::uint32_t> powerup_cnt;
162 std::optional<std::uint64_t> local_time_now;
163 std::optional<std::uint64_t> last_sync_time;
164 std::optional<std::int64_t> time_offset;
165 std::optional<TimeSyncType> time_sync_type;
166 std::optional<DiagStatus> lidar_diag_status;
167 std::optional<FwType> fw_type;
168 std::optional<std::array<HmsCode, 8>> hms_code;
169};
170
174{
175 std::uint64_t local_time_ns = 0;
176 std::uint64_t last_sync_time_ns = 0;
177 std::int64_t offset_ns = 0;
178 TimeSyncType type = TimeSyncType::kNone;
179};
180
181[[nodiscard]] std::string to_string(const TimeSyncStatus & s);
182
188
191[[nodiscard]] LidarStatus decode_status(std::span<const KeyValue> kvs) noexcept;
194[[nodiscard]] std::string to_string(const LidarStatus & s);
196
197} // namespace livox::mid360
198LIVOX_MID360_API_END
Symbol visibility helpers.
HMS (health management system) diagnostic code decoding for the Mid-360.
Key definitions and typed encoders/decoders for the Mid-360 key-value list (section "0x0102 LiDAR Inf...
The livox_mid360_core library: everything declared by the public headers.
Definition bytes.hpp:14
LidarStatus decode_status(std::span< const KeyValue > kvs) noexcept
Decodes the kStatusKeys present in kvs, each HMS slot through decode_hms(); other keys are ignored an...
DiagLevel
key 0x800E: per-module abnormality level 0 normal / 1 warning / 2 error / 3 safety_err.
Definition keys.hpp:230
constexpr std::array< Key, 6 > kIdentityKeys
The keys decode_identity() reads, for one inquire.
Definition lidar_info.hpp:41
LidarSettings decode_settings(std::span< const KeyValue > kvs) noexcept
Decodes the kSettingsKeys present in kvs; other keys are ignored.
DeviceIdentity decode_identity(std::span< const KeyValue > kvs) noexcept
Missing or undecodable keys leave the field at its default (empty string / zero).
FuncOut
Function of pins OUT0 / OUT1 (key 0x0019).
Definition keys.hpp:161
FuncIn1
Function of pin IN1 (key 0x0019).
Definition keys.hpp:156
constexpr std::array< Key, 10 > kStatusKeys
The keys decode_status() reads, for one inquire.
Definition lidar_info.hpp:184
@ 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
@ 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
@ 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
ImuGyroRange
Gyroscope full-scale range in degrees per second (key 0x002B byte 2).
Definition keys.hpp:194
FuncIn0
Pin functions of key 0x0019 (issue #52).
Definition keys.hpp:151
FwType
Key 0x8010: which firmware image is running.
Definition keys.hpp:259
ScanPattern
key 0x0001.
Definition keys.hpp:135
DetectMode
Key 0x0018: detection sensitivity.
Definition keys.hpp:143
constexpr std::array< Key, 16 > kSettingsKeys
The keys decode_settings() reads, for one inquire.
Definition lidar_info.hpp:124
TimeSyncType
Key 0x800C: the time source the LiDAR is synchronised to.
Definition keys.hpp:220
ImuOutputRate
IMU output rate (key 0x002B byte 0).
Definition keys.hpp:178
ImuAccelRange
Accelerometer full-scale range (key 0x002B byte 1).
Definition keys.hpp:186
std::string_view to_string(Event::Kind kind) noexcept
Name of an event kind, e.g. "state_changed".
Pure-function protocol layer for the Livox Mid-360: framing, parsing and serialisation of control-com...
Keys 0x8000-0x8005 (issue #38).
Definition lidar_info.hpp:31
Version version_hardware
0x8004
Definition lidar_info.hpp:36
std::array< std::uint8_t, 6 > mac
0x8005
Definition lidar_info.hpp:37
Version version_app
0x8002
Definition lidar_info.hpp:34
std::string serial_number
0x8000
Definition lidar_info.hpp:32
std::string product_info
0x8001
Definition lidar_info.hpp:33
Version version_loader
0x8003
Definition lidar_info.hpp:35
Key 0x800E, u16 bitfield split into four subsystem levels (issue #55).
Definition keys.hpp:240
Keys 0x0015 / 0x0016: one FOV window in degrees.
Definition keys.hpp:124
Key 0x0017 bitmask: bit 0 enables fov_cfg0, bit 1 enables fov_cfg1.
Definition keys.hpp:266
The three FOV keys together (issue #39): Device::set_fov() sends the present ones in one 0x0100,...
Definition keys.hpp:275
Key 0x0019; M12 pins 8, 10, 12, 11. Same layout as the 4 raw bytes.
Definition keys.hpp:169
Keys 0x0005 / 0x0006 / 0x0007 / 0x0009: where the LiDAR sends one kind of data.
Definition keys.hpp:97
Key 0x002B: IMU output rate and ranges.
Definition keys.hpp:206
Key 0x0012: mounting rotation (degrees) and offset (millimetres) of the LiDAR.
Definition keys.hpp:113
Key 0x0004: the LiDAR's own network configuration.
Definition keys.hpp:105
The 16 modelled writable keys.
Definition lidar_info.hpp:104
std::optional< HostIpConfig > state_info_host_ipcfg
0x0005
Definition lidar_info.hpp:108
std::optional< HostIpConfig > pointcloud_host_ipcfg
0x0006
Definition lidar_info.hpp:109
std::optional< FuncIoConfig > func_io_cfg
0x0019
Definition lidar_info.hpp:116
std::optional< WorkState > work_tgt_mode
0x001A
Definition lidar_info.hpp:117
std::optional< LidarIpConfig > lidar_ipcfg
0x0004
Definition lidar_info.hpp:107
std::optional< bool > imu_data_en
0x001C
Definition lidar_info.hpp:118
std::optional< HostIpConfig > imu_host_ipcfg
0x0007
Definition lidar_info.hpp:110
std::optional< ScanPattern > pattern_mode
0x0001
Definition lidar_info.hpp:106
std::optional< InstallAttitude > install_attitude
0x0012
Definition lidar_info.hpp:111
std::optional< bool > time_filter
0x0026
Definition lidar_info.hpp:119
std::optional< FovEnable > fov_cfg_en
0x0017
Definition lidar_info.hpp:114
std::optional< DetectMode > detect_mode
0x0018
Definition lidar_info.hpp:115
std::optional< FovConfig > fov_cfg1
0x0016
Definition lidar_info.hpp:113
std::optional< ImuSensorConfig > imu_sensor_cfg
0x002B
Definition lidar_info.hpp:120
std::optional< FovConfig > fov_cfg0
0x0015
Definition lidar_info.hpp:112
std::optional< DataType > pcl_data_type
0x0000
Definition lidar_info.hpp:105
Keys 0x8006-0x8011: the live state, also carried by the 0x0102 push.
Definition lidar_info.hpp:155
std::optional< std::uint32_t > powerup_cnt
0x8008
Definition lidar_info.hpp:161
std::optional< std::array< HmsCode, 8 > > hms_code
0x8011, decoded slots
Definition lidar_info.hpp:168
std::optional< std::uint64_t > local_time_now
0x8009, ns
Definition lidar_info.hpp:162
std::optional< DiagStatus > lidar_diag_status
0x800E
Definition lidar_info.hpp:166
std::optional< TimeSyncType > time_sync_type
0x800C
Definition lidar_info.hpp:165
std::optional< WorkState > cur_work_state
0x8006
Definition lidar_info.hpp:159
std::optional< FwType > fw_type
0x8010
Definition lidar_info.hpp:167
std::optional< std::uint64_t > last_sync_time
0x800A, ns
Definition lidar_info.hpp:163
std::optional< std::int32_t > core_temp
0x8007, 0.01 degC units
Definition lidar_info.hpp:160
std::optional< std::int64_t > time_offset
0x800B, ns
Definition lidar_info.hpp:164
std::uint64_t time_ns
Host time (CLOCK_REALTIME ns) at which the ACK or push behind this snapshot was received; 0 when deco...
Definition lidar_info.hpp:158
Time-sync state read by Device::time_sync_status() (issue #53): keys 0x8009–0x800C in one inquire.
Definition lidar_info.hpp:174
std::uint64_t local_time_ns
0x8009 LiDAR clock now
Definition lidar_info.hpp:175
std::int64_t offset_ns
0x800B local - source
Definition lidar_info.hpp:177
TimeSyncType type
0x800C
Definition lidar_info.hpp:178
std::uint64_t last_sync_time_ns
0x800A LiDAR time of the last sync, 0 = never
Definition lidar_info.hpp:176
Keys 0x8002 / 0x8003 / 0x8004, "aa.bb.cc.dd".
Definition keys.hpp:214