Get current time from system

How do I know the time of the system to calculate the duration of a movement? getting the time before the movement and the time at the end of the movement would make the difference of these two variables and know the duration. CB3 to polyscope/program/expression/var (urp / txt) or script.

Thank you in advance.

this has already been asked and has good answers. Can be found by using the search term “time”: Get current time

1 Like

I saw it and I was expecting a more simple function but I try it and it works well anyway, Thank you for your quick answer I win some precious time.

Time as such known from e.g. Java is not implemented in URScript.
So the sync() timer option in a thread, may be the prefereable option in URScript.
If done in Python, Java or similar, there are many native options to extract timestamps.

Dear jbm, do you have an exemple of using sync() in UR Script?

sync() uses the remaining time in an 8 ms frame.
If called sequentially, each call will have a duration of 8 ms.
E.g.:

count = 0
while (count < 125):
   sync()
   count = count + 1
end
seconds = seconds + 1
1 Like

Thanks you, it’s what I needed it

Finally i did it like this. Sometimes I have an error of 8ms but it’s insignificant for what I am doing.

contador_de_tiempo_pantallazo

Hi! And what if I wanna implement in URScript this algorithm:

Start data logging, t=0s
while t<8s do
q=random(-pi/18,+pi/18) rad
v=random(0.5,2) rad/s
a = random(0.3,7) rad/s^2
movej(q0+q,v,a)
Wait random(0.1,1.0)
end while
Stop data logging