KRL code to save robot Positions timestamped in a text file. (KRC4)

  • Code
             CWRITE($FCT_CALL,s,m,"krl_fopen","spline_log.txt","a", handle)
             SWRITE(tester[], S, OFS,"%d", $PRO_NAME1[])
             CWRITE($FCT_CALL,s,m,"krl_fwriteln", handle, tester[])
             CLEAR = STRCLEAR(tester[])

    I just double checked and $pro_name1[] returns same error as above: tester value invalid.. think I've given up and will create another variable to store the additional details i need.

  • ahhhh. shit. this is embarrassing. It works if I don't misread the CREAD / CWRITE documentation table for conversion characters.. for a char array it helps if you use %s and not the other ones which cause the error I was getting.


    Code
             CWRITE($FCT_CALL,s,m,"krl_fopen","spline_log.txt","a", handle)
             SWRITE(tester[], S, OFS,"%s", $PRO_NAME1[])
             CWRITE($FCT_CALL,s,m,"krl_fwriteln", handle, tester[])
             CLEAR = STRCLEAR(tester[])
  • Interestingly, I started with EKI for this project. The data points were 200ms apart, which was too lo-fidelity, so switched to recording locally on the control pc. Pretty sure it wasn't a networking issue, but that I was using the sps.sub to communicate with EKI, but by that stage I was using cwrite.

    Hm... EKI should be more than fast enough, based on previous experience. Were you opening/closing the port on every send? That will definitely slow things down.


    The SWRITE and CWRITE commands are pretty slow (though I don't recall ever doing a scientific speed test on them), but not 200ms slow. When I was passing several kB of data over EKI, it took more time to do the port open/close than to send all the data. The trick was to open the port, then just "stream" the data over until the entire process was done and then close the port. Avoid any handshaking beyond the return of EKI_SEND. And of course, in an SPS loop, it's vital to avoid any WAITs and minimize branches.


    ahhhh. shit. this is embarrassing. It works if I don't misread the CREAD / CWRITE documentation table for conversion characters.. for a char array it helps if you use %s and not the other ones which cause the error I was getting.

    Happens to all of us. I spent a day or more struggling with CWRITEs a few years ago until I realized I was using the KSS 8.2 manual on a KSS 8.3 robot, and CWRITE had added a new argument (in the middle, not the end, WTF KUKA?) in between versions.

Advertising from our partners