Chapter 11: servoJ and servoL
About This Chapter
servoJ and servoL are UR’s real-time servo control APIs.
Whereas moveJ and moveL are commands to “move to a destination,” servoJ is a command that “continuously updates the current target at a fixed interval.”
Servo APIs are used for:
Joystick control
Image tracking
Visual servoing
External control
Force control
11.1 Differences from moveJ
moveJ
Target position
↓
Controller generates trajectory
↓
Movement
↓
Completion
servoJ
Current target
↓
Move a little
↓
New target
↓
Move a little
↓
New target
↓
...
In other words, servoJ is an API for “continuously rewriting the target position.”
11.2 How servoJ Works
For example, when operating a joystick, the following sequence is executed every cycle:
100 Hz
↓
Current joystick position
↓
New joint angles
↓
servoJ()
The robot moves toward “the most recent target” at all times.
11.3 Basic Syntax
rtde_c.servoJ(
q,
speed,
acceleration,
dt,
lookahead_time,
gain,
)
11.4 q
Target joint angles
[
q1,
q2,
q3,
q4,
q5,
q6
]
Unit
rad
11.5 dt
Control period
For example,
0.002
corresponds to 500 Hz, while
0.008
corresponds to 125 Hz.
The PC must also send servoJ commands at a fixed interval matching this value.
11.6 lookahead_time
This is the parameter most commonly misunderstood.
The controller performs the following operations:
Current position
↓
Velocity
↓
Predict future position
↓
Correction
lookahead_time is the prediction horizon used for that future-position estimate.
In general, values of approximately
0.03–0.20 s
are used.
11.7 gain
gain is the tracking gain.
Conceptually, it is similar to a
P-control gain
Low gain:
Slower tracking
Smoother motion
High gain:
Faster tracking
More prone to oscillation
11.8 speed and acceleration
For servoJ, these parameters are not as important as they are for moveJ.
Interpolation is performed inside the controller while accounting for safety limits.
In practice,
lookahead_time
gain
have a greater influence on behavior.
11.9 Why Commands Must Be Sent Every Cycle
moveJ:
Send once
↓
Completion
servoJ:
500 Hz
↓
Send
↓
500 Hz
↓
Send
↓
500 Hz
↓
Send
If transmission stops partway through, target updates stop.
11.10 servoStop()
When ending servo control, call:
rtde_c.servoStop()
Sending moveJ immediately without doing so is not recommended.
11.11 servoL
servoL updates the TCP position every cycle.
Pose
↓
servoL
↓
Pose
↓
servoL
↓
...
It is used for applications such as visual servoing.
11.12 Comparison with moveJ
Item |
moveJ |
servoJ |
|---|---|---|
Target |
Final position |
Updated every cycle |
Period |
Not required |
125–500 Hz |
Application |
General movement |
Real-time control |
Termination |
Automatic |
servoStop() |
11.13 Difference from speedJ
speedJ:
Velocity command
servoJ:
Position command
11.14 Joystick Control
Typical sequence:
Joystick
↓
Calculate joint angles
↓
servoJ()
↓
2 ms
↓
servoJ()
↓
2 ms
↓
...
This method provides the smoothest operation.
11.15 Visual Servoing
In image-based control, the sequence is:
Camera
↓
Position error
↓
PID
↓
Pose
↓
servoL
Image-processing results can be reflected in every cycle.
11.16 Communication Latency
servoJ is sensitive to communication latency.
If the control period becomes irregular, problems such as
Jerky motion
Tracking delay
Stopping
may occur.
Therefore, the following are recommended:
A real-time operating system
Wired LAN
Transmission at a fixed interval
11.17 Common Mistakes
An inconsistent control period
Failing to call servoStop()
Setting lookahead_time extremely low
Setting gain extremely high
Mixing servo control with move-family APIs
11.18 Design in ur_ctrl.py
In general, it is convenient to divide the interface into three stages:
servo_start()
servo_update()
servo_stop()
Users then need to be concerned only with the control period.
11.19 When to Use servoJ
Gamepad operation
Mouse operation
Visual servoing
Force control
Tracking external sensors
For ordinary teaching operations, moveJ is more appropriate.
Summary
servoJ is a real-time position-control API.
It is not a faster version of moveJ; it is an API for
“continuously rewriting the target position at a fixed interval.”
When using servo APIs, it is important to understand these four points correctly:
Fixed control period
lookahead_time
gain
servoStop()
The next chapter explains Force Mode and Freedrive Mode.