Hi, I was trying to capture data from our tracking wheels setup and not sure why I’m seeing what’s going on with the timing values comparing Timer.system() rand Rotation.timerstamp().
Based on my understanding, Rotation sensors update by default every 20ms, so a ~10ms loop capturing data should see up to 20ms delta between the system time and the sensor timestamp + some delta accounting for internal Brain and VexOS sensor update delay, so maybe up to 30ms?
What I’m seeing on the other hand is the time delta starting off being delayed between 30-40ms and slowly increasing. After about 7 seconds the delta is bouncing between 80-90ms. The code here is very simple:
def sampling_thread_callback(self):
brain.screen.print("Sampling Thread Started")
global run_sampling
rot_l = [] # list for left rotation sensor
rot_r = [] # list for right rotation sensor
rot_s = [] # list for sideways rotation sensor
system_times = [] # list for system times
system_timer = Timer()
total_samples = 0
# Capture data
while self.run_sampling:
current_time = system_timer.system()
system_times.append(current_time)
rot_l.append([RotationLeft.position(TURNS), RotationLeft.timestamp()])
rot_r.append([RotationRight.position(TURNS), RotationRight.timestamp()])
rot_s.append([RotationRear.position(TURNS), RotationRear.timestamp()])
total_samples = total_samples + 1
wait(10, MSEC)
# Print data
print("Total Samples = ", total_samples)
print("idx, time, rotl TURNS, rotl TIME, rotr TURNS, rotr TIME, rots TURNS, rots TIME")
wait(10,MSEC)
for i in range(total_samples):
rotl_val, rotl_time = rot_l[i]
rotr_val, rotr_time = rot_r[i]
rots_val, rots_time = rot_s[i]
print(i, ",", system_times[i], ",", rotl_val, ",", rotl_time, ",", rotr_val, ",", rotr_time, ",", rots_val, ",", rots_time)
wait(500,MSEC)
Captured results from this is below (note sideways sensor omitted for brevity). The last two columns are just the difference between the system time “Time” and the respective sensor timestamps “rotl TIME” and “rotr TIME”.
Any help appreciated here …
Thanks,
Nick