If statements via the teach pendant

How would i go about creating an if statement for the cobot when it reaches a desired position? It seems as though I can use position of the tool in the expression box but I am unsure how to format the exact position that I am checking for.

Depends. If you want to check that the robot has arrived at a taught waypoint, you can actually just add an Until to the actual waypoint and then add an action:


This will move towards waypoint 1 and then when it’s at waypoint 1, anything I put in the “EMPTY” section would run

Alternatively, you can use the built-in if() statement to check that the actual_tcp_pose is close to some other point. This is a little trickier, as you’ll never be exactly equal. This can be very effective for creating a sort of imaginary zone in space and triggering an input any time the tcp goes within that space however. This would look something like this:

Use the assignment node to create a variable containing the TCP, then break out the individual x,y, and z components and check that they are within the bounds of whatever other points you want. An easy way to come up with the bounds “someLowX” etc would be to just teach a point there, then read what the values are and hardcode them in. Running these lines in a thread would provide constant checking of the TCP inside/outside of the zone. Also, I left out the Z coordinate just so it would fit in one line for the screenshot. You’d need to include Z to make a full cube zone

Thanks eric this is very helpful! So is the syntax for the z coordinate of the tcp, myTCP[2]. Or are those just examples of variables I would have to create

Correct, tcp[2] is the Z coordinate. In general, a Pose variable is an array of 6 numbers: p[X, y, z, rx, ry, rz] and you can pick out each component by indexing out of said array