1,6 → 1,8 |
#!/usr/bin/python |
|
# plot with >> plot 'last.txt' u 1:2 w l axes x1y1, 'last.txt' u 1:4 w l axes x1y2, 'last.txt' u 1:3 |
|
import os |
import time |
import datetime |
import sys |
57,15 → 59,19 |
angles[1] = sensor.get_angle(verify = False) |
n = 0 |
speed = 0 |
AVERAGING = 100 |
f = open('log.txt','w') |
AVERAGING = 50 |
|
filen = 'log%0.0f.txt'%time.time() |
f = open(filen,'w') |
os.remove("last.txt") |
os.symlink(filen, "last.txt") |
|
gpsp = GpsPoller() |
gpsp.start() |
|
while True: |
for i in range(AVERAGING): |
time.sleep(0.005) |
time.sleep(0.01) |
angles[0] = sensor.get_angle(verify = False) |
|
if (angles[0] + n*360 - angles[1]) > 300: |
81,10 → 87,12 |
|
speed += (-angles[4] + 8*angles[3] - 8*angles[1] + angles[0])/12 |
angles = np.roll(angles, 1) |
|
speed = speed/AVERAGING |
|
g_spd = gpsd.fix.speed |
print "W_Spd: %0.2f \t Angle: %0.2f \t G_Spd %0.2f" % (speed, angles[0], g_spd) |
f.write("%0.2f %0.2f %0.2f %0.2f\r\n" %(time.time(), speed, angles[0], g_spd)) |
f.write("%0.2f %0.2f %0.2f %0.2f\r\n" %(time.time(), abs(speed), angles[0], g_spd)) |
f.flush() |
|
|