def sendCoordinate(coordinate): """Send route to robot via TCP.""" client2Robot = sockets.TCPsocket("client", "localhost", 50005) messageSent = 0 while messageSent == 0: messageSent = client2Robot.sendMessage( "1;ROUTE;%s" % (str(coordinate)), "localhost", 50005) client2Robot.close()
def sendDemo(s): print "JACO: DEMO" clientsocket = sockets.TCPsocket("client", "localhost", 50004) ret = clientsocket.sendMessage("1;DODEMO", "localhost", 50005) if (ret == 1): print "OKOK" else: print "FAIL" clientsocket.close()
def sendGet(s): print "JACO: GET POINT" clientsocket = sockets.TCPsocket("client", "localhost", 50004) ret = clientsocket.sendMessage("1;GETPOINT", "localhost", 50005) if (ret == 1): print "OKOK" else: print "FAIL" clientsocket.close()
def sendHome(s): print "JACO: HOME" clientsocket = sockets.TCPsocket("client", "localhost", 50004) ret = clientsocket.sendMessage("1;GOTOHOME", "localhost", 50005) if (ret == 1): print "OKOK" else: print "FAIL" clientsocket.close()
def send_svg(s): print "JACO: SVGROUTE" global points point_string = json.dumps(points) clientsocket = sockets.TCPsocket("client", "localhost", 50004) ret = clientsocket.sendMessage("1;ROUTE;" + point_string, "localhost", 50005) if (ret == 1): print "OKOK" else: print "FAIL" clientsocket.close()
def sendXYZ(s): clientsocket = sockets.TCPsocket("client", "localhost", 50004) print "sending coordinates:" print "x", dx print "y", dy print "z", dz try: ret = clientsocket.sendMessage( "1;XYZ;" + str(dx) + ";" + str(dy) + ";" + str(dz), "localhost", 50005) except: print "FAIL" ret = None if (ret == 1): print "OKOK" else: print "FAIL" clientsocket.close()
def sendCoordinates2RobotInterface(fullRoute): """Send routes by each layer. Enter is required for next layer.""" server2Robot = sockets.TCPsocket("server", "localhost", 50003) layerIndex = 0 for layer in fullRoute: layerIndex += 1 for route in layer: first = True coordinate_string = "[" for coordinate in route: if not first: coordinate_string = coordinate_string + ", " first = False coordinate_string = coordinate_string + "[%f, %f, %f]" % ( coordinate.x, coordinate.y, coordinate.z) coordinate_string = coordinate_string + "]" sendCoordinate(coordinate_string) while server2Robot.getMessage()[0] != "ACK": pass print "Sent layer " + str(layerIndex) print "Press Enter to proceed." raw_input() print "Sent all layers." server2Robot.close()