Hello. This is my first time asking a question here, so I might be clumsy, and it might be a topic that has already been discussed elsewhere.
I want to collect the coordinates of a ROBOT's X, Y, Z, E1, E2 (rotary table).
To collect data in real-time, I have created a getpositions.sub file, and inside this file, I use the $ACT_POS function. This file continues to operate while the main file is running.
However, the $ACT_POS function requires that the TOOL and BASE are set; otherwise, it will not execute without errors. I have added a conditional statement to check the TOOL and BASE. But if the main file is reset, the TOOL and BASE are reset as well, leading to errors with the $ACT_POS function.
This is likely an error that occurs because the kuka robot pre-reads multiple lines of code, and it reads them quickly.
So, I added a conditional statement to check the status of the $POS_ACT function, but the result was the same.
As a solution, I placed wait sec 0.05 between the conditional statements to prevent the code from being pre-read. However, this delay affects my data collection. (I want to collect data at more than 100Hz.)
My final code is as follows (getpositions.sub).
IF VARSTATE("$ACT_POS") == #INITIALIZED TEHN
WAIT SEC 0.05
IF NOT($ACT_TOOL_C < 0) AND NOT($ACT_BASE_C < 0) THEN
BASE = $ACT_BASE_C
X_POS = ABS($ACT_POS.X)
Y_POS = ABS($ACT_POS.Y)
Z_POS = ABS($ACT_POS.Z)
E1_POS = ABS($ACT_POS.E1)
E2_POS = $ACT_POS.E2
IF $POS_ACT.X < THEN
X_SIGN = FALSE
ELSE
X_SIGN = TURE
ENDIF
IF $POS_ACT.Y < THEN
Y_SIGN = FALSE
ELSE
Y_SIGN = TRUE
ENDIF
...
ENDIF
ENDIF
Display More
Is there a solution to this problem? Or is there a way to detect the signal that resets the main file? Or could it be that the settings of my robot are unusual?
Thank you for your response.