Hello. I am developing a conveyor simulation in which I have a start and end sensor. When the product passes the start sensor, I wanted to get the real time Instant, and then make the same thing in the end sensor and make end-start so I can get the time difference from start to end of the conveyor.
I tried this using sim.getSystemTime, using "a" as an auxiliary variable to make this work only 1 time, and then assign the value to another variable so I can work the math. Problem is the variable time keeps running even after the sensor = 0. Is there a function to get the time and "freeze" it so I can get the INSTANT, instead of the running time? Any help will be appreciated. Thanks.
tempo1= 0
a = 0
if (a ==0) then
if(sensorInicio == 1.0) then
tempo1 = sim.getSystemTime(0)
local tempoInicio = tempo1
a = 1
end
end
How do I get a time Instant in a non-threaded script
Re: How do I get a time Instant in a non-threaded script
Hello,
I do not understand your question. If your sensor A is triggering, simply assign the current time to a variable X. If your sensor B is triggering, then the duration between sensor A and B trigger is the current time minus the variable X.
Cheers
I do not understand your question. If your sensor A is triggering, simply assign the current time to a variable X. If your sensor B is triggering, then the duration between sensor A and B trigger is the current time minus the variable X.
Cheers