-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrone.py
More file actions
executable file
·61 lines (49 loc) · 1.61 KB
/
Copy pathDrone.py
File metadata and controls
executable file
·61 lines (49 loc) · 1.61 KB
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
57
58
59
60
#!/usr/bin/python
import PositionConversions
from Action import Action
from Logger import DroneLogger
from DroneStatus import *
from PolarCoordinate import PolarCoordinate
from ServerMessenger import *
from Vector import Vector
class Drone:
def __init__(self, uid, startTime, waypoints, actions):
self.uid = uid
self.startTime = startTime
self.waypoints = waypoints
self.actions = actions # Actions are sorted
assert waypoints
self.polarPosition = PolarCoordinate(*waypoints.pointList[0].values())
self.velocity = Vector()
self.actionTtl = 0
self.status = DroneStatus.HOVER
self.logger = DroneLogger(uid,self)
self.time = 0
def getLogger(self):
return self.logger
def land(self):
self.status = DroneStatus.LAND
self.velocity = Vector(0, 0, -5)
def move(self):
pass
#self.polarPosition = PositionConversions.nextPolar(self.polarPosition, self.velocity)
#print self.polarPosition
def log(self):
self.logger.log(self.time)
def tick(self, time, messenger):
self.time = time
messenger.updateServer(self)
instructions = messenger.getInstructionsFromServer(self)
#
#
# if self.actionTtl != 0:
# # The drone is carrying out an action.
# pass
# elif self.actions and self.actions[0].startTime == time:
# action = self.actions.pop(0)
#
# # run the action.
# else:
# pass
# # run the instruction
# messenger.notifyServerForTick()