def control(decision): seekrate_ = 6000 driveboard.feedrate(seekrate_) driveboard.intensity(0.0) if decision == "left": driveboard.move(-10.0, 0) time.sleep(0.1) elif decision == "right": driveboard.move(10.0, 0) time.sleep(0.1) elif decision == "top": driveboard.move(0, -10.0) time.sleep(0.1) elif decision == "bot": driveboard.move(0, 10.0) time.sleep(0.1) elif decision == "quit": driveboard.absolute() driveboard.air_off() driveboard.feedrate(seekrate_) driveboard.intensity(0.0) time.sleep(0.1) driveboard.move(0, 0, 0) time.sleep(0.1) elif decision == "run": driveboard.absolute() path = [[[0, 0], [0, 0]], [[30.0, 30.0], [30.0, 60.0], [60.0, 60.0], [60.0, 30.0], [30.0, 30.0]]] driveboard.intensity(0.0) driveboard.air_on() seekrate_ = 6000 feedrate_ = 2000 intensity_ = 100.0 for polyline in path: if len(polyline) > 0: driveboard.feedrate(seekrate_) driveboard.intensity(0.0) driveboard.move(polyline[0][0], polyline[0][1]) if len(polyline) > 1: driveboard.feedrate(feedrate_) driveboard.intensity(intensity_) for i in range(1, len(polyline)): driveboard.move(polyline[i][0], polyline[i][1]) time.sleep(0.08) driveboard.air_off() driveboard.feedrate(seekrate_) driveboard.intensity(0.0) time.sleep(0.1) driveboard.move(0, 0, 0) time.sleep(0.1)
def air_on(): driveboard.air_on() return '{}'
# ip_address = "127.0.0.1" # output hostname, domain name and IP address print("working on {} ({}) with {}".format(local_hostname, local_fqdn, ip_address)) # bind the socket to the port 65431 server_address = (ip_address, PORT) print("starting up on {} port {}".format(server_address[0], server_address[1])) s.bind(server_address) # listen for incoming connections (server mode) with one connection at a time s.listen(1) driveboard.intensity(0.0) driveboard.air_on() # wait for a connection print("waiting for a connection") connection, client_address = s.accept() print(client_address) try: # show who connected to us print("connection from {}".format(client_address)) # receive the data in small chunks and print it while True: data = connection.recv(1024) if data: # output received data