Considering the scenario represented in the following image, and the function open_gripper(), close_gripper() and Offs(), present the necessary instructions for the robot to perform the path 1 - 2 - 3, represented by the red line, to transport the block on the table. Consider that the only known point is the point P1. The length of each route is shown in the image. The directions of the robot's movements must be in accordance with the direction of the arrows.
There is a discrepancy in notation. P1 is the current point at the TCP on the image but 1 denoted the position of the box. By this logic you would need a P4 corresponding to the point on the table marked as 3.
P1 does not seem to be defined in the code and P2, defined relative to P1 should have -700 as z coordinate and P3 should have -200 as x coordinated, relative to P1. I assume the axes of P1 are not rotated relative to the global CS.
You seem to be closing the gripper before arriving to P2. If P2 is a pickup point you should close the gripper after moving to P2.