/**
|
******************************************************************************
|
* @file : OrdLidar.h
|
* @brief : Header for OrdLidar.c file.
|
* This file contains the Lidar defines of the application.
|
******************************************************************************
|
*/
|
|
#ifndef __ORDLIDAR_H__
|
#define __ORDLIDAR_H__
|
|
#define ORDLIDAR_VER (0x100)
|
#pragma anon_unions
|
|
#include <stdint.h>
|
#include <stdlib.h>
|
|
#define TMPBUFF_SIZE (1024)
|
#define MAX_BLOCK_POINT_NUM (100)
|
#define MAX_BLOCK_SIZE (MAX_BLOCK_POINT_NUM * 4)
|
#define POINT_CIRCLE_MAX_SIZE (4096)
|
#define POINT_PKG_MAX_SIZE (200)
|
#define POINT_PER_PACK (12)
|
|
#define SET_TIME_OUT (10) //unit:s
|
#define HEAD_FLAG (0xF5A5)
|
#define TAIL_FLAG (0x31F2)
|
#define HEAD_LEN (5)
|
|
typedef enum
|
{
|
ORADAR_MS200 = 1,
|
ORADAR_MS300 = 2,
|
}oradar_lidar_type_id;
|
|
typedef enum {
|
ORADAR_TYPE_SERIAL = 0x0,/**< serial type.*/
|
ORADAR_TYPC_UDP = 0x1,/**< socket udp type.*/
|
ORADAR_TYPE_TCP = 0x1,/**< socket tcp type.*/
|
} device_type_id;
|
|
typedef enum
|
{
|
SET_ROTATION_SPEED = 0xA1,
|
SET_RUN_MODE = 0xA2,
|
}CMD;
|
|
typedef enum
|
{
|
WRITE_PARAM = 0xC1,
|
WRITE_PARAM_RESPONSE = 0xC2,
|
READ_PARAM = 0xC3,
|
READ_PARAM_RESPONSE = 0xC4,
|
}CMD_TYPE;
|
|
typedef struct uart_comm_st
|
{
|
uint16_t head_flag;
|
uint8_t cmd;
|
uint8_t cmd_type;
|
uint8_t payload_len;
|
uint8_t data[10];
|
}uart_comm_t;
|
|
typedef struct point_data_st
|
{
|
unsigned short distance;
|
unsigned short intensity;
|
float angle;
|
} point_data_t;
|
|
typedef enum frame_head_flag_et
|
{
|
HEAD_FLAG_NONE,
|
HEAD_FLAG_OK,
|
} frame_head_flag_t;
|
|
typedef enum protocol_version_et
|
{
|
VERSION_NONE = 0,
|
VERSION_MS200,
|
} protocol_version_t;
|
|
typedef struct __attribute__((packed))
|
{
|
uint16_t distance;
|
uint8_t confidence;
|
} OradarLidarPoint;
|
|
typedef struct __attribute__((packed))
|
{
|
uint8_t header;
|
uint8_t ver_len;
|
uint16_t speed;
|
uint16_t start_angle;
|
OradarLidarPoint point[POINT_PER_PACK];
|
uint16_t end_angle;
|
uint16_t timestamp;
|
uint8_t crc8;
|
} OradarLidarFrame;
|
|
|
|
typedef struct LidarDotData
|
{
|
unsigned char intensity;
|
unsigned char s1;
|
/*
|
struct {
|
unsigned char flag:2;
|
unsigned char s1:6;
|
};
|
*/
|
unsigned char s2;
|
}stLidarDotData;
|
|
typedef struct tagLidarDotsPkt
|
{
|
unsigned short StSign;
|
unsigned char CT;
|
unsigned char LSN;
|
unsigned short FSA;
|
unsigned short LSA;
|
unsigned short CS;
|
stLidarDotData LidarDotDatas[40];
|
|
}stLidarDotsPkt, *pLidarDotsPkt;
|
|
|
typedef struct tagLidarVector
|
{
|
int intensit;
|
int angle;
|
int value;
|
}stLidarVector;
|
|
typedef struct tagLidarDot
|
{
|
int x;
|
int y;
|
unsigned int distance;
|
}stLidarDot;
|
|
|
extern int nPosX;
|
extern int nPosY;
|
extern int nPosZ;
|
extern int nPosZ1, nPosZ2;
|
|
extern int pCount1;
|
extern int pCount2;
|
|
extern int eCount1;
|
extern int eCount2;
|
|
extern int dCount1;
|
extern int dCount2;
|
|
extern int vCount1;
|
extern int vCount2;
|
|
extern int results[32];
|
|
|
int OrdLidarStart(int nIdx); /* Start LiDar Running , nIde = 0 , 1 , -1 == ALL */
|
int OrdLidarStop(int nIdx); /* stop Lidar Running , nIde = 0 , 1 , -1 == ALL */
|
|
|
int OrdLidarParsePkt(int nLidarIdx, OradarLidarFrame * pLindarPkt, int len1);
|
|
int ProcessPos(int nLidarIdx, stLidarDot * pLindarDots, int nCount);
|
|
#endif /* __ORDLIDAR_H__ */
|