Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
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()
Ejemplo n.º 6
0
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()
Ejemplo n.º 7
0
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()