You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.4 KiB
C

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef __LIDAR_BRIDGE_H__
#define __LIDAR_BRIDGE_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#define EXPORT_API __declspec(dllexport)
#else
#define EXPORT_API __attribute__((visibility("default")))
#endif
#include <stdint.h>
/* 协议类型 */
#define PROTO_TCP 1
#define PROTO_UDP 2
/* 单点数据 (对应 pavo_response_pcd_t) */
typedef struct {
double x;
double y;
double z;
uint16_t intensity;
} LidarPoint;
/* 帧数据 */
typedef struct {
LidarPoint* points; /* 点数组 */
int count; /* 点数量 */
uint32_t timestamp;
} LidarFrame;
/* ============ 生命周期 ============ */
/** 创建雷达实例,返回不透明句柄 */
EXPORT_API void* lidar_create(void);
/** 销毁实例 */
EXPORT_API void lidar_destroy(void* handle);
/* ============ 配置 ============ */
/** 设置通信协议: PROTO_TCP(1) 或 PROTO_UDP(2) */
EXPORT_API void lidar_set_protocol(void* handle, int proto);
/* ============ 连接 ============ */
/** 连接雷达,timeout_ms=超时毫秒,成功返回1 */
EXPORT_API int lidar_open(void* handle, const char* ip, int port, int timeout_ms);
/** 是否已连接,已连接返回1 */
EXPORT_API int lidar_is_open(void* handle);
/** 断开连接 */
EXPORT_API int lidar_close(void* handle);
/* ============ 数据获取 ============ */
/** 获取一帧点云数据(PCD格式),成功返回1,timeout_ms=0为不等待 */
EXPORT_API int lidar_get_frame(void* handle, LidarFrame* frame, int timeout_ms);
/** 释放 lidar_get_frame 返回的帧内存 */
EXPORT_API void lidar_free_frame(LidarFrame* frame);
/** 启用/禁用数据传输,en=1启用 */
EXPORT_API int lidar_enable_data(void* handle, int en);
/** 获取上一帧后的累计帧数 */
EXPORT_API int lidar_get_scans_available(void* handle);
/* ============ 设备信息 ============ */
/** 获取设备序列号,buf至少64字节 */
EXPORT_API int lidar_get_sn(void* handle, char* buf, int buf_size);
/** 获取设备型号 */
EXPORT_API int lidar_get_pn(void* handle, char* buf, int buf_size);
/** 获取SDK版本 */
EXPORT_API int lidar_get_sdk_ver(void* handle, char* buf, int buf_size);
/** 获取固件版本 */
EXPORT_API int lidar_get_firmware_ver(void* handle, char* buf, int buf_size);
/** 获取错误码 */
EXPORT_API int lidar_get_error_code(void* handle);
#ifdef __cplusplus
}
#endif
#endif /* __LIDAR_BRIDGE_H__ */