8#include <condition_variable>
55 TagConfidence worst_accepted = TagConfidence::kHigh)
const noexcept
89 enum class Mode : std::uint8_t
97 std::chrono::nanoseconds
window{std::chrono::milliseconds{100}};
126 std::lock_guard lock(mutex_);
130 if (items_.size() >= capacity_) {
134 items_.push_back(std::move(item));
140 [[nodiscard]] std::optional<T>
pop(std::chrono::nanoseconds timeout)
142 std::unique_lock lock(mutex_);
143 cv_.wait_for(lock, timeout, [
this] {
return closed_ || !items_.empty(); });
150 std::lock_guard lock(mutex_);
158 std::lock_guard lock(mutex_);
167 std::lock_guard lock(mutex_);
171 [[nodiscard]] std::size_t
size()
const
173 std::lock_guard lock(mutex_);
174 return items_.size();
177 [[nodiscard]] std::size_t
capacity() const noexcept {
return capacity_; }
180 std::optional<T> take()
182 if (items_.empty()) {
185 std::optional<T> out{std::move(items_.front())};
190 std::size_t capacity_;
191 mutable std::mutex mutex_;
192 std::condition_variable cv_;
193 std::deque<T> items_;
194 std::uint64_t dropped_ = 0;
195 bool closed_ =
false;
203 float r[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
204 float t[3] = {0, 0, 0};
std::size_t size() const
Items currently queued.
Definition frame.hpp:171
std::uint64_t dropped() const
Items discarded by overflow so far.
Definition frame.hpp:165
void push(T &&item)
Producer side (receive thread). Never blocks.
Definition frame.hpp:123
std::optional< T > try_pop()
Consumer side without waiting. Empty when nothing is queued.
Definition frame.hpp:148
std::optional< T > pop(std::chrono::nanoseconds timeout)
Consumer side. Empty after timeout or once closed and drained.
Definition frame.hpp:140
BoundedQueue(std::size_t capacity=8)
An empty, open queue that holds at most capacity items.
Definition frame.hpp:120
std::size_t capacity() const noexcept
Maximum number of queued items, as passed to the constructor.
Definition frame.hpp:177
void close()
Wakes every waiting pop(); later pushes are ignored, queued items can still be popped.
Definition frame.hpp:155
Symbol visibility helpers.
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
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
Extrinsic extrinsic_from(const InstallAttitude &a) noexcept
Rotation = Rz(yaw) * Ry(pitch) * Rx(roll) (intrinsic ZYX, right-handed, degrees); translation = offse...
TagConfidence
Confidence that a point is a normal return for one tag category; higher = more likely noise.
Definition tag.hpp:17
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
constexpr TagInfo decode_tag(std::uint8_t tag) noexcept
Splits a raw tag byte into its four fields.
Definition tag.hpp:40
void apply(const Extrinsic &e, std::span< Point > points) noexcept
Transforms every point in place; reflectivity, tag, line and offset are untouched.
TimestampPolicy
How point/IMU timestamps are produced from the packet timestamp (#6).
Definition frame.hpp:102
@ kHostOffsetOnce
default: LiDAR time + (host - LiDAR) measured once at the first packet
Definition frame.hpp:104
@ kLidar
packet timestamp as is (use with PTP / GPS synchronisation)
Definition frame.hpp:103
@ kHostReceive
kernel receive time of the packet
Definition frame.hpp:105
constexpr bool is_noise(std::uint8_t tag, TagConfidence worst_accepted=TagConfidence::kHigh) noexcept
True when the adjacent-glue or particle confidence is worse than worst_accepted; the other and reserv...
Definition tag.hpp:49
Pure-function protocol layer for the Livox Mid-360: framing, parsing and serialisation of control-com...
Host-side install attitude transform (issue #51).
Definition frame.hpp:202
float t[3]
metres
Definition frame.hpp:204
float r[3][3]
row-major rotation
Definition frame.hpp:203
How a Device cuts the packet stream into Frames (#6).
Definition frame.hpp:87
std::chrono::nanoseconds window
kTimeWindow's period.
Definition frame.hpp:97
Mode
What closes a frame besides the conditions common to both modes.
Definition frame.hpp:90
@ kFrameCounter
close on a change of header frame_cnt; a jump still closes one frame
Definition frame.hpp:91
Mode mode
default: follow the header frame_cnt
Definition frame.hpp:94
A group of points closed by FramePolicy. Owns its storage; delivered by value.
Definition frame.hpp:63
DataType source_type
header data_type; one format per Frame
Definition frame.hpp:71
std::vector< Point > points
in packet order
Definition frame.hpp:67
std::uint32_t index
+1 per delivered frame, per Device (Lvx2Player: per device)
Definition frame.hpp:64
std::uint32_t dropped_packets
udp_cnt gaps observed while assembling it
Definition frame.hpp:69
std::uint64_t end_time_ns
time of the last point
Definition frame.hpp:66
std::uint32_t packets
data packets merged into this frame
Definition frame.hpp:68
TimeType time_type
header time_type; one time base per Frame
Definition frame.hpp:72
std::uint8_t frame_cnt
header frame_cnt of the first packet
Definition frame.hpp:70
std::uint64_t base_time_ns
time of the first point (after timestamp policy)
Definition frame.hpp:65
One IMU packet (the LiDAR sends one sample per packet at 200 Hz) with its time.
Definition frame.hpp:78
ImuSample sample
the decoded packet sample
Definition frame.hpp:80
std::uint64_t time_ns
after timestamp policy
Definition frame.hpp:79
The sample of an IMU packet (data type 0).
Definition protocol.hpp:321
Key 0x0012: mounting rotation (degrees) and offset (millimetres) of the LiDAR.
Definition keys.hpp:113
One return, same semantics as livox_ros_driver2's CustomPoint.
Definition frame.hpp:30
std::uint8_t line
Mid-360 has no physical lines: sample index % 4.
Definition frame.hpp:36
constexpr TagConfidence adjacent_glue() const noexcept
Tag bit 0-1: glue points between adjacent objects.
Definition frame.hpp:42
std::uint32_t offset_ns
sample time - Frame::base_time_ns
Definition frame.hpp:37
constexpr TagConfidence other() const noexcept
Tag bit 4-5: other properties.
Definition frame.hpp:52
float y
metres, LiDAR frame
Definition frame.hpp:32
std::uint8_t tag
raw tag byte; decoded by the accessors below (#34)
Definition frame.hpp:35
constexpr TagInfo tag_info() const noexcept
All four fields of the tag byte.
Definition frame.hpp:40
constexpr bool is_noise(TagConfidence worst_accepted=TagConfidence::kHigh) const noexcept
Glue or particle confidence worse than worst_accepted; see is_noise(uint8_t, ...).
Definition frame.hpp:54
float x
metres, LiDAR frame
Definition frame.hpp:31
float z
metres, LiDAR frame
Definition frame.hpp:33
constexpr TagConfidence particles() const noexcept
Tag bit 2-3: rain, fog, dust.
Definition frame.hpp:47
std::uint8_t reflectivity
0-255
Definition frame.hpp:34
Decoded tag byte: bit 0-1 adjacent glue, 2-3 rain / fog / dust, 4-5 other, 6-7 reserved.
Definition tag.hpp:28
TagConfidence particles
bit 2-3: rain, fog, dust
Definition tag.hpp:30
TagConfidence adjacent_glue
bit 0-1: glue points between adjacent objects
Definition tag.hpp:29
TagConfidence other
bit 4-5: other properties
Definition tag.hpp:31
Point tag byte (issue #34): four 2-bit confidence fields, section "Tag Information".