64 lines
2.3 KiB
C++
64 lines
2.3 KiB
C++
#pragma once
|
|
#include "lidarlib/lidar.hpp"
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace lidarlib {
|
|
|
|
// Settings for one lidar. `name` is the unique key across saves.
|
|
struct LidarConfig {
|
|
std::string name = "lidar";
|
|
std::string ip = "0.0.0.0";
|
|
uint16_t port = 2368;
|
|
std::string model = "AUTO";
|
|
bool inverted = false; // unit mounted upside-down → mirror the scan
|
|
std::string brand = "OLEI"; // "OLEI", "SICK" or "ESPE"
|
|
bool use_udp = false; // ESPE only: UDP instead of TCP transport
|
|
|
|
// Output angle window (deg): scan angles are remapped onto
|
|
// [angle_min_deg, angle_max_deg] without dropping points.
|
|
// Defaults (±360) = off.
|
|
float angle_min_deg = -360.f;
|
|
float angle_max_deg = 360.f;
|
|
|
|
friend bool operator==(const LidarConfig& a, const LidarConfig& b) {
|
|
return a.name == b.name && a.ip == b.ip && a.port == b.port &&
|
|
a.model == b.model && a.inverted == b.inverted && a.brand == b.brand &&
|
|
a.use_udp == b.use_udp &&
|
|
a.angle_min_deg == b.angle_min_deg && a.angle_max_deg == b.angle_max_deg;
|
|
}
|
|
friend bool operator!=(const LidarConfig& a, const LidarConfig& b) { return !(a == b); }
|
|
};
|
|
|
|
struct Config {
|
|
std::vector<LidarConfig> lidars = {
|
|
{"front", "0.0.0.0", 2368, "AUTO", false},
|
|
{"rear", "0.0.0.0", 2369, "AUTO", true},
|
|
};
|
|
};
|
|
|
|
// nullptr if `name` doesn't match any known model.
|
|
const ModelConfig* model_by_name(const std::string& name);
|
|
|
|
const std::vector<std::string>& model_names();
|
|
|
|
const std::vector<std::string>& brand_names();
|
|
|
|
// Subset of model_names() valid for `brand`; empty if unknown.
|
|
const std::vector<std::string>& model_names_for_brand(const std::string& brand);
|
|
|
|
// Returns defaults if the file doesn't exist (without creating it).
|
|
Config load_config(const std::string& path);
|
|
|
|
void save_config(const std::string& path, const Config& cfg);
|
|
|
|
// Build a ready-to-open lidar from one LidarConfig — the only entry point an
|
|
// app needs. brand "SICK" → SICK driver (model "SICK-nanoScan3" → UDP
|
|
// NanoScanDriver, others → TCP SickDriver); brand "ESPE" → TCP EspeDriver;
|
|
// anything else → OLEI UDP.
|
|
// Unknown/cross-brand model falls back to the brand default. Never nullptr.
|
|
std::unique_ptr<Lidar> make_lidar(const LidarConfig& cfg);
|
|
|
|
} // namespace lidarlib
|