Comparing two BASE DATA

  • Hello everyone,
    I have already transferred base data from one location to another with simple assignment: BASE_DATA[11] = BASE_DATA[5], I am trying to compare this data for a return later in program using the following:


    IF BASE_DATA[11] == BASE_DATA[5] THEN
    ;tell me
    ENDIF


    but this does not work. Can anyone explain how to compare these data? My experience in KUKA robot programming is limited.


    Thank you in advance!


    David

  • if (inv_pos(Base_data[11]):base_data[5]) == $NULLFRAME) then ...


    I did not check syntax, but you should get the idea: Multiplication of a Frame with its inverse frame leads to the nullframe.


    But to compare reals with == is dangerous anyway due to numerical reasons. So it would be better to check in a subroutine with predefined Epsilons for the difference to $NULLFRAME.


    Fubini

    Edited once, last by Fubini ().


  • if (inv_pos(Base_data[11]):base_data[5]) == $NULLFRAME) then ...


    Fubini


    P.S. I did not check syntax, but you should get the idea: Multiplication of a Frame with its inverse frame leads to the unity matrix.


    This is helpful. It is a great idea. Thanks! I will give it a go right away.

  • As Fubini says, do to rounding error, the differences between any two FRAME (or POS, or any REAL-type value) variables in KRL is likely to never be exactly 0 -- you're more likely to to 0.00001 or something. Insignificant for what you're trying to check, but enough to fail a simple "==" test. So you probably want something like:

    Code
    DECL FRAME _fDeltaFrame
    DECL BOOL _bSuccess
    _bSuccess = TRUE
    _fDeltaFrame = (INV_POS(BASE_DATA[1]) : BASE_DATA[2])
    _bSuccess = _bSuccess AND (ABS(_fDeltaFrame.X) < 0.001)
    _bSuccess = _bSuccess AND (ABS(_fDeltaFrame.Y) < 0.001)
    _bSuccess = _bSuccess AND (ABS(_fDeltaFrame.Z) < 0.001)
    _bSuccess = _bSuccess AND (ABS(_fDeltaFrame.A) < 0.001)
    _bSuccess = _bSuccess AND (ABS(_fDeltaFrame.B) < 0.001)
    _bSuccess = _bSuccess AND (ABS(_fDeltaFrame.C) < 0.001)


    The ABSs are important to cover the possibility that the delta value might be positive or negative. For this check, you're only interested in the scalar value, not the vector.

Advertising from our partners