Skip to content

Servo Joint

SUMMARY

Servo Joint streams a target joint configuration to the robot controller at high frequency (typically 500 Hz). It is designed to be called repeatedly in a tight control loop for custom real-time trajectories or teleoperation.

SUPPORTED ROBOTS

This skill is currently supported on Universal Robots only. Calling this method on other robot brands will raise a NotImplementedError.

The Skill

python
robot.servo_joint(
    q=target_joints,
    speed=30.0,
    acceleration=40.0,
    time=0.002,
    lookahead_time=0.1,
    gain=300,
)

The Code

Example: Servo Joint in a High-Frequency Control Loop

Stream joint positions to the robot at 500 Hz for 1 second.

python
import time
from loguru import logger
from telekinesis.synapse.robots.manipulators import universal_robots

robot_ip = "192.168.1.2"  # replace with your robot's IP

robot = universal_robots.UniversalRobotsUR10E()
# Connect
robot.connect(ip=robot_ip)

q_target = robot.get_joint_positions()
dt = 0.002  # 500 Hz
duration = 1.0
t_start = time.perf_counter()

while time.perf_counter() - t_start < duration:
    robot.servo_joint(
        q=q_target,
        speed=30.0,
        acceleration=40.0,
        time=dt,
        lookahead_time=0.1,
        gain=300,
    )
    time.sleep(dt)

robot.servo_stop()
logger.success("Servo joint loop complete.")

# Disconnect
robot.disconnect()

The Explanation of the Code

servo_joint streams a joint target to the controller at high frequency. q is the target joint configuration in degrees. speed and acceleration are in deg/s and deg/s². time is the command execution time in seconds — if non-zero, it overrides speed. lookahead_time (range [0.03, 0.2] s) controls trajectory smoothing: larger values smooth the path more but increase latency. gain (range [100, 2000]) is the proportional gain. Always call servo_stop() after exiting the loop.

How to Tune the Parameters

ParameterTypeDefaultDescription
qlist[float]Target joint positions in degrees.
speedfloatJoint speed in deg/s.
accelerationfloatJoint acceleration in deg/s².
timefloatCommand execution time in seconds. Overrides speed if non-zero.
lookahead_timefloatSmoothing horizon in seconds, range [0.03, 0.2].
gainfloatProportional gain, range [100, 2000].

Return Value

ValueDescription
NoneThis skill returns nothing.

Where to Use the Skill

  • Real-time trajectory streaming (e.g., teleoperation, model-predictive control).
  • Custom high-frequency motion profiles.

When Not to Use the Skill

Use a different skill instead in these cases:

  • Use Set Joint Positions for single-waypoint blocking moves; servo commands require a continuous high-frequency loop to function correctly.