Hello, this is my first question.
I'm using the KUKA KR70 R2100 model and KR c4 robot controller.
Currently, I installed a proxy server to communicate with the outside on the robot controller, and I succeeded in receiving the variable value by entering the system variable of KUKA through the proxy server.
What I mentioned as proxy server is C3 Bridge, which is the proxy server recommended by RoboDk.
And I communicated with the proxy server by referring to 'openshowvar', a simple open-source client program made in Python to communicate with this 'C3 Bridge' server. Below is a simple example code:
class kukaClient:
def __init__(self, ip, port):
self.ip = ip
self.port = port
self.msg_id = random.randint(1, 100)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
self.sock.connect((self.ip, self.port))
except socket.error as e:
print(f"Socket error: {e}")
sys.exit(-1)
def test_connection(self):
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ret = sock.connect_ex((self.ip, self.port))
sock.close()
return ret == 0
except socket.error as e:
print(f"Socket error: {e}")
return False
@property
def can_connect(self):
return self.test_connection()
def read(self, var, debug=True):
if not isinstance(var, str):
raise TypeError('Var name must be a string')
self.varname = var.encode('utf-8')
return self._read_var(debug)
def _send_req(self, req):
self.rsp = None
self.sock.sendall(req)
self.rsp = self.sock.recv(256)
def _pack_read_req(self):
req_len = len(self.varname) + 3
return struct.pack('!HHBH' + str(len(self.varname)) + 's',
self.msg_id,
req_len,
0,
len(self.varname),
self.varname)
def _read_var(self, debug):
req = self._pack_read_req()
self._send_req(req)
return self._read_rsp(debug)
def _read_rsp(self, debug=False):
if self.rsp is None: return None
header_format = '!HHBH'
header_size = struct.calcsize(header_format)
body = self.rsp[header_size:-3] # Exclude the 3-byte end marker
is_ok = self.rsp[-3:]
if debug:
print('Response:', self.rsp)
# else:
# self.msg_id = (self.msg_id + 1) % 65536
# return self.rsp.decode('utf-8')
if is_ok.endswith(b'\x01'):
self.msg_id = (self.msg_id + 1) % 65536
return body.decode('utf-8')
def loop_read_var(self, var, interval=1):
try:
while True:
response = self.read(var, debug=False)
if response is not None:
time.sleep(interval)
except KeyboardInterrupt:
def close(self):
self.sock.close()
Display More
What I really want is to know if there is a way to give movement commands to the KUKA robot through proxy server communication, just like reading *.src files using smart pads to give KRL movement commands.
Thank you for reading the long article. I look forward to response.