# Implementing Weave Function Causes Deviation in Taught Waypoints

**URL:** <https://forum.universal-robots.com/t/implementing-weave-function-causes-deviation-in-taught-waypoints/31969>\
**Category:** URCap Development\
**Created:** [December 29, 2023, 2:22pm UTC](https://forum.universal-robots.com/t/implementing-weave-function-causes-deviation-in-taught-waypoints/31969 "2023-12-29T14:22:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maximilian.tanjr](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@maximilian.tanjr](https://forum.universal-robots.com/u/maximilian.tanjr)\
**Post date:** [December 29, 2023, 2:22pm UTC](https://forum.universal-robots.com/t/implementing-weave-function-causes-deviation-in-taught-waypoints/31969/1 "2023-12-29T14:22:13Z")

</div>

Hi!

I have a URCap that attempts to implement a sine weave function. This function runs as a thread. I followed the guide here:  
[https://www.universal-robots.com/articles/ur/programming/modify-robot-trajectory-by-overlaying-custom-motion/](https://www.universal-robots.com/articles/ur/programming/modify-robot-trajectory-by-overlaying-custom-motion/)

The weave pattern only activates when a condition is satisfied (egs if START\_WEAVE = True, and is implemented within the weave function). In the main program:

![example_main](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/9/9a7a8232f09e94fa4f7dc7e861eb48f2f57ad2d3.jpeg)

The weave pattern only activates when the robot tries to move towards DEST\_WP.

However, what I noticed is whenever the program cycles back to START\_WP, the TCP coordinates of START\_WP is offset by a little bit (in the range of 5-15mm, along x and y), and the offset is not consistent each cycle. The START\_WP coordinates continue to deviate further and further away from its original position with each cycle.

The lines of code I have used for implementing the weave function:

 ![example_weave](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/0/0bdb40ac2437e37d0f2c885098572dbfdd7bceac.jpeg)

Hope to seek some advice on this!

---

<div class="post-metadata">

**Author:** ![anon32693620](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@anon32693620](https://forum.universal-robots.com/u/anon32693620)\
**Post date:** [January 2, 2024, 12:09pm UTC](https://forum.universal-robots.com/t/implementing-weave-function-causes-deviation-in-taught-waypoints/31969/2 "2024-01-02T12:09:07Z")

</div>

You may want to look at disabling the path offsetting when you are ending the weave. There should be a path\_offset\_disable command you can use in the URScript. Otherwise it will hold the last offset you had when you told it to stop since it was never disabled and continue adding onto it each cycle.

---

<div class="post-metadata">

**Author:** ![maximilian.tanjr](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@maximilian.tanjr](https://forum.universal-robots.com/u/maximilian.tanjr)\
**Post date:** [January 6, 2024, 8:34am UTC](https://forum.universal-robots.com/t/implementing-weave-function-causes-deviation-in-taught-waypoints/31969/3 "2024-01-06T08:34:08Z")

</div>

Thanks for the reply!

I have modified my program to check if the boolean register is false (this indicates that the weave motion should stop) to trigger the path\_offset\_disable(). However, I get an error on the UR stating “Another thread is already controlling the robot”. Tried inserting path\_offset\_disable() into the end of my program node tree however the deviation issue still persists. Is there any other way of resolving this?

 ![example_weave](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/3/3bd7803b9c968b3e2715e34e6a35af1a292bda9b.jpeg)

---

<div class="post-metadata">

**Author:** ![anon32693620](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@anon32693620](https://forum.universal-robots.com/u/anon32693620)\
**Post date:** [January 8, 2024, 12:33pm UTC](https://forum.universal-robots.com/t/implementing-weave-function-causes-deviation-in-taught-waypoints/31969/4 "2024-01-08T12:33:31Z")

</div>

I would place the disable call in the main program as it is taking it as a robot motion call. So after the START\_WEAVE = false; call the disable as your main program, in this case, is in control of the movements. Also, if you are going to have the Thread loop and just watching for the variable, I would put another sync() for the thread while loop as well or else you will run into another error.
