-
Notifications
You must be signed in to change notification settings - Fork 13
/
CalcLidarData.py
47 lines (36 loc) · 1.26 KB
/
CalcLidarData.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import binascii
import math
class LidarData:
def __init__(self,FSA,LSA,CS,Speed,TimeStamp,Confidence_i,Angle_i,Distance_i):
self.FSA = FSA
self.LSA = LSA
self.CS = CS
self.Speed = Speed
self.TimeStamp = TimeStamp
self.Confidence_i = Confidence_i
self.Angle_i = Angle_i
self.Distance_i = Distance_i
def CalcLidarData(str):
str = str.replace(' ','')
Speed = int(str[2:4]+str[0:2],16)/100
FSA = float(int(str[6:8]+str[4:6],16))/100
LSA = float(int(str[-8:-6]+str[-10:-8],16))/100
TimeStamp = int(str[-4:-2]+str[-6:-4],16)
CS = int(str[-2:],16)
Confidence_i = list()
Angle_i = list()
Distance_i = list()
count = 0
if(LSA-FSA > 0):
angleStep = float(LSA-FSA)/(12)
else:
angleStep = float((LSA+360)-FSA)/(12)
counter = 0
circle = lambda deg : deg - 360 if deg >= 360 else deg
for i in range(0,6*12,6):
Distance_i.append(int(str[8+i+2:8+i+4] + str[8+i:8+i+2],16)/100)
Confidence_i.append(int(str[8+i+4:8+i+6],16))
Angle_i.append(circle(angleStep*counter+FSA)*math.pi/180.0)
counter += 1
lidarData = LidarData(FSA,LSA,CS,Speed,TimeStamp,Confidence_i,Angle_i,Distance_i)
return lidarData