What is KRC2 doing when you set an array of frame equal to a single frame?

  • I am configuring a KRC4 robot and it is having errors that didn't show up on our KRC2 robot running the same programs.


    I did not set up the program on the KRC2, so I am trying to understand the intent while developing the functionality.


    The specific issue I would like to ask about is that in the KRC2 program an array of FRAME called TTool is being set equal to the system variable $Tool.

    This throws an error in the KRC4. I am assuming this is because an array of FRAME is set equal to a FRAME object. In KRC2, does this just set the first indexed item of TTool equal to the FRAME $Tool?



    DECL FRAME TTool[6]
    ; TTool is declared in system.dat

    ; TTool values are set by a loaded program


    ; In the ToolChange program

    TTool = $Tool

    ; this works in KRC2 (somehow) and has an error in KRC4



    ; KRC4 assumed solution

    TTool[toolIndex] = $Tool

    ; This would work in KRC4, but I want to know if KRC2 would assume the toolIndex to be 0.

  • you cannot assign variable of some type to an array of that type.

    i think you need to check KRC2 code a bit closer. there has to be another variable (not an array) with same name as array. if variables do not have same scope, KSS does not complain but WorkVisual may complain about one variable shadowing another.


    and no.. there is no index zero... in KSS arrays start with index 1.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Thank you Mr. Mode!

    I will check again to see if there is another variable with the same name in a local scope.

    I thought the controller would complain about double declaration since it is already declared in the config.dat.

  • I searched all files in multiple backups of the KRC2 controller and found that TTool is declared in two places: config.dat and sps.sub.

    Both declare TTool as an array of Frame. This doesn't seem to help understand how this is working on the KRC2 controller.

    I am also not sure how to know which TTool is being used by the toolChange program.

  • Those old robots 'create' a new variable of type pos when using a not declared variable.

    So if you use a not declared single variable TTool it will be created at runtime and you get no error.

    There will be an error if you want to assign a single real or boolean value to a not declared variable, because the robot always creates a pos. And one can assign a frame ($tool) to a pos without error. This works only if the declaration of the concurrent array variable is not in the dat file of the program using the undeclared variable.

    On newer robots there is no automatic creation of variables of the type pos, so you get an error, every variable has to be declared in the scope of use.

  • Hermann, that sounds like what is happening.

    I just declared some of my own variables with useful names and got everything working on KRC2 and KRC4.


    Thank you for explaining this issue (feature / bug ??). I will look out for this in the future ( especially within this old KRC2 ).

  • Those old robots 'create' a new variable of type pos when using a not declared variable.

    Really? What versions of KSS did that? I don't recall ever running into it, and I started with KSS 2.x on KRC1s. Whenever I failed to DECL a variable, the controller would invariably fail at compile time.

  • Yes, that's for shure.

    Can't remember a version of KRC2 that hadn't that "feature". For KRC1 I'm not shure, it's a long time ago, can't remember, I'm getting old :winking_face:. It ended with KRC4.

    Had that problem several times when calculating positions from folds and forgot this silly 'X' in front of the position names.

  • Really? What versions of KSS did that? I don't recall ever running into it, and I started with KSS 2.x on KRC1s. Whenever I failed to DECL a variable, the controller would invariably fail at compile time.

    I can test on the KRC2 to make sure it lets me use variables that are not declared. That bot is in production right now, but I can run a test when it is down and let you know the KSS that it is using.

Advertising from our partners