Sending data from python to the robot

Hi everyone,

For a school project we need to program a UR with has to peform serveral actions based on vision. A customer can order a product which exists of 3 components with random colours. We already wrote a bit of code so we can read what product and which colours the customer ordered. Every variation is linked to a number so we can easily read the python script. For example, a product with a blue bottom, green middle part and red top is linked to the number 1.

The part we cannot figure out is how we can send a signal to the UR so it knows what components to pick for the correct variation. We think we have to work with the digital inputs of the robot, but we are not sure. Can someone help us with this issue?

How are you writing the Python code? Directly on the UR controller, or are you using a raspberryPI or similar? If you’re already far enough along that the python code is interacting with the vision software on a separate board like a PI, I would just take an output from the Pi and have it turn on a relay connecting the robot’s 24v to one of its digital inputs. You’d need one relay per input/combination, so this might not be a good route. If you’re writing the python on the robot controller via a daemon, then you should be able to access the GB boolean registers in the robot and let those make the robot decisions

If you have a Python code running, then are you using a board or computer with Ethernet connections available? Wouldn’t it be easier to use the Python code to send it over TCP, UDP or XML-RPC?

I agree with cgs,
I think a simple Socket message over TCP/IP would be the most simple way.

or you could use RTDE to set a register in the Robot. (Python examples are available Real-Time Data Exchange (RTDE) Guide - 22229)