Align Orientation

edited February 2019 in RAPID Programming
I am a beginner robot programmer. 
I recently started my first project, Grinding stainless steel elbow from the inside. 
I am using an IRB 2400 robot with S4C + controller. And for grinding I use something like 
a straight grinder. I have a problem with alignment of coordinate systems. As a stationary
 TCP, I set the head of the grinder with the orientation [1,0,0,0] to World, and the gripper
 as the userframe. I would like the TCP and Uframe orientation to be the same. From the 
mathematical calculations, the ideal orientation for Uframe should be [0.7071,0,-0.7071,0].
 I know that this value would be good only in RobotStudio. Mechanical inaccuracies and 
other errors occur in the real system. I set UserFrame manually. I aligned the position 
to the X axis and then using World I determined 2 points on the X axis and one on the Y 
I received the following orientation of Uframe [0.717779, -0.033785, -0.695418, -0.00675]
With this setting I started grinding. On the straight section of the elbow where I only 
move along XYZ, everything is ok. The problem arises when I try to grind the arc 
of the elbow with TCP shifted to Y. When Y0 = 0, i.e. grind the upper or lower wall 
of the elbow by turning around the Y axis, the tool is always centered in the elbow. 
When Y = 4.6 or -4.6, the gripper turns gently around the Z axis, but I have the same 
orientation as for Y0. I can send pictures and video, just write to me.

Can anyone explain to me why the gripper turns around Z?
When I jog XYZ in the coordinate system Wobj gripper moves relatively straight along 
the World coordinate system

What methods do you have for machining an oval surface accurately and aligning the tool?
Thank you to everyone who will speak in the subject and contribute to the creation 
of my first project :)
Best regard,
Dawid Firlej