Moving the robot in xyz direction until an IO-signal is received

Hi,

I am using our UR10e with a distance sensor. The idea is to move the robot at constant speed until a “True” signal is received from the sensor (in this case DO9).

From what I have gathered I can move the robot at a constant speed using speedl-command until the movement is interrupted. Since the sensor signal changes from “False” to “True” at a specific height, I need to constantly check the IO-value while the robot moves. As I understood this can be done using a program that runs parallel to the main script, a thread.

What I cannot figure out is how to let the main script know when the thread has detected the signal change to “True”. It seems like I cannot use a return statement either since the manual states “although a return statement is allowed in the thread, the value returned is discarded, and cannot be accessed from outside the thread.”

Any suggestions?

You could have the movement inside the thread while the main script is checking for the input. That way you can kill the thread once it goes “True” and stop the movement.

Is this what you’re looking for, or am I missing something (happens quite often these days)? :slight_smile:
DO9, though? That’s an output?

1 Like

Thanks, but would this be any different than running the movement in the main script? I assume the thread works linearly by running line after line,. and having a move here would not allow me to continuously check the signal while moving.

Yeah, this is similar to what I found on Google and it seems to work. The thing is that I would like to do this on URScript side so that I can use the same file in several places. By DO9 I mean Digital Out 9.

Thanks!

But you have to use a digital input if you want to get a signal from a sensor into the robot? I’m confused. :slight_smile:

Anywho. You can load programs as subprograms and load them between programs with the SubProg command.
Alternatively, you can also make a “normal” .urp UR program, save it and run it. Then the controller will save the program as a script file. You can take a look at it to get an idea of how to write it in script yourself, if you need to afterall. :slight_smile:

This is another way to achieve the same function:

Looks like this in the generated script file:

Here similar solution but with UR script code better arranged :blush:

And you have every right to be confused - Digital In 9 it is, NOT Digital Out!

Thank you, it seems like I am getting there! I noticed that you have the movel command in two places: both inside the thread and the main script - is there a specific reason to do this twice?

Also, you are checking the signal condition inside a “while thread running-loop”; does this mean the script checks the signal level every processing cycle ?

The first movel in the main script is the starting position, inside the async thread you find the final target position.
The while async_running loop is there to continuously check the signal condition.
The while True loop is there only to repeat the task for testing purpose.

(I have used digital_out because it is easier to test it directly using polyscope IO status window)

Thank you for the clarification. I need to do some trials when I go to the lab.

Where is this window?

Which window? The Direction? It’s a command available in e-series and updated CB-series robots. :slight_smile: