How to easily save freemove coordinates as variables

When you have a lot of coordinates to calibrate in can be useful to have a script that allows you to move the robot freely and automatically save the current position as a variable that can then later be used in other scripts.

Here is the script:
freedrive_mode()
popup(Move the robot to Pos x, title=‘Pos x’, blocking=True)
global pos_x=get_actual_tcp_pose()

The first line puts the robot in freedrive mode which lets you move it freely. (note: make sure you have the payload set correctly so it doesn’t move when you let go of it. It’s also better for the health of the robot :wink:) If you for instance only want to be able to move it in one direction you can change paramaters like this: freedrive_mode(freeAxes=[0,0,1,0,0,0]). Now you can only move it in the z-direction.

The second line gives you a popup on the GUI of the robot. Here it can say to what coordinate it wants you to move to make it easier for you. Because the blocking parameter of the function is set to ‘True’ you actually have to press ‘continue’ on the GUI to make the script continue.

The third line makes a global variable and assigns the current position of the robot to this variable. This variable can afterwards be used by any script in the robot program.