1 Overview
The UR robot provides a variety of ports for controlling and reading robot information. I have sorted out the relevant information, see the article " UR robot communication ports and protocols ".
I use port 30003 to send URScript script control commands to the robot, and receive real-time return data through this port.
2 UR return information protocol analysis
2.1 Return packet frequency and length
Since the information returned by port 30003 is the most complete, including the information returned by ports 30001 and 30002, the information of port 30003 is analyzed here.
The frequency of data returned by port 30003 is generally 125Hz, that is, a data packet is returned every 8ms, and the highest frequency can reach 500Hz.
According to my personal measurement, the byte length of the returned data packet is generally 1108 bytes. According to the document 1, the data packet is 1044 bytes, and the document 2 data packet is 1108 bytes. According to the analysis, UR may expand the UR return data information later.
In fact, the number of bytes specified does not affect the use, because the first four bytes of the returned data packet give the number of bytes of information contained in the data packet.
2.2 Return data packet format
The following table shows the 1044-byte data format of the 30003 real-time feedback port robot information, from reference 1.
byte order | content |
---|---|
1-4 | The number of bytes in the entire packet |
5-12 | Controller power-on time, reset when power off |
13-444 | Joint target position, speed, acceleration, current, torque, actual position, speed, current, control current |
445-684 | TCP position, velocity, force, 0 target position, velocity |
685-692 | input bit state |
693-740 | motor temperature |
740-748 | program scan time |
749-756 | reserve |
757-820 | robot mode, joint mode, safe mode |
821-868 | reserve |
869-892 | TCP acceleration |
893-940 | reserve |
941-948 | speed ratio |
949-956 | Robot's current momentum value |
957-972 | reserve |
973-996 | Control board voltage, robot voltage, robot current |
997-1044 | joint voltage |
The figure below shows the specific data format of each byte of the 1108-byte returned data, from reference 2.
3 Parsing examples
Write a TCP/IP program to control the UR robot, and analyze the data packets returned by it on port 30003. The actual measurement results:
each data packet receives 1108 bytes of data.
Pay attention when parsing the data. The byte order of each data in the received data packet is Big-Endian, that is, the high-order is first, while the byte order in the computer is Little-Endian, that is, the low-order is first. Pay attention to the byte order. sequential conversion.
The following figure shows a part of the received data packet,
taking several main data analysis as examples:
- The first 1-4 bytes (offset address in the figure above: 0x0): 00 00 04 54, integer data, namely 0x454, 1108, this is the byte length of the received data.
- Starting from the 13th byte (offset address in the figure above: 0x0c), there are 6 consecutive Double data, that is, the joint target position q target, and the data are: 2.466446, -0.586911, 1.581819, -2.725837, 4.662427, -0.580726;
- Starting from the 445th byte (offset address in the figure above: 0x1bc), there are 6 consecutive Double data, that is, the current TCP position vector Tool Vector Actual, the data are: 0.405443, -0.164387, 0.030460, 2.077079, -2.308484, 0.256067.
The received data is consistent with the data displayed on the UR teach pendant.
4 related codes
Supplemented the relevant sample codes for the above analysis. If you are interested, please refer to " Windows Sockets Network Programming and UR Robot Communication Data Analysis Code ".
references
1 https://wenku.baidu.com/view/c78aa35c0722192e4436f61c.html
2 https://blog.csdn.net/seing128/article/details/89713207