提交 | 用户 | age
|
842bb6
|
1 |
/** |
Q |
2 |
****************************************************************************** |
|
3 |
* @file : OrdLidar.h |
|
4 |
* @brief : Header for OrdLidar.c file. |
|
5 |
* This file contains the Lidar defines of the application. |
|
6 |
****************************************************************************** |
|
7 |
*/ |
|
8 |
|
|
9 |
#ifndef __ORDLIDAR_H__ |
|
10 |
#define __ORDLIDAR_H__ |
|
11 |
|
|
12 |
#define ORDLIDAR_VER (0x100) |
|
13 |
#pragma anon_unions |
|
14 |
|
|
15 |
#include <stdint.h> |
|
16 |
#include <stdlib.h> |
|
17 |
|
|
18 |
#define TMPBUFF_SIZE (1024) |
|
19 |
#define MAX_BLOCK_POINT_NUM (100) |
|
20 |
#define MAX_BLOCK_SIZE (MAX_BLOCK_POINT_NUM * 4) |
|
21 |
#define POINT_CIRCLE_MAX_SIZE (4096) |
|
22 |
#define POINT_PKG_MAX_SIZE (200) |
|
23 |
#define POINT_PER_PACK (12) |
|
24 |
|
|
25 |
#define SET_TIME_OUT (10) //unit:s |
|
26 |
#define HEAD_FLAG (0xF5A5) |
|
27 |
#define TAIL_FLAG (0x31F2) |
|
28 |
#define HEAD_LEN (5) |
|
29 |
|
|
30 |
typedef enum |
|
31 |
{ |
|
32 |
ORADAR_MS200 = 1, |
|
33 |
ORADAR_MS300 = 2, |
|
34 |
}oradar_lidar_type_id; |
|
35 |
|
|
36 |
typedef enum { |
|
37 |
ORADAR_TYPE_SERIAL = 0x0,/**< serial type.*/ |
|
38 |
ORADAR_TYPC_UDP = 0x1,/**< socket udp type.*/ |
|
39 |
ORADAR_TYPE_TCP = 0x1,/**< socket tcp type.*/ |
|
40 |
} device_type_id; |
|
41 |
|
|
42 |
typedef enum |
|
43 |
{ |
|
44 |
SET_ROTATION_SPEED = 0xA1, |
|
45 |
SET_RUN_MODE = 0xA2, |
|
46 |
}CMD; |
|
47 |
|
|
48 |
typedef enum |
|
49 |
{ |
|
50 |
WRITE_PARAM = 0xC1, |
|
51 |
WRITE_PARAM_RESPONSE = 0xC2, |
|
52 |
READ_PARAM = 0xC3, |
|
53 |
READ_PARAM_RESPONSE = 0xC4, |
|
54 |
}CMD_TYPE; |
|
55 |
|
|
56 |
typedef struct uart_comm_st |
|
57 |
{ |
|
58 |
uint16_t head_flag; |
|
59 |
uint8_t cmd; |
|
60 |
uint8_t cmd_type; |
|
61 |
uint8_t payload_len; |
|
62 |
uint8_t data[10]; |
|
63 |
}uart_comm_t; |
|
64 |
|
|
65 |
typedef struct point_data_st |
|
66 |
{ |
|
67 |
unsigned short distance; |
|
68 |
unsigned short intensity; |
|
69 |
float angle; |
|
70 |
} point_data_t; |
|
71 |
|
|
72 |
typedef enum frame_head_flag_et |
|
73 |
{ |
|
74 |
HEAD_FLAG_NONE, |
|
75 |
HEAD_FLAG_OK, |
|
76 |
} frame_head_flag_t; |
|
77 |
|
|
78 |
typedef enum protocol_version_et |
|
79 |
{ |
|
80 |
VERSION_NONE = 0, |
|
81 |
VERSION_MS200, |
|
82 |
} protocol_version_t; |
|
83 |
|
|
84 |
typedef struct __attribute__((packed)) |
|
85 |
{ |
|
86 |
uint16_t distance; |
|
87 |
uint8_t confidence; |
|
88 |
} OradarLidarPoint; |
|
89 |
|
|
90 |
typedef struct __attribute__((packed)) |
|
91 |
{ |
|
92 |
uint8_t header; |
|
93 |
uint8_t ver_len; |
|
94 |
uint16_t speed; |
|
95 |
uint16_t start_angle; |
|
96 |
OradarLidarPoint point[POINT_PER_PACK]; |
|
97 |
uint16_t end_angle; |
|
98 |
uint16_t timestamp; |
|
99 |
uint8_t crc8; |
|
100 |
} OradarLidarFrame; |
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
typedef struct LidarDotData |
|
105 |
{ |
|
106 |
unsigned char intensity; |
|
107 |
unsigned char s1; |
|
108 |
/* |
|
109 |
struct { |
|
110 |
unsigned char flag:2; |
|
111 |
unsigned char s1:6; |
|
112 |
}; |
|
113 |
*/ |
|
114 |
unsigned char s2; |
|
115 |
}stLidarDotData; |
|
116 |
|
|
117 |
typedef struct tagLidarDotsPkt |
|
118 |
{ |
|
119 |
unsigned short StSign; |
|
120 |
unsigned char CT; |
|
121 |
unsigned char LSN; |
|
122 |
unsigned short FSA; |
|
123 |
unsigned short LSA; |
|
124 |
unsigned short CS; |
|
125 |
stLidarDotData LidarDotDatas[40]; |
|
126 |
|
|
127 |
}stLidarDotsPkt, *pLidarDotsPkt; |
|
128 |
|
|
129 |
|
|
130 |
typedef struct tagLidarVector |
|
131 |
{ |
|
132 |
int intensit; |
|
133 |
int angle; |
|
134 |
int value; |
|
135 |
}stLidarVector; |
|
136 |
|
|
137 |
typedef struct tagLidarDot |
|
138 |
{ |
|
139 |
int x; |
|
140 |
int y; |
|
141 |
unsigned int distance; |
|
142 |
}stLidarDot; |
|
143 |
|
|
144 |
|
|
145 |
extern int nPosX; |
|
146 |
extern int nPosY; |
|
147 |
extern int nPosZ; |
|
148 |
extern int nPosZ1, nPosZ2; |
|
149 |
|
|
150 |
extern int pCount1; |
|
151 |
extern int pCount2; |
|
152 |
|
|
153 |
extern int eCount1; |
|
154 |
extern int eCount2; |
|
155 |
|
|
156 |
extern int dCount1; |
|
157 |
extern int dCount2; |
|
158 |
|
|
159 |
extern int vCount1; |
|
160 |
extern int vCount2; |
|
161 |
|
|
162 |
extern int results[32]; |
|
163 |
|
|
164 |
|
|
165 |
int OrdLidarStart(int nIdx); /* Start LiDar Running , nIde = 0 , 1 , -1 == ALL */ |
|
166 |
int OrdLidarStop(int nIdx); /* stop Lidar Running , nIde = 0 , 1 , -1 == ALL */ |
|
167 |
|
|
168 |
|
|
169 |
int OrdLidarParsePkt(int nLidarIdx, OradarLidarFrame * pLindarPkt, int len1); |
|
170 |
|
|
171 |
int ProcessPos(int nLidarIdx, stLidarDot * pLindarDots, int nCount); |
|
172 |
|
|
173 |
#endif /* __ORDLIDAR_H__ */ |
|
174 |
|