Repository navigation
Expand file tree
/
Copy pathBehaviorInterface.py
More file actions
54 lines (38 loc) · 2 KB
/
Copy pathBehaviorInterface.py
File metadata and controls
54 lines (38 loc) · 2 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
class BehaviorInterface:
#Husk, en behavior skal ikke kommunisere med en annen behavior!
def __init__(self,bbcon,sensorList, priority):
self.__bbcon = bbcon #Pointer til kontrolleren, bruk til indirekte kommunikasjon
self.__sensors = sensorList #Liste av sensor objektene som leverer info
self.__motorRecs = [] #Anbefalinger som sendes til motorene, kan kanskje fernes og erstattes med en funskjon
self.__active = False #Bestemmer om behavior er aktiv
self.__priority = priority #Prioriteten til behavioren, tall mellom 0 og 1.
self.__halt_request = False #Request å stoppe (avslutte bevegelse)
self.__match_degree = 0 #Tall mellom 0 og 1 som indikerer hvor 'sikker' behavioren er på det den leser.
self.__weight = 0 #Hvor 'viktig' anbefalingen er, =prioritet*match_degree
#Obligatoriske funksjoner
def consider_deactivation(self):
#Whenever a behavior is active, it should test whether it should deactivate.
pass
def consider_activation(self):
#Whenever a behavior is inactive, it should test whether it should activate.
pass
def update(self):
#The main interface between the bbcon and the behavior (detailed below).
#Test om behavioren skal aktiveres/deaktiveres:
if (self.__active):
self.consider_deactivation()
else:
self.consider_activation()
#Hvis fortsatt aktiv, gjør dette:
if (self.__active):
self.sense_and_act()
self.__weight = self.__priority * self.__match_degree #Oppdaterer weight, basert på data
def sense_and_act(self):
#The core computations performed by the behavior that use sensob readings to produce motor recommendations
# (and halt requests).
#Husk å oppdatere match_degree
pass
#Hjelpefunksjoner
def main():
pass
if __name__ == '__main__': main()