Hi all,
I'm experiencing a bug on my system that seemingly defies reason.
A KAREL program gets the current robot position using CURPOS, sets the current coordinates into a series of real variables. Then CNV_REAL_STR converts these variables into strings, groups then together to transfer over socket coms to a PC.
The problem is that under seemingly random conditions, the string variable storing the current z position (CUR_Z_STR in the code attached) returns an empty value.
When this happens, the program will continue this behaviour, printing this variable blank. The program can be aborted, the system power cycled, the robot moved, nothing fixes this blank variable. The only thing that fixes it is to delete the Karel program where this runs (check_align_speed.kl in attached code) and reuploading the exact same code. I don’t know what this changes.
The other perplexing part of this error is that the exact same real to string conversion is happening in x,y,z,w,p,r & ext1 but only z ever seems to fail. As part of troubleshooting for this I have printed the real variable from CURPOS which shows a non-blank seemingly innocuous number (e.g. 1.09168E+03).
Does anyone know what could cause an error like this? How to prevent it from happening or a way for the system to recover itself?
CUR_POS : XYZWPREXT
CUR_X_STR : STRING[9]
CUR_Y_STR : STRING[9]
CUR_Z_STR : STRING[9]
CUR_W_STR : STRING[9]
CUR_P_STR : STRING[9]
CUR_R_STR : STRING[9]
SEND_POSE('robot2,')
WRITE('sending current TCP position', CR, CUR_X_STR, CUR_Y_STR, CUR_Z_STR, CR, CUR_W_STR, CUR_P_STR, CUR_R_STR, CR, CUR_EXT1_STR, CR)
--================================================================--
ROUTINE SEND_POSE (NICKNAME: STRING)
--================================================================--
BEGIN
-- Get current robot pose
$GROUP[1].$UTOOL = $MNUTOOL[1,$MNUTOOLNUM[1]]
$GROUP[1].$UFRAME = $MNUFRAME[1,$MNUFRAMENUM[1]]
CUR_POS = CURPOS(0,0)
-- CONVERT REAL TO STRING
-- 9 CHARACHTERS WITH 3 AFTER DECI POINT
CNV_REAL_STR(CUR_POS.X, 9, 3, CUR_X_STR)
CNV_REAL_STR(CUR_POS.Y, 9, 3, CUR_Y_STR)
CNV_REAL_STR(CUR_POS.Z, 9, 3, CUR_Z_STR)
CNV_REAL_STR(CUR_POS.W, 9, 3, CUR_W_STR)
CNV_REAL_STR(CUR_POS.P, 9, 3, CUR_P_STR)
CNV_REAL_STR(CUR_POS.R, 9, 3, CUR_R_STR)
CNV_REAL_STR(CUR_POS.EXT1, 9, 3, CUR_EXT1_STR)
CUR_POS_STR = 'current robot pose:'+CUR_X_STR+';'+CUR_Y_STR+';'+CUR_Z_STR+';'+CUR_W_STR+';'+CUR_P_STR+';'+CUR_R_STR+';'+CUR_EXT1_STR
ASK_FOR_DATA(NICKNAME, CUR_POS_STR)
END SEND_POSE
Display More