Ethernet_KRL with TCP sockets in python

  • Hi,


    I was assigned project about use add-on technology package called EthernetKRL to sent data1 form server (My PC) to Client a Robot Controller (.src file) via XML file and must use Python.


    So, In the past, I'm read KUKA.Ethernet KRL 3.0 manual and try to configuration network connection in server program user interface (that simulate to a server) via the KLI of the robot controller. It's work that can send/received and display data.


    But now if I want to open server on python and send data1 (XML) via TCP/IP socket, I use a XmlTransmit.src and XmlTransmit.xml as an example to do.

    I know the main 3 components are

    1. Server.py (this part is on My PC)
    2. Data.xml (use for send data)
    3. Client.src (to received data that send from PC and run robot program)

    What do I have to do? Any one can help me pls.

    ______________________________________________________________________________________________________________________

    1 a data that I want to sent is a variable or integer

    __________________________________________________________________________________________________

    KSS version 8.6.5

    Controller type : KR C4 Compact

    Robot type : KR10 R1100


    Thankyou :)

  • AD
  • read the manual...


    It tells you how to configure robot and establish connection.


    EKI includes sample server so you can test your robot setup.


    Once you confirm that this is fine (connecting and data exchange works as expected), you can work on making own server and just point EKI to a different server.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • What do I have to do? Any one can help me pls.

    Much the same as when you had the robot set up as the server, simply in reverse. The EKI manual covers this in detail -- setting the robot up as a client is probably easier than setting it up as a server.


    Python has a lot of libraries for acting as a TCP/IP server, and for parsing XML. There are innumerable examples and discussions on StackOverflow and other web sites.

  • Thank you for your suggestion.

  • Much the same as when you had the robot set up as the server, simply in reverse. The EKI manual covers this in detail -- setting the robot up as a client is probably easier than setting it up as a server.


    Python has a lot of libraries for acting as a TCP/IP server, and for parsing XML. There are innumerable examples and discussions on StackOverflow and other web sites.

    First of all, thanks for your advice.


    In my project, I am set up the robot as a client and in python will set up to a server. But now I'm stuck in a part of how to send .XML file from python to robot via socket TCP/IP and another part about the config file that, How I must write (this part is in Config > User > Common > folder EthernetKRL).


    Or I must to create .xml file in part of python then send to config and use .src call it.


    If you have a example, let me look. Please :)


    Thankyou

  • Yes, In that part about an open server in python via TCP/IP, I'm not stuck.


    But now I'm confused about how to send .XML file from python to robot via socket TCP/IP and How I must write (this part is in Config > User > Common > folder EthernetKRL) to make sure the data has been sent from the server to the robot.


    Thanks a lot.

  • I always use Anaconda to install the library and use QT for design UI.


    But Did you know about how to send .XML file from python to robot via socket TCP/IP ?


    So, I know that "It communicates with .xml file."


    Thankyou.

  • server does not transmit files, it sends a messages. and this message can be string for example...


    "this is a plain string"

    "<MyData>This is an XML formatted string</MyData>"


    or if you want to send numeric value


    as a plain string: "123456"

    as an XML string: "<Distance>123456</Distance>"


    if you want to use XML format, your data need to be formatted correctly.


    but this is message.... and you seem to be confusing this message with EKI configuration file.

    EKI configuration file tells EKI how the connection is made and how the message is structured.... but this is NOT the message. it is just a blueprint for the message.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • But now I'm confused about how to send .XML file from python to robot via socket TCP/IP and How I must write (this part is in Config > User > Common > folder EthernetKRL) to make sure the data has been sent from the server to the robot.

    As I said, it's almost identical to how you already did it when the robot was acting as a server. There are a few details to change, but the EKI manual details this pretty well. What specifically are you having trouble with?

  • As I said, it's almost identical to how you already did it when the robot was acting as a server. There are a few details to change, but the EKI manual details this pretty well. What specifically are you having trouble with?

    My trouble is how to send the .XML file to robot via TCP/IP with Python. Because I want to send a variable or integer from server to Robot Controller.


    Thankyou

  • i am not sure you grasping the concepts and meaning of terms you use...


    1. do you know that there are different types of 'servers'?

    your server is TCP server.... not a file server, not an FTP server, not an email server, not a print server, not a restaurant waiter....


    TCP server is sending TCP messages... not files, not emails, not print jobs, not bringing food...

    TCP message is block of data that includes frame and data block (sequence of bytes).

    frame is a "box" or "envelope" that encapsulates data block and contains info where the messages is from and who is it for.


    btw it is possible to use TCP messages to transport files.... piecemeal.... and assemble file from the datablocks but this is beyond of what is happening here. EKI is not a file transfer...


    2. do you know what server does? it sits and waits... it does nothing until spoken to. it does not actively send something, it is passive and waits for clients to connect and request something. it is client that opens connection and tells "i need this and that" and THEN server replies.


    3. "variable or integer" thing. what is it? what do you mean exactly?


    4. establishing connection requires SEQUENCE of things. things must happen in the right order to create one. server MUST be running first.... then client can try connecting to it. and if connection is successful, client need to request something, then server replies.

    think of this forum. it is running on some webserver (which is a server). your computer uses browser (which is a client). in order for you to see anything on this forum, forum must be already running, before your computer tries to connect to it and tell what page you want to visit, then server replies and you get correct page displayed.


    5. EKI includes manual and examples. you should try to get familiar with them. XmlTransmit.xml is sample configuration for KRC acting as a client. but this is not ready to use as is. you also need to adapt network configuration by using correct IP address and port of the server. did you do this? are you able to establish connection to a server? are you able to send message to a server? does server receive it? if any of this is not taking place there will be no response from the server.


    6. server need to send correctly FORMATED message that matches configuration in mentioned XML. only then EKI can decode message and get correct integer value you are interested in. so... are you familiar with XML? are you familiar with tags and how they are nested?


    message that server sends and client receives is quite complex and you need to match the entire thing exactly by creating correct format of the message.


    this is receive configuration for client:


    so top level tag is "Sensor" which means your message will need to include

    "<Sensor></Sensor>"

    then inside is bunch of other tags (Message, Positions, Nmb, Status etc)

    each of those will have a tag that must be nested into previous tag.

    for example to send message with only "Nmb" (which is an integer), server would need to send message

    "<Sensor><Nmb>1234</Nmb></Sensor>"


    and server can replace mentioned "1234" sample with whatever integer value you want sent.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now