-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnavLidarPoint.py
56 lines (48 loc) · 1.18 KB
/
navLidarPoint.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
48
49
50
51
52
53
54
55
56
import math
import numpy as np
import logging
import json
# START Class LidarPoint ----------------------------------------------
class LidarPoint:
def __init__(self):
self.angle = 0
self.r = np.zeros(2)
self.dist = 0
self.col = False
def print(self):
logging.info("angle: " + str(math.degrees(self.angle)) + " | oi: " + str(self.r) + " | dist: " + str(self.dist) + " | collision: " + str(self.col))
def get_coords(self):
return list(self.r)
def get_col(self):
return self.col
def get_coord_list(self, limits_list):
oi = []
for aux in limits_list:
coords = []
mylist = aux.get_coords()
coords.append(int(mylist[0]))
coords.append(int(mylist[1]))
oi.append(coords)
return oi
def get_coords_point_data(self, limits_list):
oi = []
for aux in limits_list:
oi.append(aux.to_dict())
return oi
def to_dict(self):
point = {
"angle": self.angle,
"rx": self.r[0],
"ry": self.r[1],
"dist": self.dist,
"col": self.col,
}
return point
def from_dict(self, point):
self.angle = point["angle"]
self.r = np.zeros(2)
self.r[0] = point["rx"]
self.r[1] = point["ry"]
self.dist = point["dist"]
self.col = point["col"]
return self