-
Notifications
You must be signed in to change notification settings - Fork 0
/
datapoint.py
45 lines (34 loc) · 1.09 KB
/
datapoint.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
from tools import polar_to_cartesian
class DataPoint:
"""
A set of derived information from measurements of known sensors
NOTE: Upon instantiation of a "radar" DataPoint, state variables are computed from raw data
"""
def __init__(self, d):
self.timestamp = d['timestamp']
self.name = d['name']
self.all = d
self.raw = []
self.data = []
if self.name == 'state':
self.data = [d['x'], d['y'], d['vx'], d['vy']]
self.raw = self.data.copy()
elif self.name == 'lidar':
self.data = [d['x'], d['y'], 0, 0]
self.raw = [d['x'], d['y']]
elif self.name == 'radar':
x, y, vx, vy = polar_to_cartesian(d['rho'], d['phi'], d['drho'])
self.data = [x, y, vx, vy]
self.raw = [d['rho'], d['phi'], d['drho']]
self.all['processed_data'] = self.data
self.all['raw'] = self.raw
def get_dict(self):
return self.all
def get_raw(self):
return self.raw
def get(self):
return self.data
def get_timestamp(self):
return self.timestamp
def get_name(self):
return self.name