-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.py
More file actions
41 lines (23 loc) · 788 Bytes
/
Logger.py
File metadata and controls
41 lines (23 loc) · 788 Bytes
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
#!/usr/bin/python
import json
import DroneStatus
class Logger:
def __init__(self):
self.text = []
def record(self, str):
self.text.append(str)
class DroneLogger(Logger):
def __init__(self, uid, drone):
self.uid = uid
self.actions = []
self.drone = drone
def log(self, timestamp):
action = {"action": self.drone.status, "timestamp": timestamp}
if self.drone.status == "MOVE":
action["lng"] = self.drone.polarPosition.lng
action["lat"] = self.drone.polarPosition.lat
action["alt"] = self.drone.polarPosition.alt
self.actions.append(action)
def generateLog(self):
log = {"id": self.uid, "waypoints": self.actions}
return json.dumps(log)