Universal Robots Forum

Usage of servoj

I’m trying to replay a sampled trajectory and in order to do it smoothly I need to use servoj (according to what I’ve read on the forum).
I want to replay my trajectory as recorded, meaning with the same speed. But the speed is correlated to the gain with servoj.
I don’t really understand how this variable work on the movement.
If you have anything to help me, and if you have a formula showing how the speed is calculated with servoj. It would be perfect.
Thank you.

1 Like

Hello @be1,

A colleague posted some documentation that goes over some robotic functionality for UR. You can check it out here.

There is a section on servoj in the document referenced:

“In UR robots, it is basically not allowed to change any parameter in the low level. However, there is
a URScript function servoj that can be used for online control of the robot joint position. For
each joint, it calculates the error between the desired position and the actual position and adjusts
the position accordingly. As input arguments, users can set the lookahead time and the gain to
smoothen or sharpen the trajectory. The magnitude of the error is modified with the parameter gain, which can range from 100 to 2000. Its effect is similar to the P gain of a PID controller. The
higher this value is, the faster reaction the robot will have. However, it is more likely to produce
oscillations and shakiness. The default value is 300. The parameter lookahead_time plays a role in
the error calculation by predicting the future position of the joint some time in advance. It can
range from 0.03 to 0.2 seconds. The higher this value is, the slower the reaction will be. Nevertheless,
the movement will become smoother and with fewer sharp movements. The default value is 0.1.”

You can read more on the post I linked above. Hope this helps.


This does help me a lot. I now understand better how to use servoj, and it even help me with other problems I had.
Thank you for your response.