Refactor lidar library: rename olei_config to lidar_config, add nanoscan example and shared byte helpers

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 09:27:43 +07:00
parent 59880871b0
commit 323715eab0
16 changed files with 621 additions and 814 deletions

View File

@@ -1,19 +1,15 @@
// example.cpp — quick try-out of the OLEI LiDAR driver
// OLEI driver example.
#include "lidarlib/lidar.hpp"
#include <cstdio>
int main() {
// ── pick a model ────────────────────────────────────────────────────────
// lidarlib::Driver drv(lidarlib::MODEL_VF); // 2D 360°
// lidarlib::Driver drv(lidarlib::MODEL_LR1F); // 2D 360°, 50m
lidarlib::Driver drv(lidarlib::MODEL_VB); // 2D 270°
lidarlib::Driver drv(lidarlib::MODEL_VB);
if (!drv.open()) {
fprintf(stderr, "Không mở được socket\n");
return 1;
}
// ── option 1: blocking recv ─────────────────────────────────────────────
for (int i = 0; i < 10; ++i) {
lidarlib::ScanResult result;
if (!drv.recv_scan(result, 2000)) {
@@ -26,7 +22,6 @@ int main() {
i, scan.ranges.size(), scan.timestamp_ms, info.error_status,
info.detected_model.c_str());
// Print the first few points
for (size_t j = 0; j < 20 && j < scan.ranges.size(); ++j) {
float angle_deg = (scan.angle_min + j * scan.angle_increment) * 180.f / 3.14159265f;
printf(" [%zu] angle=%.2f° dist=%.3fm intensity=%.0f\n",
@@ -34,12 +29,6 @@ int main() {
}
}
// ── option 2: callback (your own loop) ──────────────────────────────────
// drv.set_scan_callback([](const lidarlib::ScanResult& result) {
// printf("Got scan: %zu pts\n", result.scan.ranges.size());
// });
// while (true) drv.spin_once();
drv.close();
return 0;
}