Problem with SET_POS_REG using Karel.

  • Gents, I have a problem with using SET_POS_REG instruction in Karel.

    I want to set the value to PR fot example the following data:


    posn.X = 0

    posn.Y = 0

    posn.Z = value

    posn.W = 0

    posn.P = 0

    posn.R = 0

    SET_POS_REG(reg, posn, status)


    The instruction itself make a good job, but when I want to use this position as offset to points in a program, I got a problem with config field in the PR.

    Before running my Karel prog, the PR config field was NUT 000, after using SET_POS_REG from Karel prog, I got "FUT 127-1-1".

    My "value" is around -200.

    The effect is, when using is as the offset data, I got the alarm INTP-311 Uninitialized data, which stops my robot.


    Do you have any ideas how to solve that issue?

  • XYZWPR data structure also stores a CONFIG data type.

    So inside of an XYZWPR variable there are 6 real values: X,Y,Z,W,P,R and a CONFIG value. Are you setting the CONFIG part of your XYZWPR variable posn?

  • From the manual, CONFIG types are a structure that contain:

    CFG_TURN_NO1

    CFG_TURN_NO2

    CFG_TURN_NO3

    CFG_FLIP

    CFG_UP

    CFG_FRONT


    The TURNs are integers, and the rest are booleans.


    So, it looks like accessing the config elements would be

    Code
    PositionVariable.config_data.CFG_TURN_01 = 0
    PositionVariable.config_data.CFG_FRONT = TRUE

    and so on.

  • You need to write CONFIG string to your posn variable:

    Code
    posn.X = 0
    posn.Y = 0
    posn.Z = value
    posn.W = 0
    posn.P = 0
    posn.R = 0
    CNV_STR_CONF('nut000', posn.config_data, STATUS)

Advertising from our partners