Syntax for pulling a position out of the system variables in TP
- Nation
- Thread is marked as Resolved.
-
-
The reason this isn't working is because you're trying to do it as a mixed logic statement. ...=(...) instead of just ...=...
However, you can't dump a parameter into a PR element directly, so you need to put it into a register first and then put that register into the PR element, like so:
R[98]=$LNSCH[1].$TRK_FRAME.X ;
PR[98,1]=R[98] ; -
Pulling from a system parameter isn't even an option if I don't use mixed logic.
If I point the PR at a number, or a bool, it works fine.
example:
However, I can't figure out how to access a sub component of a position. It always says invalid parameter name.
Stuff I have tried so far (all invalid parameter names.):
-
When I'm having problems finding the correct formatting for a system parameter I use the variable browser in Roboguide. If you browse to the desired variable there it displays the correct formatting in the same window.
-
When I'm having problems finding the correct formatting for a system parameter I use the variable browser in Roboguide. If you browse to the desired variable there it displays the correct formatting in the same window.That's what I normally do as well, but when you go to the system variable I am looking at, it just changes to a "view position" button. Similar to how a PR is displayed.
-
Well I was unable to determine the syntax.
I ended up doing in Karel, as much as I didn't want to.
Here's the code (stripped down a bit):
Code
Display MorePROGRAM LNTRKTOPR %COMMENT = 'Line Trk to PR' %NOLOCKGROUP %NOPAUSE = ERROR + COMMAND + TPENABLE VAR data_type, dest_PR , int_value, LNTRKSCH , STATUS : INTEGER LNTRKFRAME :XYZWPR real_value: REAL -- Used only for the GET_TPE_PRM command str_value : STRING[32] -- Used only for the GET_TPE_PRM command BEGIN GET_TPE_PRM(1, data_type, int_value, real_value, str_value, STATUS) LNTRKSCH=int_value GET_TPE_PRM(2, data_type, int_value, real_value, str_value, STATUS) dest_PR=int_value --Get the frame from the commanded line schedule. LNTRKFRAME=$LNSCH[LNTRKSCH].$TRK_FRAME --Set the commanded PR. SET_POS_REG(dest_PR, LNTRKFRAME, STATUS) END LNTRKTOPR
-
Hi
I'm sorry to reanimate this thread, but it comes close to my problem: dealing with $LNSCH in KAREL
Code
Display MorePROGRAM trsptrkfrm -------------------------------------------------------------------------------- -- -- Transpose Tracking Frame -- -------------------------------------------------------------------------------- %COMMENT = 'Transpose Tracking Frame' %NOLOCKGROUP %NOBUSYLAMP %NOPAUSE = ERROR + COMMAND + TPENABLE %NOABORT = ERROR + COMMAND + TPENABLE -------------------------------------------------------------------------------- -- -- local types & constants -- -------------------------------------------------------------------------------- VAR iSleepTime : INTEGER -- delay in ms bShutdwnReq : BOOLEAN -- program abort requested status fLntTrkFrame : XYZWPREXT -- line tracking frame rRegVal : REAL -- GET_REG output iRegVal, -- GET_REG output iRegStatus : INTEGER -- GET_REG output rRegFlg : BOOLEAN -- GET_REG output entry: integer status: integer CONST LOOP_HZ = 5 -- Main loop freq (Hz) SHUTDWNREG = 461 -- Shutdown register REGSUCCESS = 0 -- Success Status LNTRKSCH = 1 -- Line Tracking Schedule Number -------------------------------------------------------------------------------- -- -- Main program -- -------------------------------------------------------------------------------- BEGIN WRITE('START - Transpose Tracking Frame',CR) bShutdwnReq = FALSE iSleepTime = ROUND(1000.0 / LOOP_HZ) WHILE (NOT bShutdwnReq) DO fLntTrkFrame = $LNSCH[1].$TRK_FRAME --GET_VAR(entry, '*SYSTEM*', '$LNSCH[1].$TRK_FRAME', fLntTrkFrame, status) --IF (status <> REGSUCCESS) THEN --WRITE('GET_VAR Failed',cr,' Status = ',status,cr) --ENDIF --fLntTrkFrame.z = fLntTrkFrame.z + 10 --SET_VAR(entry, '*SYSTEM*', '$LNSCH[1].$TRK_FRAME', fLntTrkFrame, status) --IF (status <> REGSUCCESS) THEN -- WRITE('SET_VAR Failed',cr,' Status = ',status,cr) --ENDIF --$LNSCH[1].$TRK_FRAME = fLntTrkFrame DELAY iSleepTime GET_REG(SHUTDWNREG, rRegFlg, iRegVal, rRegVal, iRegStatus) IF (iRegStatus = REGSUCCESS) THEN IF (iRegVal <> 0) THEN bShutdwnReq = TRUE WRITE('STOPPING - Transpose Tracking Frame',CR) ENDIF ELSE WRITE('GET_REG Failed',cr,' Status = ',iRegStatus,cr) ENDIF ENDWHILE -- Reset Outputs etc SET_INT_REG(SHUTDWNREG, 0, iRegStatus) IF (iRegStatus <> REGSUCCESS) THEN WRITE('SET_INT_REG Failed',cr,' Status = ',iRegStatus,cr) ENDIF WRITE('STOPED - Transpose Tracking Frame',CR) END trsptrkfrm
I'm triing to compile the code with following error message:
Code
Display MoreC:\Program Files (x86)\FANUC\WinOLPC\bin>ktrans trsptrkfrm.ls /ver V8.20-1 Notice: Unable to find 'robot.ini', Using basic KAREL support files. KTRANS Version V8.20 (Build 11 6/19/2014) Copyright (C) FANUC Robotics America Corporation, 1985 through 2012. All Rights Reserved. C:\Program Files (x86)\FANUC\WinOLPC\bin\trsptrkfrm.ls(49) 49 fLntTrkFrame = $LNSCH[1].$TRK_FRAME ^ ERROR Id must be defined before this use. Id: $LNSCH ===============Translation not successful=============== Error executing KTrans: Error translating program: Code: 0xFFFFFFFF: C:\Program Files (x86)\FANUC\WinOLPC\bin>
No matter what variable of $LNSCH i want to adress ($LNSCH[1].$SCALE), i allways get the same error: "Id must be defined before this use. Id: $LNSCH"
So may someone enlighten me... please
-
Could it be that the file extension you are trying to compile ends with .ls instead of .kl?
Create an account or sign in to comment
You need to be a member in order to leave a comment