Using speedl() with a timed loop

Dear,

I want to have the robot (a UR10, CB3) make a simple linear move. a movel() would do it, but I want to do some processing while the move is taking place. So I converted the arguments to movel to a difference vector and a time and use speedl() to do the move. If I use the difference vector and the time I computed, speedl works fine.

However, if I program something like:

steps = time/some_unit_of_time
speedl(xd,a) ← should start the robot off in the direction given by xd and return when the robot reaches the encoded velocity
c = 0
while 0 < steps:
steps = steps -1
sleep(some_unit_of_time)
do_stuff_really_quick()
end
stopl(a)

The robot stops immediately after the speedl(), then enters the timed loop… not what I wanted. If I use speedl(xd,a,time) the robot moves correctly, but I still have to wait, just as if I had used movel().

So how can I achieve this behavior? Threads don’t work (e.g. using a thread to issue a stopl()) since I get a “robot already controlled by another thread”-exception.

Have you tried enter_critical on your thread? I’m not sure if it would solve you problem or not:

image

1 Like