I have used jerk limited velocity profile for linear path trajectory. for more understandable similar motion graph which is shown below from internet:
With this kind of motion in a while loop I used servoj. My algorithm is shown below:
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.
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.
I will try my last attempts with servoj according to your advice after that I will switch my trajectory speedl and speedj functions.