Skip to content
Snippets Groups Projects
Commit 82f56e8a authored by Chair on Fire's avatar Chair on Fire
Browse files

Implemented acceleration measurement for SAVED.

parent 61c4360c
No related branches found
No related tags found
1 merge request!1Added SAVED integration.
......@@ -123,16 +123,23 @@ class Control(object):
sys.stdout.write(255)
sys.stdout.flush()
def accelerationToByte(self, a):
a /= self.accG # convert back to g-force
a *= 16384.0 # convert back to raw 16-bit word
a += (2**15) # shift value to nonnegative range
a = int(a / (2**8)) # truncate to byte
a = min(max(a, 0), 2**8-1) # enforce range
return a
def savedloop(self, human=False):
t = time.time()
while True:
self.refreshSensors()
# a = self.accY.read(tsensed - self.period - sys.float_info.epsilon)
a = self.accY.read(t)
d = 0.75 # TODO
b = max(0, min(254, int(254 * d)))
if human:
print 'accY = {v}m/s^2'.format(v=a)
print 'accY = {v}'.format(v=self.accelerationToByte(a))
print 'duty = {d}'.format(d=b)
else:
dutycmd = array.array('B', [b])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment