# Weaving angular orientation (tool flange vs TCP)

**URL:** <https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569>\
**Category:** URScript\
**Created:** [March 4, 2020, 9:18pm UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569 "2020-03-04T21:18:22Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![steven.borkman](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@steven.borkman](https://forum.universal-robots.com/u/steven.borkman)\
**Post date:** [March 4, 2020, 9:18pm UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/1 "2020-03-04T21:18:22Z")

</div>

I’m developing a URCap for a welding application that uses weaving. I’m using the URScript command “path\_offset\_set” to accomplish this. Everything’s working, except the angular orientation is relative too the tool flange rather than TCP. I need weaving to be relative to the TCP. From what I can tell, an offset in the X-direction is parallel to the path of the TCP. An offset in the Z-direction is parallel to the tool flange direction (NOT the TCP direction). And an offset in the Y-direction is perpendicular to both of the previous two (the cross product).

Is this a bug? Is weaving really supposed to be relative to tool flange coordinates? Am I meant to manually apply the rotational calibration for the TCP when using the path\_offset\_set command in order to get the Z and Y weaving offset directions to be relative to the TCP?

I’m already in the process of trying to find a work-around to this - by applying the rotational calibration manually. Some feedback from UR would be nice.

---

<div class="post-metadata">

**Author:** ![sam.verity-hilton](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/sam.verity-hilton/32/6046_2.png) [@sam.verity-hilton](https://forum.universal-robots.com/u/sam.verity-hilton)\
**Post date:** [March 5, 2020, 9:03am UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/2 "2020-03-05T09:03:57Z")

</div>

Hi Steven,

When you set the offset with `path_offset_set`, which type of offset are you applying? It sounds like you’re using type 3, the motion offset, as the extract in the script manual seems match your description. You might wish to consider sing one of the other offset types in order to acheive your required functionality. See the screenshot from the script manual below:

 ![Screenshot (56)](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/0/0862d2f3f8140532326ac094693e62dbe9bb91a0.png)

If you are interested, we (Olympus Technologies) have developped a weaving URCap already which encorporates multiple configurable weaving patterns, which is being released to purchase soon. If you are interested in discussing it, feel free to drop me a PM and we can talk more.

---

<div class="post-metadata">

**Author:** ![pica](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/pica/32/1703_2.png) [@pica](https://forum.universal-robots.com/u/pica)\
**Post date:** [March 5, 2020, 9:23am UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/3 "2020-03-05T09:23:43Z")

</div>

Hi Steven,  
A few weeks ago I encountered this kind of problem, I noticed that the set\_path\_offset function doesn’t update the reference frame of the TCP if defined different from the flange one in the installation tab, as a consequence both for mode 2 and 3 if you have a different setup for the TCP than (0,0,0,0,0,0) [coincidence with flange ref frame] you will not have the expected result in the motion. As a workaraoun i wrote a script that adjust the offset considering the real TCP ref frame for set\_path\_offset mode 2.

> #Author: Alberto Novazzi [alno@universal-robots.com](mailto:alno@universal-robots.com)  
> #Author: Pietro Castelli [pica@universal-robots.com](mailto:pica@universal-robots.com) 12/02/2020  
> #Poliscope version 5.6  
> def pose2list(pose):  
> return [pose[0], pose[1], pose[2], pose[3], pose[4], pose[5]]  
> end  
> def path\_offset\_tcp( offset ):  
> # offset \<pose, list\> : Pose specifying the translational and rotational offset with respect to the current TCP frame  
> tcpOffset = get\_tcp\_offset()  
> pathOffset = pose\_trans( p[0.0, 0.0, 0.0, tcpOffset[3], tcpOffset[4], tcpOffset[5]],p[offset[0], offset[1],offset[2],offset[3],offset[4],offset[5]])  
> pathOffsetRot = pose\_trans(p[0.0, 0.0, 0.0, tcpOffset[3], tcpOffset[4], tcpOffset[5]], p[offset[3], offset[4], offset[5], 0.0, 0.0, 0.0])  
> pathOffset[3] = pathOffsetRot[0]  
> pathOffset[4] = pathOffsetRot[1]  
> pathOffset[5] = pathOffsetRot[2]  
> path\_offset\_set(pose2list(pathOffset), 2)  
> end

I created a bug report for this problem, so that in the future it will be fixed, until then feel free to use this script.  
Best Regards  
Castelli Pietro

---

<div class="post-metadata">

**Author:** ![steven.borkman](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@steven.borkman](https://forum.universal-robots.com/u/steven.borkman)\
**Post date:** [March 6, 2020, 5:59pm UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/4 "2020-03-06T17:59:33Z")

</div>

Thanks for your quick response! I will try your work-around soon.

---

<div class="post-metadata">

**Author:** ![steven.borkman](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@steven.borkman](https://forum.universal-robots.com/u/steven.borkman)\
**Post date:** [March 6, 2020, 6:04pm UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/5 "2020-03-06T18:04:24Z")

</div>

Yes, I am using type 3. Just today, I added the ability to select from types 1, 2, and 3 in my URCap. The “motion” type seems to not always behave as I want, so I will try using “TCP” instead. I will mention your URCap to management of my company. Thanks!

---

<div class="post-metadata">

**Author:** ![anon16768823](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@anon16768823](https://forum.universal-robots.com/u/anon16768823)\
**Post date:** [May 7, 2020, 7:55pm UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/6 "2020-05-07T19:55:36Z")

</div>

I am having a similar issue, the tcp we have is at an angle to the tool flange. During testing, if I align the tcp z axis to the base z axis, teach a moveL in the direction of base x only, and use path offset type 3 with a variable in the [0,X,0,0,0,0] position, it should only alter movement in the base y direction, now I rotate my tcp about the z axis. The motion should still only be altered in the x or y direction depending on the orientation, no offset should be applied in the z direction, though I am seeing that the y axis of motion using the path\_offset\_set(type 3) is not perpendicular to the z axis of the base like it should. The documentation states that:

3: (MOTION) Use a coordinate system following  
the un-offset trajectory when applying. This  
coordinate system is defined as follows. X-axis  
along the tangent of the translational part of  
the un-offset trajectory (rotation not relevant  
here). Y-axis perpendicular to the X-axis above  
and the Z-axis of the tool (X cross Z). Z-axis  
given from the X and Y axes by observing the  
right-hand rule. This is useful for instance for  
superimposing a weaving pattern onto the  
trajectory when welding.

I think that the actual calculation is being done with the flange z axis, not the tool z axis.

Does anyone know a way fix this?

---

<div class="post-metadata">

**Author:** ![pica](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/pica/32/1703_2.png) [@pica](https://forum.universal-robots.com/u/pica)\
**Post date:** [May 8, 2020, 7:12am UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/7 "2020-05-08T07:12:40Z")

</div>

Hi Taylor,  
In our office we struggled a lot with the weaving mode and after we found a fix for mod 2 a colleague of mine wrote a fix for mod 3.  
The following script will give you the correct motion frame wrt the base frame; I attached it in a .zip file below.  
[get\_motion\_frame.zip](https://forum.universal-robots.com/uploads/short-url/u3F0QU7QXAfT93ZqGMyowdI63ll.zip) (1.2 KB)

Best Regards  
Pietro C.

---

<div class="post-metadata">

**Author:** ![anon16768823](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@anon16768823](https://forum.universal-robots.com/u/anon16768823)\
**Post date:** [May 8, 2020, 1:28pm UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/8 "2020-05-08T13:28:57Z")

</div>

Well I am glad that it’s not just me that can’t figure out the weaving. Do you have an example on how to integrate your GetMotionFrame function into the path\_offset\_set command?

---

<div class="post-metadata">

**Author:** ![anon16768823](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@anon16768823](https://forum.universal-robots.com/u/anon16768823)\
**Post date:** [May 18, 2020, 1:29pm UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/9 "2020-05-18T13:29:12Z")

</div>

Could you provide a sample on how to integrate the code you wrote into the path\_offset command?

---

<div class="post-metadata">

**Author:** ![pica](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/pica/32/1703_2.png) [@pica](https://forum.universal-robots.com/u/pica)\
**Post date:** [May 20, 2020, 7:59am UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/10 "2020-05-20T07:59:33Z")

</div>

Hi Taylor,  
Depending on the pattern you want to impose implementation may vary but should go something like this:

Suppose you have a thread in which you calculate the required offset expressed in motion frame:  
Thread:  
some calculations  
d=p[x,y,z,rot1,rot2,rot3]

Then to express d wrt the base frame and not the motion frame you will do:  
d\_base\_frame = pose\_trans(motion\_frame, d)

In the end you can easily apply the path offset in mode 0, base frame, of the quantity d\_base\_frame

---

<div class="post-metadata">

**Author:** ![matthew.pearson](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@matthew.pearson](https://forum.universal-robots.com/u/matthew.pearson)\
**Post date:** [August 19, 2020, 2:38pm UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/11 "2020-08-19T14:38:14Z")

</div>

Hi

My testing suggests that polyscope 5.9.1 has fixed this issue about the mode 2 using flange z rather than tool z when a tool with a non zero orientation is defined. However, there is nothing in the release notes about this being fixed.

Has this bug been formally addressed, can I trust that this problem is fixed for this and future releases of polyscope or do I still need to apply a work around?

Thanks

---

<div class="post-metadata">

**Author:** ![inu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/inu/32/732_2.png) [@inu](https://forum.universal-robots.com/u/inu)\
**Post date:** [August 19, 2020, 11:25pm UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/12 "2020-08-19T23:25:16Z")

</div>

Hello @matthew.pearson,

I just ran a test using 5.9.1 and an offset TCP and can verify the issue is resolved with mode 3 as well. I ran the same setup on 5.7 and 5.9.1 to verify.

I checked with our internal team and the bug originally submitted regarding motion frame 2&3 not taking into account the active TCP offset has been marked as completed and flagged to have released with 5.9.

---

<div class="post-metadata">

**Author:** ![matthew.pearson](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@matthew.pearson](https://forum.universal-robots.com/u/matthew.pearson)\
**Post date:** [August 21, 2020, 8:10am UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/13 "2020-08-21T08:10:45Z")

</div>

Thank you very much. That’s great.

---

<div class="post-metadata">

**Author:** ![mbush](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mbush/32/76_2.png) [@mbush](https://forum.universal-robots.com/u/mbush)\
**Post date:** [August 21, 2020, 5:35pm UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/14 "2020-08-21T17:35:20Z")

</div>

We have tested as well and can confirm it’s resolved with mode 3 as of 5.9.1.

---

<div class="post-metadata">

**Author:** ![anon61982790](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@anon61982790](https://forum.universal-robots.com/u/anon61982790)\
**Post date:** [August 17, 2021, 7:19am UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/15 "2021-08-17T07:19:31Z")

</div>

HI @sam.verity-hilton

Is it possile to do weavig in cb series? If yes, culd you please describe me how?

---

<div class="post-metadata">

**Author:** ![sam.verity-hilton](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/sam.verity-hilton/32/6046_2.png) [@sam.verity-hilton](https://forum.universal-robots.com/u/sam.verity-hilton)\
**Post date:** [August 17, 2021, 7:32am UTC](https://forum.universal-robots.com/t/weaving-angular-orientation-tool-flange-vs-tcp/6569/16 "2021-08-17T07:32:32Z")

</div>

It is possible, though I’m afraid that you have to go about it in a more brute force manner, as the `path_offset` functions ar not available in CB3 URScript. We have created a straight line weaving URCap for CB3 if that is something of interest to you?
