Skip to content

Read Contact Detection

SUMMARY

Read Contact Detection queries the current contact detection state without stopping detection. Returns True if contact has been detected since Start Contact Detection was called, and False otherwise.

This skill is designed to be called repeatedly in a polling loop while the robot is moving asynchronously.

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
contact = robot.read_contact_detection()

The Code

Example: Poll for Contact During an Asynchronous Move

Poll for contact at 20 Hz while the robot moves toward a target.

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)

current = robot.get_cartesian_pose()
target = list(current)
target[2] += 0.05

robot.set_cartesian_pose(target, speed=0.05, acceleration=0.5, asynchronous=True)
robot.start_contact_detection()
logger.info("Polling for contact...")

for _ in range(50):
    if robot.read_contact_detection():
        logger.info("Contact detected!")
        break
    time.sleep(0.05)

contact = robot.stop_contact_detection()
logger.success(f"Final contact state: {contact}")

# Disconnect
robot.disconnect()

The Explanation of the Code

read_contact_detection queries whether contact has been detected since the detection was armed with start_contact_detection. It does not stop detection — the robot continues moving and the detection subsystem remains armed after the call. Call this in a polling loop at the desired rate. Use Stop Contact Detection when you want to disarm detection and obtain the definitive final result.

How to Tune the Parameters

This skill takes no parameters.

Return Value

TypeDescription
boolTrue if contact has been detected, False if no contact has occurred yet.

Where to Use the Skill

  • High-frequency polling loops — Check for contact at 20–125 Hz during asynchronous motion
  • Interrupt-driven control — Break out of a motion loop immediately when contact is detected

When Not to Use the Skill

Do not use Read Contact Detection when: