The final position after the movment seems correct but the trajectory is wrong : the robot moves the TCP on X and Y before reaching the final position, it’s not a rotation around tool Z axis only.
Could you please help me figure out how to achieve the rotation around tool Z axis only?
Yes, the TCP seems correct because when I use the movment tab in polyscope, select tool base and make Rz rotation it works fine.
Any idea how to do it using URScript?
I think it’s because you are using movej which generates a linear trajectory in the joint space and not in the cartesian space.
Using movel you should be able to obtain the desired behaviour