Posts by Damek123

    Well, it doesn't have to be python. I said that because I was thinking that was the easiest way. What I want to do is to try to read the serial number from a cylinder and convert it to a string. Is that possible in IR vision? Do You maybe have some examples? Do You have advice about what functions do I need to use? Do I need to use Karel? Any advice on what's the easiest way to do that?

    I will use a standard Fanuc industrial camera, nothing special. I just want some guidelines on how to start.

    Thanks!

    Greetings,


    I would like to analyze pictures taken by a camera on my Fanuc robot. I want to make that a loop process. So every picture that the camera takes needs to be sent to a python app and then the app should work with the picture and when it's done robot needs to take another picture and repeat the process. Any advice? I was thinking of some kind of TCP/IP communication via Karel? Since I didn't work with IR vision before can you give me some advice? Where to start (some example, manual, what functions in Karel do I need to use, etc.)?


    Thank You!

    Here is the full code. The idea is that the Karel program works in the background and on the Python app demands changes DO and get register values. I tested locally and everything works. The problem is only that when I run simultaneously Karel and TP program (a simple program that moves the robot through few points) the robot in Roboguide starts lagging and moving in big steps. I tried with a few delays but that didn't help. Any other ideas?


    Thank you!

    -----------------------------------------------------


    PROGRAM kc_test

    %STACKSIZE = 4000

    %NOLOCKGROUP

    %NOPAUSE=ERROR+COMMAND+TPENABLE

    %ENVIRONMENT uif

    %ENVIRONMENT sysdef

    %ENVIRONMENT kclop

    %ENVIRONMENT bynam

    %ENVIRONMENT fdev

    %ENVIRONMENT flbt

    %ENVIRONMENT REGOPE

    %INCLUDE klevccdf

    %INCLUDE klevkeys

    %INCLUDE klevkmsk



    VAR

    file_var : FILE

    tmp_int : INTEGER

    tmp_str : STRING[128]

    status : INTEGER

    entry : INTEGER

    loop1 : BOOLEAN

    broj_kom : INTEGER

    status_2 : INTEGER

    broj_kom_str : STRING[128]

    r_val : REAL

    rflag : BOOLEAN


    BEGIN


    MSG_DISCO('C1:',status)


    label::


    DELAY 100


    SET_FILE_ATR(file_var, ATR_IA)

    SET_VAR(entry, '*SYSTEM*','$HOSTC_CFG[1].$SERVER_PORT',8000,status)

    WRITE(' VAR status = ',status,CR)

    MSG_CONNECT('C1:',status)

    WRITE(' Connect status = ',status,CR)

    loop1 = TRUE

    IF status = 0 THEN

    WHILE loop1 = TRUE DO

    DELAY 100

    WRITE('Opening file...',CR)

    OPEN FILE file_var('rw','C1:')

    status = IO_STATUS(file_var)

    IF status = 0 THEN

    WRITE('Waiting to read from server...')

    DELAY 100

    READ file_var(tmp_str::2)

    WRITE('Read: ',tmp_str::2,CR)

    DELAY 100


    IF tmp_str = 'P1' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[5] = ON

    DELAY 500

    ENDIF


    IF tmp_str = 'P2' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[6] = ON

    ENDIF


    IF tmp_str = 'P3' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[7] = ON

    ENDIF


    IF tmp_str = 'P6' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[8] = ON

    ENDIF


    IF tmp_str = 'P9' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[9] = ON

    ENDIF


    IF tmp_str = '12' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[10] = ON

    ENDIF


    IF tmp_str = 'S6' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[11] = ON

    ENDIF


    IF tmp_str = 'S9' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[12] = ON

    ENDIF


    IF tmp_str = '13' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[13] = ON

    ENDIF


    IF tmp_str = '14' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[14] = ON

    ENDIF


    IF tmp_str = 'F6' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[15] = ON

    ENDIF


    IF tmp_str = '15' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[16] = ON

    ENDIF


    IF tmp_str = 'F9' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[17] = ON

    ENDIF


    IF tmp_str = 'CO' THEN

    FOR tmp_int = 1 TO 18 DO

    DOUT[tmp_int] = OFF

    ENDFOR

    DOUT[1] = ON

    DOUT[2] = ON

    ENDIF


    IF tmp_str = '99' THEN

    DOUT[4] = ON

    CLOSE FILE file_var

    MSG_DISCO('C1:',status)

    GOTO label

    ENDIF


    IF tmp_str = 'BR' THEN

    GET_REG(1, rflag, broj_kom, r_val, status_2)

    CNV_INT_STR(broj_kom, 0, 0, broj_kom_str)

    WRITE file_var(broj_kom_str)

    CLOSE FILE file_var

    ENDIF


    IF tmp_str = 'RS' THEN

    SET_REAL_REG(1,0, status_2)

    DELAY 50

    GET_REG(1, rflag, broj_kom, r_val, status_2)

    CNV_INT_STR(broj_kom, 0, 0, broj_kom_str)

    WRITE file_var(broj_kom_str)

    CLOSE FILE file_var

    ENDIF


    CLOSE FILE file_var

    ELSE

    GOTO label

    ENDIF

    ENDWHILE

    ENDIF

    DELAY 200

    GOTO label


    END kc_test

    PROGRAM kc

    %STACKSIZE = 4000

    %NOLOCKGROUP

    %NOPAUSE=ERROR+COMMAND+TPENABLE

    %ENVIRONMENT uif

    %ENVIRONMENT sysdef

    %ENVIRONMENT kclop

    %ENVIRONMENT bynam

    %ENVIRONMENT fdev

    %ENVIRONMENT flbt

    %INCLUDE klevccdf

    %INCLUDE klevkeys

    %INCLUDE klevkmsk



    VAR

    file_var : FILE

    tmp_int : INTEGER

    tmp_str : STRING[128]

    status : INTEGER

    entry : INTEGER

    loop1 : BOOLEAN

    s : STRING[25]


    BEGIN

    MSG_DISCO('C1:',status)


    label::


    DELAY 100


    SET_FILE_ATR(file_var, ATR_IA)

    SET_VAR(entry, '*SYSTEM*','$HOSTC_CFG[1].$SERVER_PORT',8000,status)

    WRITE(' VAR status = ',status,CR)

    MSG_CONNECT('C1:',status)

    WRITE(' Connect status = ',status,CR)


    DELAY 100


    IF status = 0 THEN

    WRITE(' spojeno',status,CR)

    MSG_DISCO('C1:',status)

    DELAY 100

    WRITE(' Odspojeno',status,CR)

    ENDIF


    DELAY 100


    GOTO label


    END kc


    ---------------------------------------


    Yes, I tried with a few delays but I still get the same behavior.

    Thank You, I didn't know that. However, I tried to add some delays into the code but it still doesn't work correctly.

    Every time when my loop is iterating in Karel the robot moves with lag. If I put a delay to 3000 for example, the lag occurs every 3 s. Any advice on how to solve that? (I am doing everything in Roboguide for now so I don't know if a real robot will behave in the same way).

    I managed to establish a connection and run a simple program in Karel and in TP in parallel.

    But I have a problem with Roboguide. It keeps crashing every time I manage to establish a connection. Also when I run Karel script parallel with a simple TP program (movements between two points) everything starts lagging and robot movements are very slow and in big steps.

    What am I doing wrong? I attached Karel program and TP program.


    -------------------------------

    PROGRAM kc

    %STACKSIZE = 4000

    %NOLOCKGROUP

    %NOPAUSE=ERROR+COMMAND+TPENABLE

    %ENVIRONMENT uif

    %ENVIRONMENT sysdef

    %ENVIRONMENT kclop

    %ENVIRONMENT bynam

    %ENVIRONMENT fdev

    %ENVIRONMENT flbt

    %INCLUDE klevccdf

    %INCLUDE klevkeys

    %INCLUDE klevkmsk



    VAR

    file_var : FILE

    tmp_int : INTEGER

    tmp_str : STRING[128]

    status : INTEGER

    entry : INTEGER

    loop1 : BOOLEAN


    BEGIN

    label::

    SET_FILE_ATR(file_var, ATR_IA)

    SET_VAR(entry, '*SYSTEM*','$HOSTC_CFG[1].$SERVER_PORT',8000,status)

    WRITE(' VAR status = ',status,CR)


    MSG_CONNECT('C1:',status)

    WRITE(' Connect status = ',status,CR)

    IF status = 1 THEN

    GOTO label_2

    ENDIF

    GOTO label


    label_2::

    MSG_PING('C1:',status)

    IF status = 0 THEN

    MSG_DISCO('C1:',status)

    WRITE('Disconnect status=',status,CR)

    GOTO label

    ENDIF


    GOTO label_2


    END kc

    ----------------------------------------------------



    tp program:

    ---------------------------------------------------

    RUN kc


    LBL[1]


    J PR[1] FINE 100%

    J PR[2] FINE 100%


    JLBL[1]

    I managed to establish a connection. My next question is how to run the Karel program for connecting to the server and collecting data in the background? I don't want to call it from TP. I want to run it every time I start the controller. Is this possible?

    Thank You. I am currently trying to establish a connection between the Fanuc robot in Roboguide and my Python app.

    Is this even possible? I want the robot to be a client and the app needs to act as a server. Is it possible to simulate that kind of connection in Roboguide? Or it needs to be done on a real robot?

    Thank You!

    Have you tested this using a "raw" browser command first? Typically, for a RoboGuide virtual robot, you should be able to point a browser directly to "http://localhost/KAREL/prvi?object=DOUT", and see that the string variable Object becomes "DOUT". Any errors in the KRL will be shown on the virtual pendant, so make sure you have it active.


    For testing this way, it would also help if you set up a return string to the browser, as shown in the Internet Options manual.

    That was the problem. I fixed it and it worked.

    Thank You!

    Greetings,


    I want to make Python app that would communicate with Fanuc robot via TCP/IP. The goal is to select a program to run on TP.

    I believe that I need to use Karel to read data from Python app. Is it possible to get some small piece of code as an example of how to do that?

    I am totally new in Karel so it would be very helpful just to try some simple example of reading data and calling program in Karel via TCP/IP.


    Thank You!

    Greetings I need help.

    I am doing a custom Html page to control Fanuc robot I/O. I am doing this with help of Karel.

    Here are the programs. HTML program for sending data and Karel program for receiving data.

    I don't know why they won't work. Please help me. I picked KAREL 632 during configuration of my cell and Karel is unlocked in TP.

    The HTML page is saved in MC folder in My workcells.



    KAREL

    -------------------------------------------------------------

    PROGRAM prvi -- svaki program mora zapoceti s "PROGRAM" nakon cega slijedi ime programa


    %NOLOCKGROUP -- grupe moraju biti otkljucane da bi program radio


    VAR -- sve varijable koje se koriste u programu moraju se definirati

    object : STRING[12]

    operate : STRING[12]

    INDEX : STRING[12]

    value : STRING[12]


    uobject : STRING[12] -- duple varijable koje ce se koristiti za prebacijavje teksta u velika slova

    uoperate: STRING[12]

    uindex : STRING[12]

    uvalue : STRING[12]


    value_i : INTEGER -- ostale varijable

    value_r : REAL

    index_i: INTEGER

    status : INTEGER

    i : INTEGER

    return_code : INTEGER


    ROUTINE toupper(p_char: INTEGER): STRING -- prebacivanje ulaza u velika slova

    BEGIN

    IF (p_char > 96) AND (p_char < 123) THEN

    p_char = p_char - 32

    ENDIF

    RETURN (CHR(p_char))

    END toupper


    BEGIN

    IF UNINIT(object) THEN object = ''; ENDIF -- provjera neinicializiranih varijabli prije korištenja

    IF UNINIT(operate) THEN operate = ''; ENDIF

    IF UNINIT(INDEX) THEN INDEX = ''; ENDIF

    IF UNINIT(value) THEN value = ''; ENDIF


    uobject = ''

    FOR i = 1 TO STR_LEN(object) DO

    uobject = uobject + toupper(ORD(object, i))

    ENDFOR

    uoperate = ''

    FOR i = 1 TO STR_LEN(operate) DO

    uoperate = uoperate + toupper(ORD(operate, i))

    ENDFOR

    uindex = ''

    FOR i = 1 TO STR_LEN(INDEX) DO

    uindex = uindex + toupper(ORD(INDEX, i))

    ENDFOR

    uvalue = ''

    FOR i = 1 TO STR_LEN(value) DO

    uvalue = uvalue + toupper(ORD(value, i))

    ENDFOR


    IF (uobject = 'DOUT') THEN

    IF (uoperate = 'SET') THEN

    CNV_STR_INT(uindex, index_i)

    IF (uvalue = 'ON') THEN

    DOUT[index_i] = ON

    ENDIF

    IF (uvalue = 'OFF') THEN

    DOUT[index_i] = OFF

    ENDIF

    ENDIF

    ENDIF


    IF (uobject = 'NUMREG') THEN

    CNV_STR_INT(uindex, index_i)

    IF (uoperate = 'SETINT') THEN

    CNV_STR_INT(uvalue, value_i)

    SET_INT_REG(index_i, value_i, status)

    ENDIF

    IF (uoperate = 'SETREAL') THEN

    CNV_STR_REAL(uvalue, value_r)

    SET_REAL_REG(index_i, value_r, status)

    ENDIF

    ENDIF

    return_code = 204 -- povratak NO RESPONSE koda - potrebno

    END prvi -- svaki program mora završiti s "END" nakon cega slijedi ime programa

    -----------------------------------------------------------------------------------------------------------------------------




    HTML PROGRAM

    -------------------------------------------------------------------------------------------------

    <!DOCTYPE html>

    <html lang="hr-HR">

    <head>

    <meta charset=UTF-8>

    <div align="mid">

    <title>FANUC WEB WIZARD - Paletizacija</title> </div>

    </head>

    <body bgcolor="#4169E1">

    <h2>

    <font color="#FFFFFF">

    </fontcolor>Primjeri mogućeg sadržaja:

    </h2>

    <table>

    <tr>

    <h3>1. Postavljanje digitalnih izlaza:</h3>

    <td>

    <form action="C:\Users\kovad\OneDrive\Dokumenti\My Workcells\Projekt_IRM\Robot_1\MC\prvi" method="GET"> <!--link na karel program-->

    <div align="left">

    <input type="hidden" name="object" value="DOUT">

    <input type="hidden" name="operate" value="set">

    <input type="hidden" name="index" value="1"> <!--broj izlaza koji se mijenja-->

    <input type="hidden" name="value" value="ON">

    <input type="submit" value="Upali DOUT[1]">

    </div>

    </form>

    </td>

    <td>

    <form action="C:\Users\kovad\OneDrive\Dokumenti\My Workcells\Projekt_IRM\Robot_1\MC\prvi" method="GET"> <!--link na karel program-->

    <div align="left">

    <input type="hidden" name="object" value="DOUT">

    <input type="hidden" name="operate" value="set">

    <input type="hidden" name="index" value="1"> <!--broj izlaza koji se mijenja-->

    <input type="hidden" name="value" value="OFF">

    <input type="submit" value="Ugasi DOUT[1]">

    </div>

    </form>

    </td>

    </tr>

    </table>

    <table>

    <tr>