53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
import uuid
|
|
import paho.mqtt.client as mqtt
|
|
from planet import Direction, Planet
|
|
from communication import Mode, Communication
|
|
from move import Move
|
|
|
|
# DO NOT EDIT
|
|
client = None
|
|
|
|
|
|
def run():
|
|
# DO NOT EDIT
|
|
global client
|
|
# client_id has to be unique among ALL users
|
|
client = mqtt.Client(client_id=str(uuid.uuid4()),
|
|
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__':
|
|
run()
|