"encoder": [ "5", "5", "50", "5" ] } ''' data = arduinodata.decode(examplestring) print(data) print('\n') for i in data: print(i, data[i]) walls = arduinodata.analyze(data, 'walls') for i in walls: print(i, walls[i]) victims = arduinodata.analyze(data, 'victims') for i in victims: print(i, victims[i]) environment = arduinodata.analyze(data, 'environment') for i in environment: print(i, environment[i]) motors = arduinodata.analyze(data, 'motors') for i in motors: print(i, motors[i])
print("Moved room from tile to current_tile") tasks = stack.Stack() print("Initialised stack") #ACTION while True: m_ser.send('pls#') print("Requested data from Arduino") data = m_ser.receive() print("Received data from arduino") data = arduinodata.decode(data) print("Unzipped received data: ") print(data) wallsdata, victimsdata, environmentdata, motorsdata = arduinodata.analyze( data, 'all') print("Analysed unzipped data") for i in wallsdata: print(i, wallsdata[i]) for i in victimsdata: print(i, victimsdata[i]) for i in environmentdata: print(i, environmentdata[i]) for i in motorsdata: print(i, motorsdata[i]) current_tile, tasks = logic.calculate_action(wallsdata, victimsdata, environmentdata, motorsdata, current_tile, tasks) try:
import arduinodata import history #SETUP m_ser.start #Serial Kommunikation starten kachel = tile.Tile(None, None, None, None) #Initialkachel erstellen kachel.set_coordinates(0, 0, 0) #Initialkachel auf 0, 0, 0 setzen aktueller_raum = kachel #Raum von Kachel zu aktueller_raum verschieben #ACTION while True: m_ser.send('pls#') #Daten von Arduino anfragen data = m_ser.receive('here') #Daten von Arduino empfangen data = arduinodata.decode(data) #Empfangene Daten entpacken wallsdata, victimsdata, environmentdata, motorsdata = arduinodata.analyze( data, 'all') #Entpackte Daten analysieren #kameradaten jetzt auch analysieren if environmentdata[floor] == 'black': #Schwarze Platte checken aktueller_raum.set_type(black) aktueller_raum.set_top(wall.Wall()) #OBEN ABRIEGELN aktueller_raum.set_rgt(wall.Wall()) #RECHTS ABRIEGELN aktueller_raum.set_but(wall.Wall()) #UNTEN ABRIEGELN aktueller_raum.set_lft(wall.Wall()) #LINKS ABRIEGELN #befehl zum runterfahren geben #auf bestätigung warten aktueller_raum = history.get_last_tile() continue #rampe? -> rampenbefahrungsmodus