# Add a external button to real time adjust robot trajectory during moving. How do I do

**URL:** <https://forum.universal-robots.com/t/add-a-external-button-to-real-time-adjust-robot-trajectory-during-moving-how-do-i-do/20202>\
**Category:** General Application Help: How do I?\
**Created:** [March 28, 2022, 9:57pm UTC](https://forum.universal-robots.com/t/add-a-external-button-to-real-time-adjust-robot-trajectory-during-moving-how-do-i-do/20202 "2022-03-28T21:57:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zongyao.chen](https://avatars.discourse-cdn.com/v4/letter/z/e9c0ed/32.png) [@zongyao.chen](https://forum.universal-robots.com/u/zongyao.chen)\
**Post date:** [March 28, 2022, 9:57pm UTC](https://forum.universal-robots.com/t/add-a-external-button-to-real-time-adjust-robot-trajectory-during-moving-how-do-i-do/20202/1 "2022-03-28T21:57:37Z")

</div>

Hi everyone,

I would like to real time adjusting the end position during a programmed motion.  
As a example, while robot arm is moving from waypoint A to B, I could add 5mm on Y+ direction for waypoint B, which result in a changing of trajectory.  
It seems like it is impossible to to adjust it with teach pendent while it is moving.  
Can I apply some external button at digital input to real control it? Any better ways to implement it?

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![cg1](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@cg1](https://forum.universal-robots.com/u/cg1)\
**Post date:** [March 29, 2022, 10:16am UTC](https://forum.universal-robots.com/t/add-a-external-button-to-real-time-adjust-robot-trajectory-during-moving-how-do-i-do/20202/2 "2022-03-29T10:16:08Z")

</div>

Hi [zongyao.chen](https://forum.universal-robots.com/u/zongyao.chen)

try to look into path\_offset script function which allow you to live offset a path.  
There is a advanced aplication of it in this arcticle, but your situation should be bit simpler.  
[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/)

and then you can simply use a analog input as your input to the path offset function.

---

<div class="post-metadata">

**Author:** ![anon58126263](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@anon58126263](https://forum.universal-robots.com/u/anon58126263)\
**Post date:** [March 31, 2022, 7:26am UTC](https://forum.universal-robots.com/t/add-a-external-button-to-real-time-adjust-robot-trajectory-during-moving-how-do-i-do/20202/3 "2022-03-31T07:26:42Z")

</div>

Has your endpoint (B) a fixed (5mm) or variable offset? I understand it’s fixed and activated with a digital input.  
If so you could just teach the two variable points (A and B) and program a simple IF function with permanent expression evaluation:

If Dinput=0 then move to A else move to B  
or  
If Dinput=1 then move to B else move to A (which gives the same ^^)

But don’t forget to check the box “check expression continuously” (or something like this, I have the French interface so I don’t know the exact terms in English).
