Sending motion commands to a KUKA arm in server mode via EthernetKRL (from a Windows-host-based Python program)

  • Hello


    I'm working with a KUKA KR10R1100_2 robot arm and would like to be able to tell it how to move to different poses (positions plus rotations) via a Python program on a Windows machine (as opposed to using the Teach Pendant or just sending over a canned-program).
    I'm curious about how to use RoboDK to:

    1. Put the KUKA robot into "server mode" where the robot's "background submit interpreter" can both
      1. receive raw-string commands (like what positions and angles the arm should move to next) FROM a host Windows computer over EthernetKRL and
      2. send back raw-string reports of its current position/speed/etc TO a host windows computer over EthernetKRL.
    • All code on the Windows host computer will be written in Python.
    • I'd like to send and receive the raw-strings messages (as opposed to XML messages) at 5-10Hz (every 0.1 to 0.2 seconds), which should be achievable over EthernetKRL (without needing the "real-time" control).
      • It's my understanding that we get to control the raw-string message format. I'd like to do this in JSON format, like: {"X": 1.0, "Y": 2.0, "Z": 3.0, "Rx": 0.4, "Ry": 0.5, "Rz": 0.6}

    Since this application involves writing code on BOTH the robot-side and the Windows host computer, I'm looking for sample code for each side (robot and Windows host). Any insights, advice, or sample code would be much appreciated!


    Thanks!


    --Reuben

  • Place your Ad here!
  • Lemster68

    Approved the thread.
  • I'd like to send and receive the raw-strings messages (as opposed to XML messages) at 5-10Hz (every 0.1 to 0.2 seconds), which should be achievable over EthernetKRL (without needing the "real-time" control).

    Is the PC app driving the communications?


    What you're describing doesn't sound too hard. I've seen it done by setting the KRC to run as a server in UDP mode, and using the various Flags to detect if the connection is active, and if a new datagram has been received. It really simplifies things if you can ensure that the incoming datagram is always a fixed number of bytes -- use leading-zero padding, always include sign characters, stuff like that. Grabbing the string from the EKI input buffer and stuffing it into a CHAR array isn't too hard, and is in the manual examples.


    Parsing that raw JSON out will be something you'll have to program yourself, though. KRL doesn't handle JSON natively. It should be doable, I've done it with CSV data. But, again, if you can ensure that your incoming datagram string has a fixed number of bytes for each "variable", that will simplify your task a great deal.

  • panic mode : Could you please include a link and a page number for the CWRITE information that you mentioned? ("since you plan on controlling message format yourself, you better read CWRITE manual"). One of the issues that I've been running up against is the many, many manuals and knowing which ones to read :winking_face:


    SkyeFire : Yes, the PC app is driving the communications. Your idea sounds like what I'd like to do. Could you please send any example that you have, whether something from a manual or something that you've written? It doesn't need to be JSON-format specific, just anything where you're sending/receiving strings with KRC running in server mode.


    To both of you, many thanks for taking the time to help me out!


    --Reuben

  • check pinned topic READ FIRST. it tells among other things what the key manuals are,where and how one can get them.


    CWRITE manual covers few instructions that maybe mentioned but not covered in detail in system integrator manual. also searching forum posts for CWRITE will get you plenty of info.


    Few warnings:

    1. Also this is not very fast, so where possible it may be better to stick with XML.

    2. Parsing data is possible but it is tedious and one need to diligently test everything (there will be surprises). I ended writing own library for this reason. I always try to break things down into small and simple functions that are faster to test and behave the way i want.

    3. You will likely have to do similar as even some of built in instructions have limitations that may not be obvious. For example KRL does not really support strings. As a substitute it uses character array and there are some subtle differences and peculiarities.

    4. null character is treated as a string termination. if the received string contains null, anything that follows will still be there but it will not be displayed. In some cases this can be useful, in others it is a pain.

    5. SWRITE function allows creating of string content from different sources. IT is nice and flexible, supporting variety of format characters that could be used as separator. but SREAD which is supposed to be complementary function is not nearly as flexible. in fact it only supports space as separator. guess what you need to do when your message to be parsed contains something else (comma or semicolon... ). that's right, you need to do search and replace which is another performance penalty. and guess what happens when your string (JSON or whatever) contains several separators like commas, curly braces, etc. it is just more fun... but since you are in a position to choose your own format, you can do anything you like.


    also check German forum, there is a lot of tidbits as well.

    Zerstückeln eines Char Arrays und dessen Zuweisung als REAL Variable - Roboterforum.de - die Industrieroboter und Cobot Community
    Hallo zusammen, ich habe eine Frage bezüglich des Zerstückelns eines Char Arrays. Und zwar möchte ich mir bestimmte Zahlen aus dem Char Array rauspicken und…
    www.roboterforum.de

    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

  • Hello, you can also use C3 Bridge.exe for this instead of KUKA.Ethernet KRL. Its faster also than KUKAVarproxy, you have sample videos, etc...


    VDm

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

Advertising from our partners