// SICK nanoScan3 / microScan3 safety scanners over UDP — plugin-private header. #pragma once #include "lidar_interface.hpp" #include #include #include namespace xlidar { inline constexpr ModelConfig MODEL_SICK_NANOSCAN3 { "SICK-nanoScan3", -137.5f, 137.5f, 0.05f, 40.f }; // SICK nanoScan3 / microScan3 safety-scanner binary UDP output. Layout ported // from SICK's open-source sick_safetyscanners; NOT verified on real hardware. // Passive UDP receiver: the sensor's UDP target must be configured up front in // SICK Safety Designer — this class does no CoLa2/TCP handshake. class SickSafetyDriver : public LidarDriverInterface { public: // ip: local bind address; port: local UDP port the sensor sends to; // inverted: unit mounted upside-down → mirror the scan. explicit SickSafetyDriver(const ModelConfig& cfg, const std::string& ip = "0.0.0.0", uint16_t port = 6060, bool inverted = false); ~SickSafetyDriver(); SickSafetyDriver(const SickSafetyDriver&) = delete; SickSafetyDriver& operator=(const SickSafetyDriver&) = delete; DriverInfo get_driver_info() const override; ErrorCode open() override; void close() override; bool recv_scan(ScanResult& out, int timeout_ms = 1000) override; void set_scan_callback(ScanCallback cb) override { cb_ = std::move(cb); } bool spin_once() override; bool is_open() const override { return sock_fd_ >= 0; } // No model string on the wire — returns the configured name. const char* detected_model() const override { return detected_model_name_.c_str(); } Diagnostics get_diagnostics() const override { return latest_diag_; } private: int recv_datagram(int timeout_ms); bool parse_packet(const uint8_t* buf, int len, ScanResult& out); ModelConfig cfg_; std::string detected_model_name_; // owned copy of cfg_.name (stable lifetime) std::string ip_; uint16_t port_; bool inverted_ = false; int sock_fd_ = -1; ScanCallback cb_; // Snapshot for get_diagnostics(); refreshed by parse_packet(). Diagnostics latest_diag_; // Per-instance; sized for a full safety-data packet (max ~2751 beams). std::vector recv_buf_; }; } // namespace xlidar