-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimestampHandler.py
executable file
·42 lines (30 loc) · 1.33 KB
/
TimestampHandler.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
#TimestampHandler.py - Timetsamp Handler for ZED2i sensor data
#Import ZED module
import pyzed.sl as sl
#TimestampHandler class
class TimestampHandler:
#Class constructor, initalize timetsamps to init time
def __init__(self):
self.last_bar_timestamp = sl.Timestamp()
self.last_imu_timestamp = sl.Timestamp()
self.last_mag_timestamp = sl.Timestamp()
#Class destructor
def __del__(self):
pass
#isNew - Determines whether to update ZEDControllers class attributes based on timestamps
def isNew(self, sensor):
if (isinstance(sensor, sl.BarometerData)):
new = (sensor.timestamp.get_microseconds() > self.last_bar_timestamp.get_microseconds())
if new:
self.last_bar_timestamp = sensor.timestamp
return new
elif (isinstance(sensor, sl.IMUData)):
new = (sensor.timestamp.get_microseconds() > self.last_imu_timestamp.get_microseconds())
if new:
self.last_imu_timestamp = sensor.timestamp
return new
elif (isinstance(sensor, sl.MagnetometerData)):
new = (sensor.timestamp.get_microseconds() > self.last_mag_timestamp.get_microseconds())
if new:
self.last_mag_timestamp = sensor.timestamp
return new