Universal Robots Forum

Python ur-e get/set signals

hi,
how I can read a signal , set the signal on / off and (if it was possible to) set a point or a variable, Through a python script.
if you can i need a deep explaination of the procedure if external libraryes are needed.

thanks a lot!

Hi @francesco.menci, the RTDE interface is the preferred method for this kind of interaction with the robot. Check out the python samples at the bottom of this page:

https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/real-time-data-exchange-rtde-guide-22229/

the example of rtde communication is really dispersive and the examples are not very clear to me. I was wondering if it was possible to have an example of how to switch on / off a bit, check the status of a bit and set the coordinates of a pick point

Hey @francesco.menci I have recently released an interface where you can do this over RTDE. See this forum post Universal Robots RTDE C++/Python Interface

An example of your use case in python would be something like:

import rtde_receive
import rtde_control 
rtde_r = rtde_receive.RTDEReceiveInterface("127.0.0.1")
rtde_c = rtde_control.RTDEControlInterface("127.0.0.1")

# Set standard digital out 
rtde_c.setStandardDigitalOut(0, True)
# Get standard digital output bits,  returns current state of the digital outputs. 0-7: Standard, 8-15: Configurable, 16-17: Tool
rtde_r.getActualDigitalOutputBits()
# Mask the bits you want.

# Go to a pick point 
pick_point = [-0.143, -0.435, 0.20, -0.001, 3.12, 0.04]
speed = 0.5
acceleration = 0.3
rtde_c.moveL(pick_point, speed, acceleration)

Checkout the documentation with examples and API here: https://sdurobotics.gitlab.io/ur_rtde/index.html