Fixed some errors/typos which I had overlooked/missed earlier. Stared implementing main loop.
This commit is contained in:
parent
c173917a72
commit
c1049f4a58
4 changed files with 54 additions and 10 deletions
33
src/main.py
33
src/main.py
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import ev3dev.ev3 as ev3
|
||||
import uuid
|
||||
import paho.mqtt.client as mqtt
|
||||
from planet import Direction, Planet
|
||||
from communication import Communication
|
||||
from communication import Mode, Communication
|
||||
from move import Move
|
||||
|
||||
# DO NOT EDIT
|
||||
|
@ -19,6 +17,35 @@ def run():
|
|||
clean_session=False,
|
||||
protocol=mqtt.MQTTv31)
|
||||
|
||||
communication = Communication(client)
|
||||
move = Move()
|
||||
|
||||
while(communication.planetname is None):
|
||||
communication.process_messages()
|
||||
|
||||
print("received Planet Name")
|
||||
|
||||
while(communication.status() is not Mode.COMPLETE):
|
||||
move.getstationedges() # TODO: Register in map
|
||||
move.turnto(90) # TODO: add control mechanism to communication class
|
||||
move.traversetonextstation(False) # TODO: let same control mechanism decide if station is known, also traversetonextstation needs a return value
|
||||
|
||||
while(communication.status() is Mode.GOTOSTATION): # should be triggered if current station has no unexplored edges
|
||||
for instructions in communication.navto:
|
||||
move.follow(instructions)
|
||||
communication.update()
|
||||
|
||||
while(communication.status() is Mode.TARGET): # should be triggered when communication gets TARGET signal from server
|
||||
for instructions in communication.navto:
|
||||
move.follow(instructions)
|
||||
communication.update() # TODO: implement update function that communicates with server and waits/checks for new instructions
|
||||
if(communication.status() == Mode.TARGET2): # TODO: implement Target change
|
||||
break
|
||||
|
||||
communication.update()
|
||||
|
||||
|
||||
|
||||
|
||||
# DO NOT EDIT
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue