X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Ftests%2Fstatic_beacon%2Fcoding.py;h=05b20abdd1c39c12e888066c5f79f6de86feba2f;hp=9ef4c5caac918e18fc3050e60db9b29d07d67a4d;hb=4e68c9b6f30c864b671b5c51affe61d7c9205465;hpb=d6922ca35b126696fc34cfb7714acfa14edd1c4a diff --git a/projects/microb2010/tests/static_beacon/coding.py b/projects/microb2010/tests/static_beacon/coding.py index 9ef4c5c..05b20ab 100644 --- a/projects/microb2010/tests/static_beacon/coding.py +++ b/projects/microb2010/tests/static_beacon/coding.py @@ -10,7 +10,7 @@ RPS = 20. #TIMER_FREQ = 2000000. TIMER_FREQ = 16000000. -LASER_RADIUS = 25. # mm +LASER_RADIUS = 20. # mm MIN = 200. MAX = 3500. @@ -68,10 +68,12 @@ def time_tick_to_us(t): # linear correction: distance_mm, time_us # must be ordered samples = [ - (250., 2201.), - (450., 701.), - (1200., 231.), - (3000., 50.), + (330., 15681./16), + (778., 6437./16), + (1180., 4351./16), + (1608., 3221./16), + (2045., 2583./16), + (2487., 2167./16), ] dist_mm = map(frame_to_mm, range(512)) @@ -83,7 +85,7 @@ for i in range(512): # find offset and update theorical curve off = samples[-1][1] - mm_to_us(3000.) -print "offset=%f"%(off) +#print "offset=%f"%(off) theo_off = [0] * 512 for i in range(512): mm = frame_to_mm(i) @@ -107,33 +109,26 @@ for i in range(512): ratio = (mm - samples[smp][0]) / (samples[smp+1][0] - samples[smp][0]) mm_new = mm_start + ratio * (mm_end - mm_start) + if mm_new < 0: + mm_new = 1. final[i] = mm_to_us(mm_new) + off -sample_idx = 0 -while sample_idx < len(samples): - print samples[sample_idx][1], - print us_to_mm(samples[sample_idx][1] - off), - print mm_to_us(samples[sample_idx][0]) - sample_idx += 1 - plt.plot( -# dist_mm, theorical, "r-", -# dist_mm, theo_off, "b-", + dist_mm, theorical, "r-", + dist_mm, theo_off, "b-", dist_mm, final, "g-", map(lambda x:x[0], samples), map(lambda x:x[1], samples), "g^", ) plt.show() - print "#include " print "#include " print "prog_uint16_t framedist_table[] = {" for i in range(512): if (i % 8) == 0: print " ", -# print "%d,"%(int(linear_interpolation(offsets, i, table[i]))), - print "%d,"%(int(table[i])), + print "%d,"%(int(time_us_to_tick(final[i]))), if (i % 8 == 7): print print "};"