servoj(q, a, v, t=0.002, lookahead_time=0.1, gain=300)
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.002)
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)
Here 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.002, 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 current version
- v = 0 → not used in current version
- t = 0.002 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]