# Modifying robot trajectory by overlaying custom motion

**URL:** <https://forum.universal-robots.com/t/modifying-robot-trajectory-by-overlaying-custom-motion/34385>\
**Category:** Technical Questions\
**Created:** [May 23, 2024, 9:01am UTC](https://forum.universal-robots.com/t/modifying-robot-trajectory-by-overlaying-custom-motion/34385 "2024-05-23T09:01:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rares.voinea](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@rares.voinea](https://forum.universal-robots.com/u/rares.voinea)\
**Post date:** [May 23, 2024, 9:01am UTC](https://forum.universal-robots.com/t/modifying-robot-trajectory-by-overlaying-custom-motion/34385/1 "2024-05-23T09:01:59Z")

</div>

**Hello everyone!**

I am trying to program the UR5e to follow a welding path. I found out this article ([Modify robot trajectory with custom motion](https://www.universal-robots.com/articles/ur/programming/modify-robot-trajectory-by-overlaying-custom-motion/)) about custom motion between waypoints and I tried it.

**offset[1] = sin((i / cycle\_duration) \* 2.0 \* 3.14159) \* amplitude**

For this value, I divided it by 1000 since the result was in meters and it went over the default max offset value of 0.1m. Now the offset was 6mm which was good for the intended use.

Anyways, I am now getting an error: Path offset, Maximum acceleration limit exceeded. How can I make it work?

**This is the thread code for calculating the offset positions:**

thread Thread\_1():  
while (True):  
$ 6 “setup”  
$ 7 “ctrl\_frequency≔500.0”  
global ctrl\_frequency=500.0  
$ 8 “weave\_frequency≔3.0”  
global weave\_frequency=3.0  
$ 9 “amplitude≔0.006”  
global amplitude=0.006  
$ 10 “cycle\_duration≔ctrl\_frequency / weave\_frequency”  
global cycle\_duration=ctrl\_frequency / weave\_frequency  
$ 11 “pi≔3.14159”  
global pi=3.14159  
$ 12 “enable”  
$ 13 “offset≔[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]”  
global offset=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]  
$ 14 “i≔0”  
global i=0  
$ 15 “path\_offset\_enable()”  
path\_offset\_enable()  
$ 16 “alpha≔0.27”  
global alpha=0.27  
$ 17 “path\_offset\_set\_alpha\_filter(alpha)”  
path\_offset\_set\_alpha\_filter(alpha)  
$ 18 “weave”  
$ 19 “Loop”  
while (True):  
$ 20 “offset[1]=sin((i / cycle\_duration) \* 2.0 \* pi) \* amplitude”  
offset[1]=sin((i / cycle\_duration) \* 2.0 \* pi) \* amplitude  
$ 21 “path\_offset\_set(offset, 2)”  
path\_offset\_set(offset, 2)  
$ 22 “i≔i+1”  
global i=i+1  
$ 23 “sync()”  
sync()  
end  
end  
end
