krlkuka-krl

A strange error about the WAIT FOR statement in KUKA Robot Language(KRL)


When the program reaches "WAIT FOR"(server.src, line 11), the robot stops. And the "START" button must be pressed to continue running. What do I need to do to prevent the robot from stopping when the program reaches "WAIT FOR"? And I use EthernetKRL package, the source files as follow:

connect.xml:

<ETHERNETKRL>
  <CONFIGURATION>
    <EXTERNAL>
      <IP>172.31.55.5</IP>
      <PORT>60000</PORT>
      <TYPE>Client</TYPE>
    </EXTERNAL>
    <INTERNAL>
      <ENVIRONMENT>Program</ENVIRONMENT>
      <BUFFERING Mode="FIFO" Limit="10"/>
      <BUFFSIZE Limit="16384"/>
      <IP>172.31.55.6</IP>
      <PORT>54601</PORT>
      <PROTOCOL>TCP</PROTOCOL>
      <MESSAGES Logging="error" Display="disabled"/>
    </INTERNAL>
  </CONFIGURATION>
  <RECEIVE>
    <XML>
      <ELEMENT Tag="Robot/Pos/X" Type="REAL" />
      <ELEMENT Tag="Robot/Pos/Y" Type="REAL" />
      <ELEMENT Tag="Robot/Pos/Z" Type="REAL" />
      <ELEMENT Tag="Robot/Pos/A" Type="REAL" />
      <ELEMENT Tag="Robot/Pos/B" Type="REAL" />
      <ELEMENT Tag="Robot/Pos/C" Type="REAL" />
      <ELEMENT Tag="Robot/ready" Type="BOOL" />
      <ELEMENT Tag="Robot/chuck" Type="BOOL" />
      <ELEMENT Tag="Robot/readRobotStatus" Type="BOOL" Set_Out="14"/>
      <ELEMENT Tag="Robot/onlySetIO" Type="BOOL" Set_Out="15"/>
      <ELEMENT Tag="Robot" Set_Flag="14" />
    </XML>
  </RECEIVE>
  <SEND>
    <XML>
      <ELEMENT Tag="Robot/Pos/X" />
      <ELEMENT Tag="Robot/Pos/Y" />
      <ELEMENT Tag="Robot/Pos/Z" />
      <ELEMENT Tag="Robot/Pos/A" />
      <ELEMENT Tag="Robot/Pos/B" />
      <ELEMENT Tag="Robot/Pos/C" />
      <ELEMENT Tag="Robot/ready" />
      <ELEMENT Tag="Robot/chuck" />
      <ELEMENT Tag="Robot/readRobotStatus" />
      <ELEMENT Tag="Robot/onlySetIO" />
    </XML>
  </SEND>
</ETHERNETKRL>

server.src:

&ACCESS RVP
&REL 3
&PARAM DISKPATH = KRC:\R1\Program
DEF SERVER()

RET=EKI_Init("CONNECT")
RET=EKI_Open("CONNECT")

LOOP

WAIT FOR $OUT[14]==TRUE 
    
$OUT[14]=FALSE

$TOOL = tool_data[4]
$LOAD = load_data[4]
$BASE = base_data[4]

RET=EKI_GetBool("CONNECT","Robot/readRobotStatus",READROBOTSTATUS)

IF READROBOTSTATUS==TRUE THEN
RET=EKI_SetReal("CONNECT","Robot/Pos/X",$POS_ACT.X)
RET=EKI_SetReal("CONNECT","Robot/Pos/Y",$POS_ACT.Y)
RET=EKI_SetReal("CONNECT","Robot/Pos/Z",$POS_ACT.Z)
RET=EKI_SetReal("CONNECT","Robot/Pos/A",$POS_ACT.A)
RET=EKI_SetReal("CONNECT","Robot/Pos/B",$POS_ACT.B)
RET=EKI_SetReal("CONNECT","Robot/Pos/C",$POS_ACT.C)
RET=EKI_SetBool("CONNECT","Robot/chuck",$OUT[2])
RET=EKI_SetBool("CONNECT","Robot/ready",$OUT[1])
RET=EKI_Send("CONNECT","Robot")

ELSE
RET=EKI_GetBool("CONNECT","Robot/onlySetIO",ONLYSETIO)

IF ONLYSETIO==TRUE THEN
RET=EKI_GetBool("CONNECT","Robot/chuck",$OUT[2])
RET=EKI_Send("CONNECT","Robot")

ELSE
RET=EKI_GetReal("CONNECT","Robot/Pos/X",POS_FR.X)
RET=EKI_GetReal("CONNECT","Robot/Pos/Y",POS_FR.Y)
RET=EKI_GetReal("CONNECT","Robot/Pos/Z",POS_FR.Z)
RET=EKI_GetReal("CONNECT","Robot/Pos/A",POS_FR.A)
RET=EKI_GetReal("CONNECT","Robot/Pos/B",POS_FR.B)
RET=EKI_GetReal("CONNECT","Robot/Pos/C",POS_FR.C)

LIN POS_FR


RET=EKI_Send("CONNECT","Robot")
ENDIF

ENDIF

ENDLOOP

RET=EKI_Close("CONNECT")
RET=EKI_Clear("CONNECT")
END

server.dat:

&ACCESS RVP
&REL 3
&PARAM DISKPATH = KRC:\R1\Program
DEFDAT  server PUBLIC
DECL EKI_STATUS RET
DECL BOOL READROBOTSTATUS=TRUE
DECL BOOL ONLYSETIO=FALSE
;DECL REAL POS_X=100
;DECL REAL POS_Y=100
;DECL REAL POS_Z=100
;DECL REAL POS_A=100
;DECL REAL POS_B=100
;DECL REAL POS_C=100
DECL FRAME POS_FR={X 100.000,Y 100.000,Z 50.0000,A 0.0,B 50.0000,C 30.0000}
DECL BASIS_SUGG_T LAST_BASIS={POINT1[] "P0",POINT2[] "P0",CP_PARAMS[] "CPDAT0",PTP_PARAMS[] "PDAT0",CONT[] " ",CP_VEL[] "2.0",PTP_VEL[] " 100",SYNC_PARAMS[] "SYNCDAT",SPL_NAME[] "S0",A_PARAMS[] "ADAT0"}

DECL INT cnt

ENDDAT

My purpose is to use a computer as the client and I want the robot as the server. When the computer sends data to the robot, $OUT[14]=TRUE, and then the robot will return data to the computer. If anyone can help me, I would be very grateful.


Solution

  • I believe this issue has to do with the 'On Path' requirement for run mode.

    In order for the robot to actually go into automatic mode, the robot must be 'On Path'. You might have seen this before when running a program that a notification pops up in the message banner mentioning 'On Path'. 'On Path' means that the robot is on a programmed path, and not "floating in space". For instance, a program can be started while the robot is in some random jogged pose and the robot program wants the robot to move to a programmed pose before letting automatic mode take over.

    I'd recommend the first thing your programs do is move the robot home. If you do not want the robot to move to a defined position at the beginning of a program, you can trick the system with the code below:

    BAS(#INITMOV, 0) ;Initialize default motion parameters like acceleration and speed.
    PTP $AXIS_ACT ;Move the robot to its current position.
    

    $AXIS_ACT is a global E6AXIS variable that holds the robots current position, so by telling the robot at the beginning of your program to PTP there, its literally commanding the robot to move to where it already is, thus putting the robot 'On Path'. Once it runs that line, you hit Go once more, then it should be in full auto and not stop any further.

    I'd try that out and see if it works.