# Middle points of my linear path using servoj

**URL:** https://forum.universal-robots.com/t/middle-points-of-my-linear-path-using-servoj/9600
**Category:** URScript
**Created:** [November 4, 2020, 7:54am UTC](https://forum.universal-robots.com/t/middle-points-of-my-linear-path-using-servoj/9600 "2020-11-04T07:54:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![anon4832633](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@anon4832633](https://forum.universal-robots.com/u/anon4832633)
#### Post date: [November 4, 2020, 7:54am UTC](https://forum.universal-robots.com/t/middle-points-of-my-linear-path-using-servoj/9600/1 "2020-11-04T07:54:50Z")

</div>

I have used jerk limited velocity profile for linear path trajectory. for more understandable similar motion graph which is shown below from internet:

 ![Sample Jerk-Limited Profile](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/d/d312a8b89342fec194bcbed5901003c5d2a9a0c3.png)

With this kind of motion in a while loop I used servoj. My algorithm is shown below:  
///////////////////////////////////////////////////////////////////////  
myPoses=[pose1,pose2,pose3…poseN]  
i=1  
while i\<N  
servoj(get\_inverse\_kin(poseN),0,0,t=0.08,  
lookahead\_time=0.03,gain=1170)  
end  
/////////////////////////////////////////////////////////////////////  
With these lookahead\_time and gain coefficients, I have reached exactly the end point with adjusting gain to 1170 value but when I watch my middle points in polysope log viewer cannot reach the desired points. Maybe 1 or 2 mm lagging happened. Do I have to change gain and lookahed\_time coefficient during path? I could not fix it. I need suggestions.

---

<div class="post-metadata">

### Author: ![Ebbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ebbe/32/1413_2.png) [@Ebbe](https://forum.universal-robots.com/u/Ebbe)
#### Post date: [November 4, 2020, 9:28am UTC](https://forum.universal-robots.com/t/middle-points-of-my-linear-path-using-servoj/9600/2 "2020-11-04T09:28:59Z")

</div>

Hi @anon4832633,

As long as your input is limited on jerk and acceleration. You can reduce the lookahead time and increase the gain to follow the target more aggressively and hopefully minimizing the error. Due to _servoj_ nature it will always be lagging.  
If you are testing on the simulator and adjusting to an very aggressive setup. Be aware that the real robot might act with jerk an acceleration peaks.  
An alternative is to use _speedl_ or _speedj_.

Ebbe

---

<div class="post-metadata">

### Author: ![anon4832633](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@anon4832633](https://forum.universal-robots.com/u/anon4832633)
#### Post date: [November 4, 2020, 10:30am UTC](https://forum.universal-robots.com/t/middle-points-of-my-linear-path-using-servoj/9600/3 "2020-11-04T10:30:12Z")

</div>

Thanks @Ebbe  
I will try my last attempts with servoj according to your advice after that I will switch my trajectory speedl and speedj functions.
