aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug/nxt-python-fantom/examples/latency.py
blob: b4b1f2656424909290c1de103054fceb4838c330 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python

import time
import nxt.locator
from nxt.sensor import *

b = nxt.locator.find_one_brick()

#Touch sensor latency test
touch = Touch(b, PORT_1)
start = time.time()
for i in range(100):
    touch.get_sample()
stop = time.time()
print 'touch latency: %s ms' % (1000 * (stop - start) / 100.0)

#Ultrasonic sensor latency test
ultrasonic = Ultrasonic(b, PORT_4)
start = time.time()
for i in range(100):
    ultrasonic.get_sample()
stop = time.time()
print 'ultrasonic latency: %s ms' % (1000 * (stop - start) / 100.0)