ServoJ command
Servoj can be used for online realtime control of joint positions.
Created: July 20th, 2021.
Command structure:
servoj(q, a, v, t=0.002, lookahead_time=0.1, gain=300)
This command and many others can be found on the Script Manual in Download section HERE
Servoj can be used for online realtime control of joint positions. The gain parameter works the same way as the P-term of a PID controller, where it adjusts the current position towards the desired (q). The higher the gain, the faster reaction the robot will have. The parameter lookahead_time is used to project the current position forward in time with the current velocity. A low value gives fast reaction, a high value prevents overshoot.
Note: A high gain or a short lookahead time may cause instability and vibrations. Especially if the target positions are noisy or updated at a low frequency It is preferred to call this function with a new setpoint (q) in each time step
(Thus the default:
t=0.008 for CB3
t=0.002 for e-series)
You can combine with the script command get_inverse_kin() to perform servoing based on cartesian positions:
- q = get_inverse_kin(x)
- servoj(q, lookahead_time=0.05, gain=500)
In the example "x" is a pose variable with target cartesian positions, received over a socket or RTDE registers.
Example command:
- servoj([0.0,1.57,-1.57,0,0,3.14], 0, 0, 0.008, 0.1, 300)
Example Parameters:
- q = [0.0,1.57,-1.57,0,0,3.14] joint angles in radians representing rotations of base, shoulder, elbow, wrist1, wrist2 and wrist3.
- a = 0 → not used in example
- v = 0 → not used in example
- t = 0.008 time where the command is controlling the robot. The function is blocking for time t [S].
- lookahead time = .1 time [S], range [0.03,0.2] smoothens the trajectory with this lookahead time.
- gain = 300 proportional gain for following target position, range [100,2000]
Several discussions are posted in the UR Forum to support users on any question that it might raise on how to use this command efficiently:
https://forum.universal-robots.com/t/servoj-urscript-abrupt-final-motion/8644
https://forum.universal-robots.com/t/servoj-function/7176
https://forum.universal-robots.com/t/how-to-decrease-error-value-of-servoj/6112