livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
Loading...
Searching...
No Matches
device.hpp File Reference

Public API (issue #9): one LiDAR. More...

#include <array>
#include <chrono>
#include <cstdint>
#include <expected>
#include <functional>
#include <memory>
#include <optional>
#include <span>
#include <tuple>
#include <utility>
#include <vector>
#include "livox/mid360/config.hpp"
#include "livox/mid360/context.hpp"
#include "livox/mid360/debug_data.hpp"
#include "livox/mid360/event.hpp"
#include "livox/mid360/export.hpp"
#include "livox/mid360/firmware_log.hpp"
#include "livox/mid360/frame.hpp"
#include "livox/mid360/keys.hpp"
#include "livox/mid360/lidar_info.hpp"
#include "livox/mid360/protocol.hpp"
#include "livox/mid360/session.hpp"
#include "livox/mid360/transport.hpp"

Go to the source code of this file.

Classes

struct  livox::mid360::ReconnectOptions
 Disconnect detection and automatic recovery (issue #8). More...
struct  livox::mid360::DeviceOptions
 Per-Device settings, passed to Device::open(). More...
struct  livox::mid360::ReceiveInfo
 Per-packet metadata handed to on_packet together with the non-owning DataPacketView. More...
struct  livox::mid360::SetResult
 Result of Device::set<K>() / set_many<>(): the LiDAR accepted the values. More...
class  livox::mid360::Device
 One LiDAR: commands through its own Session, data through the Context it was opened on. More...

Namespaces

namespace  livox
 Livox LiDAR drivers.
namespace  livox::mid360
 The livox_mid360_core library: everything declared by the public headers.

Typedefs

using livox::mid360::PacketCallback = std::function<void(const DataPacketView &, const ReceiveInfo &)>
 Every parsed point-cloud / IMU data packet; the view is valid only during the call.
using livox::mid360::FrameCallback = std::function<void(Frame &&)>
 Every completed Frame, moved to the callee.
using livox::mid360::ImuCallback = std::function<void(const ImuData &)>
 Every IMU sample.
using livox::mid360::EventCallback = std::function<void(const Event &)>
 Every Event (state, HMS, diagnostics, connection, periodic stats, firmware log gaps).
using livox::mid360::PushCallback = std::function<void(const LidarStatus &)>
 Every successfully parsed 0x0102 push, as the snapshot pushed_status() now returns (#56).
using livox::mid360::FirmwareLogCallback = std::function<void(const FirmwareLogChunk &)>
 One 0x0300 firmware log push (#44); data is valid only during the call.
using livox::mid360::DebugDataCallback = std::function<void(const DebugDataPacket &)>
 One datagram of the debug raw data stream (#93); data is valid only during the call.

Detailed Description

Public API (issue #9): one LiDAR.

Wraps a Session (commands, caller's thread) and receives its data through a Context (receive thread, callbacks). Threading rules:

  • callbacks run on the Context's receive thread, must return quickly and never block;
  • commands are serialised by an internal mutex and may be called from any user thread, but NEVER from a callback (deadlock; asserted in debug builds) - react to Events from your own thread instead;
  • an exception escaping a callback terminates the process;
  • a Device must not be destroyed from inside its own callbacks. Data path (#6), push / state / HMS (#7) and reconnection (#8) are implemented. Reconnection: a Device is disconnected when no 0x0102 push arrived for ReconnectOptions::push_timeout (or a command timed out while the push was already stale, or reboot() was acknowledged). Event::kDisconnected is raised, commands fail with DeviceError::Kind::kDisconnected, and - when ReconnectOptions::enabled - a worker thread owned by the Device retries with exponential backoff: the last known command endpoint first (serial verified), then discovery filtered by serial. On success the host setup is applied again, sampling is resumed if it had been requested, and Event::kReconnected is raised. Callbacks stay frozen for the whole period when sampling was requested.