Compare 2 positions

Hello UR-Plus community,

i am currently struggling with a safety mod i am trying to insert in a robot program. Before the program starts, it should do a Loop where it checks if the robot is at a specific position.

The loop is very simple as i am just trying to compare 2 variables, e.g.

(simplified)

Loop
If get_actual_tcp_pos() =/= specified Pos
-> Message: Move robot manually
Else … go on with program

But it is impossible to compare these variables because they will never be same (speaking of the never meeting decimal spaces).

IS there an option to round the position or pose (like 0.23675 = 0.2) so that the robot doesnt have to be in the exact position, but just near the value? (floor() didnt work out really…)

Greetings, Robin

Hello @robin.schurr,

There isn’t anything I can think of, you could try multiplying by 10 or 100 then using floor. It would require a bit more logic on your end but you wouldn’t lose the digits by just using floor.

I have ran into this in the past and did just that, multiplied, floor(), then divided to continue using the value for other logic in my program. It may not be the best solution but right now it’s all that comes to mind.

1 Like

Hello @robin.schurr
I’ve had a similar problem in the past. What if instead you check if the robot is within a small distance from “specified Pos” using pose_dist(get_actual_tcp_pos(),specified Pos)? Does that work for your application?

3 Likes

Hi @prichlin,

i think this could do the trick, damn why didnt i get this by myself, haha…

Thank you, will try it tomorrow.

Greetings

PS: @inu didnt see your answer at first, could you kindly explain how to use floor in this case?

1 Like

works like a charm! thank you

1 Like

You can also simply look at the joint angles. If the robot needs to be in a specific starting pose, such as

J1: 180 deg
J2: -90 deg
J3: -90 deg
J4: 0 deg
J5: 90 deg
J6: 0 deg

p = get_actual_joint_positions()
if (
(p[0] < d2r(182) and p[0] > d2r(178)) and
(p[1] < d2r(-88) and p[1] > d2r(-92)) and
(p[2] < d2r(-88) and p[2] > d2r(-92)) and
(p[3] < d2r(2) and p[3] > d2r(-2)) and
(p[4] < d2r(92) and p[4] > d2r(88)) and
(p[5] < d2r(2) and p[5] > d2r(-2))
):
popup(“Robot is in correct position:.”)
else:
popup(“Robot is NOT in correct position.”)

end

Do keep in mind that a safety feature in the task program is NOT considered safety rated per ISO 10218-1: 2011, section 5.4.2 which basically states:

Safety-related parts of control systems shall be designed so they comply with PL=d with structure category 3. That means you need dual redundancy with monitoring.

Of course, you can still include it, but it would be considered an extra.