RobotStudio event

123

Options

I have two question:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

1. In the RobotStudio API Help it is written that "position.x", "position.y" or "position.z" properties are of type "Long". However, I think they must be defined as type "Double". Am I right?

 

2. In my API code I'd like to shift the target points to other locations in the space. To be able to restore the original coordinates location, I save x, y, and z coordinates of targets in arrays of type "Double" first. However, after shifting and then restoring the original coordinate some inaccuracy are formed in x, y, or z of position properties. e.g. position.x=1699.999 instead of 1700.000. Although this inaccuracy is small, it is enough to influence my result and sometimes leads to wrong result especially if this error accumulates. The same problem can occur in "orientation.Rx, Ry, Rz" even if I do not change these properties in the code. This means sometimes Rx,Ry, or Rz change after changing the position.x, y, or z properties after doing many shifting. (If my question is not clear, please run the attached code and notice to the coordinates of targets before and after shifting)

Is this error because of "position.x", "position.y" or "position.z" properties are defined of type "single" and not "double"? How we can eliminate this inaccuracy?

Thanks in advance,

BR, /Behnam

 

   showRoundError.zip

Administrator37896,5281018519
/Behnam

Comments

  • John Wiberg
    Options

    1. image You are correct, they are double. The API online manual will be changed to the next version. When in doubt about types, you can use the VBE, View>Object Browser (F2), then type in the object you are interested in and it will give you the type directly from the code. If you find any other inconsistencies in the manual please report them to the forum as well. image

    2. Will come back to you on this one.

  • Thanks for your commentS. I'm curiusly waiting for an answer.

    /Behnam

    /Behnam
  • The problem occurs when you read information from the graphics (which calculates with Float). A way to eliminate the problem is to use the "Round" function every time you read positions and transforms from the graphics.

    E.g:

    oriTargets_x(jCount, iCount) = Round(trfTargetRef.Target.Transform.Position.x, 3)
    oriTargets_y(jCount, iCount) = Round(trfTargetRef.Target.Transform.Position.y, 3)
    oriTargets_z(jCount, iCount) = Round(trfTargetRef.Target.Transform.Position.z, 3)

    Best Regards

    Fredrik

    Fredrik Syr?n
    Program Manager
    ABB Automation Technologies