import urx

# Create robot instance
rob = urx.Robot("192.168.1.3")

# Use try-finally to ensure robot is closed on exit
try:
    # Get current robot joint angles in radians
    init_joint_angles = rob.getj()
    print("Initial joint position is ", init_joint_angles)

    # Move robot to new position
    new_joint_angles = [1.57,-1.57, 0, -1.57, 0, 0]
    a=0.1
    v=0.1
    print("Moving to ", new_joint_angles)
    rob.movej( new_joint_angles, a, v )
finally:
    # Close robot connection
    print("Closing robot connection")
    rob.close()