Dear all,
My robot is kuka KR6-R900, with KRC4 compact and KSS 8.6.6. The version of RSI is 4.0.
I am trying to connect an external PC to my robot to achieve real time motion control. Right now I am basically following the RSI_Ethernet example in the manual while I developed a UDP server in Python 3.9 to imitate the function of Testserver.exe.
Testing with Testserver.exe is good, I am able to acquire signal and command movement. However, using my own UDP server, I am able to receive xml message from robot but send command to robot. So I guess the ethernet configuration and UDP connection are alright. What happens is RSI will stop in few seconds after the execution of "RSI_MOVECORR()", and pops out "stop by $CORRECTION function (reset or block selection required)" and "Signal flow (running): Object ETHERNET 1 returns error RSITimeout". Meanwhile my UDP server will terminate after receiving several xml message from robot.
I guess the possible cause is either the robot address is set wrong in my UDP server, or the XML format is incorrect. I put effort on checking everything but haven't sort this problem out yet. Any advice from you is appreciated!
My Ethernet configuration:
robot side:
IP: 192.168.1.2 (RSI, virtual 6)
subnet: 255.255.255.0
(I forget other settings but they are default)
external PC side:
IP 192.168.1.1
submnet prefix length 24
gateway 192.168.1.2
DNS 8.8.8.8/ 8.8.4.4
XML message from robot:
<Rob Type="KUKA">
<RIst X="445.0" Y="0.0" Z="790.0" A="180.0" B="0.0" C="180.0"/>
<RSol X="445.0" Y="0.0" Z="790.0" A="180.0" B="0.0" C="180.0"/>
<Delay D="0"/>
<Tech C11="0.0" C12="0.0" C13="0.0" C14="0.0" C15="0.0" C16="0.0" C17="0.0" C18="0.0" C19="0.0" C110="0.0"/>
<DiL>0</DiL><Digout o1="0" o2="0" o3="0"/>
<Source1>0.0</Source1>
<IPOC>29106442</IPOC>
</Rob>
XML message sent to robot from external PC:
<Sen Type="ImFree">
<EStr>Message from RSI TestServer</EStr>
<Tech T21="1.09" T22="2.08" T23="3.07" T24="4.06" T25="5.05" T26="6.04" T27="7.03" T28="8.02" T29="9.01" T210="10.00" />
<RKorr X="0.000" Y="1.0000" Z="0.0000" A="0.0000" B="0.0000" C="0.0000" />
<DiO>125</DiO>
<IPOC>53189046</IPOC>
</Sen>
UDP server code (Python 3.9):
import socket
import os
import time
import xml.etree.ElementTree as ET
# bind UDP socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
#my local IP of external PC is set to 192.168.1.1, same as defined in RSI_Config.xml
# submnet prefix length 24, gateway 192.168.1.2, DNS 8.8.8.8/ 8.8.4.4
server_addr = ('192.168.1.1',59152)
s.bind(server_addr)
print('Bind UDP on 59152...')
# count bytes
cnt=0
while True:
#receive xml file from robot
data, client_addr = s.recvfrom(1024)
# record initial IPOC number from robot
if cnt==0:
#record received xml from robot into a file
f = open("input1.xml", 'wb')
f.write(data)
f.close()
# find IPOC tag
input = ET.parse("input1.xml")
in_root = input.getroot()
# get IPOC value
for ipoc in in_root.iter('IPOC'):
timestamp=ipoc.text
print(timestamp)
timestamp=str(int(timestamp)+4+cnt*4)
print(timestamp)
# prepare xml sent from extenal PC to robot
output=ET.parse('output.xml')
out_root=output.getroot()
# change IPOC in output xml
for ipoc in out_root.iter('IPOC'):
ipoc.text=timestamp
output.write('output1.xml')
#send prepared xml file
filename = "output1.xml"
J = open(filename,'rb')
client_addr = ('192.168.1.2',59152)
data = J.read(1024)
s.sendto(data,client_addr)
# starting from the second file received from robot, no longer record xml file
# only calculate timestamp at interval of 4ms
else:
print(cnt)
timestamp=str(int(timestamp)+4+cnt*4)
# prepare xml sent from extenal PC to robot
output=ET.parse('output.xml')
out_root=output.getroot()
# change IPOC in output xml
for ipoc in out_root.iter('IPOC'):
ipoc.text=timestamp
output.write('output1.xml')
#send prepared xml file
filename = "output1.xml"
J = open(filename,'rb')
client_addr = ('192.168.1.2',59152)
data = J.read(1024)
s.sendto(data,client_addr)
cnt=cnt+1
Display More