When the server receives the read request what is it returning the to the robot and how is the data wrapped? What is an example of the return value the server is sending?
Tr1peiro
matthewd92 said:When the server receives the read request what is it returning the to the robot and how is the data wrapped? What is an example of the return value the server is sending?
the code i use on the robot is the following down
def test2():
flag = False
sync_flag = False
open = False
while(open == False):
open = socket_open("192.168.1.6",5050)
end
# popup("Connected to server!")
while (sync_flag != True):
data = socket_read_ascii_float(6)
if (data[1] == 1):
flag = True
end
end
socket_close()
flag = False
end
test2()
flag = False
sync_flag = False
open = False
while(open == False):
open = socket_open("192.168.1.6",5050)
end
# popup("Connected to server!")
while (sync_flag != True):
data = socket_read_ascii_float(6)
if (data[1] == 1):
flag = True
end
end
socket_close()
flag = False
end
test2()
Tr1peiro
matthewd92 said:What is an example of the return from the PC server? If its not configured correctly the robot will not receive it. That is why I asked to see the return value
The code on pc server is write in that way:
"import socket
from struct import pack
#Variaveis
S = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
IP = "192.168.1.6"
PORTA = 5050
FORMAT = "utf-8"
server_address = (IP, PORTA)
S.bind(server_address)
S.listen(5)
connection, client_address = S.accept()
val = pack('i!', 4)
#Escolha das coordenadas
waypoint1 = input('Inserir coordenadas: ' + "\n")
waypoint2 = input('Inserir coordenadas: ' + "\n")
waypoint3 = input('Inserir coordenadas: ' + "\n")
waypoint4 = input('Inserir coordenadas: ' + "\n")
Ligar = input('Enviar coordenadas e ligaar Servidor? ')
#Decidir se conecto ao servidor ou não
if Ligar == ('yes' or 'Y'):
connection.send(val)
S.send(waypoint1.encode())
S.send(waypoint2.encode())
S.send(waypoint3.encode())
S.send(waypoint4.encode())
elif Ligar == ('no' or 'N'):
connection.close()
else:
print("tenta outra vez")
connection.close()"
from struct import pack
#Variaveis
S = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
IP = "192.168.1.6"
PORTA = 5050
FORMAT = "utf-8"
server_address = (IP, PORTA)
S.bind(server_address)
S.listen(5)
connection, client_address = S.accept()
val = pack('i!', 4)
#Escolha das coordenadas
waypoint1 = input('Inserir coordenadas: ' + "\n")
waypoint2 = input('Inserir coordenadas: ' + "\n")
waypoint3 = input('Inserir coordenadas: ' + "\n")
waypoint4 = input('Inserir coordenadas: ' + "\n")
Ligar = input('Enviar coordenadas e ligaar Servidor? ')
#Decidir se conecto ao servidor ou não
if Ligar == ('yes' or 'Y'):
connection.send(val)
S.send(waypoint1.encode())
S.send(waypoint2.encode())
S.send(waypoint3.encode())
S.send(waypoint4.encode())
elif Ligar == ('no' or 'N'):
connection.close()
else:
print("tenta outra vez")
connection.close()"
Tr1peiro
I also test in SocketTest and sending the coordinates and work fine....matthewd92 said:Have you tried using a socket test program to send the request and see what value that server returns. Also, the robot has a timeout of 2 seconds on the read value so if you are waiting for the robot to send a request and then typing the values back you are probably timing out on the robot read
My big trouble now is how i write the socket to connect the machine to the PC.....
In the first time i create one simple code without the while loop but this code doesn't work.....
# def prog():
# open = socket_open("192.168.1.7", 5050)
# movel(Plane_1, accel_mss, speed_ms, 0,0)
# sendToServer = 'Coordenadas: '
# socket_send_string(sendToServer)
# data_1 = socket_read_byte_list(8)
# if data[0]=8
# prog()
# open = socket_open("192.168.1.7", 5050)
# movel(Plane_1, accel_mss, speed_ms, 0,0)
# sendToServer = 'Coordenadas: '
# socket_send_string(sendToServer)
# data_1 = socket_read_byte_list(8)
# if data[0]=8
# prog()
I was wondering if you cold help me in a proggram for the robot UR5, because I have been struggling in the creation of a socket/TCP that can run in the robot but at the same time can read the coordinates that have been sent by the computer.
I have already the code for user/server already created but, the client program(URrobot) i can make a program that cand read this coordinates and I have already tried to use the scripts socket_read_interger and the socket_read_ascii_float and none of them work