Hi,I am working with the ur5e and want to controlScript:I open the socket connection with python. I receive the 1108 Bytes and I parse the actual position. I do this in a loop, 1000 times.But the received position is every time the same. But the robot is moving.Now I close the socket Question:Why is the sent actual TCP position everytime the same?Do I have to sent an URScript to the UR5e which is calling the get_actual_tcp_position() and is sending it to a digital out?
It is only working if I call connect and close within the loop for receiving the full 1108 bytes.But why do I need to reconnect to the UR5E to get the current position?Why doesnt the UR5E send the actual tcp position without reconnecting to him?I am confused
I've never experienced that situation, we listen to port 30003 on all of the robots and they are streaming real time data. We use nodejs as our backend language, maybe there is something in the python code that is not allowing you to receive new data packets and you are just looping through the same packet each time.I am not a python programmer but if you wanted to post the code I would be happy to look at it best I can, maybe others on here could help as well.I know with nodejs once we establish the socket connection we have to add a listener to the socket that actually listens for the incoming data stream and then passes off each new packet to the code that breaks it down and stores it into the state tree.
Ok I deliver now detailled informationmy python code:# Echo client programimport socketimport timeimport structHOST = "192.168.80.128" # The remote hostPORT_30003 = 30003print "Starting Program"count = 0home_status = 0program_run = 0s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)s.settimeout(10)s.connect((HOST, PORT_30003))s.setblocking(0)while (True): if program_run == 0: try: get_active_tcp(s) get_active_tcp(s) get_active_tcp(s) get_active_tcp(s) get_active_tcp(s) get_active_tcp(s) except socket.error as socketerror: print("Error: ", socketerror) home_status = 1program_run = 0s.close()print "Program finish"//And the get_active_tcp:def get_active_tcp(s): time.sleep(1.00) print "" packet_1 = s.recv(4) packet_2 = s.recv(8) packet_3 = s.recv(48) packet_4 = s.recv(48) packet_5 = s.recv(48) packet_6 = s.recv(48) packet_7 = s.recv(48) packet_8 = s.recv(48) packet_9 = s.recv(48) packet_10 = s.recv(48) packet_11 = s.recv(48) packet_12 = s.recv(8) packet_12 = packet_12.encode("hex") #convert the data from \x hex notation to plain hex x = str(packet_12) x = struct.unpack('!d', packet_12.decode('hex'))[0] print "X = ", x * 1000 packet_13 = s.recv(8) packet_13 = packet_13.encode("hex") #convert the data from \x hex notation to plain hex y = str(packet_13) y = struct.unpack('!d', packet_13.decode('hex'))[0] print "Y = ", y * 1000 packet_14 = s.recv(8) packet_14 = packet_14.encode("hex") #convert the data from \x hex notation to plain hex z = str(packet_14) z = struct.unpack('!d', packet_14.decode('hex'))[0] print "Z = ", z * 1000 packet_15 = s.recv(8) packet_15 = packet_15.encode("hex") #convert the data from \x hex notation to plain hex Rx = str(packet_15) Rx = struct.unpack('!d', packet_15.decode('hex'))[0] print "Rx = ", Rx packet_16 = s.recv(8) packet_16 = packet_16.encode("hex") #convert the data from \x hex notation to plain hex Ry = str(packet_16) Ry = struct.unpack('!d', packet_16.decode('hex'))[0] print "Ry = ", Ry packet_17 = s.recv(8) packet_17 = packet_17.encode("hex") #convert the data from \x hex notation to plain hex Rz = str(packet_17) Rz = struct.unpack('!d', packet_17.decode('hex'))[0] print "Rz = ", Rz packet_18 = s.recv(624)// UR5-Simulator is running in the VMWare and is in the remote running.// If I move the Roboter with another script, the Roboter is moving, but no change in the received message.// But it is a different message because the timestamp in the received message is changing!// So what is my mistake? Do I have to execute a URScript in the Roboter to get the current tcp?
I had to make some changes to the program to get it to run as I am on Python 3.7 but I am seeing the same behavior you are. What is weird though is with the robot sitting still you will see slight variations in the data, I am seeing changes of around 0.05 mm in the data stream which corresponds nicely with what I am actually seeing on the screen of the pendant. But as soon as I move the robot, even manually, the data does not change but I am still seeing slight variations in the streaming data, so its not like it has a constant that it is stuck with.Like I said, I am not a python programmer so I will have to dig a little deeper. I will try to do a simple nodejs program as well to see if I am seeing similar issues. We do not decode RTE for position data, we use RTDE for all of that now as RTE was deprecated a while ago and they are pushing everyone to RTDE which is a more robust data tool. I would recommend if you are building something new that you take a look at the RTDE documentation. I know there are some sample Python programs on the UR website as well as its a little more complex to set-up and get running.
Ok, can I have an working example for the RTDE Port? I will test immidiatlyI need an example with showing the current Position :-)
It is working with RTDEHints: starting the record.py with --samples 2500 worksstarting without --samples 2500 leads to a corrupt csv file.For plotting I started example_plot.pyIs RTDE the future?Is there a sample code for parsing the RTDE Protocol in MATLAB?
RTDE is the recommended port for gathering real time data. It’s also a 2-way channel meaning you can inject data back into the robot on that channel whereas 30003 RTE was only a streaming channel for data that you could send script over. I’ve never used matlab but all of the packet types are there in the RTDE information so I’m sure you could use that to decode it in Matlab if you can make the connection.
Hi,
I am working with the ur5e and want to control
Script:
I open the socket connection with python.
I receive the 1108 Bytes and I parse the actual position. I do this in a loop, 1000 times.
But the received position is every time the same.
But the robot is moving.
Now I close the socket
Question:
Why is the sent actual TCP position everytime the same?
Do I have to sent an URScript to the UR5e which is calling the get_actual_tcp_position() and is sending it to a digital out?