Skip to content
Snippets Groups Projects
Commit e9921b7c authored by Felix Freiberger's avatar Felix Freiberger
Browse files

Merge branch 'saved' of ssh://liebe.cs.uni-saarland.de:2222/powver/draisine into saved

parents 072a9157 03b45091
No related branches found
No related tags found
1 merge request!1Added SAVED integration.
......@@ -124,13 +124,19 @@ class Control(object):
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 /= 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 speedToByte(self, s):
s *= 25 # stretch to reasonable range
s = int(s) # truncate to byte
s = min(max(s, 0), 2**8-1) # enforce range
return s
def savedloop(self, human=False):
# old duty signal
# |
......@@ -141,11 +147,13 @@ class Control(object):
while True:
self.refreshSensors()
a = self.accY.read(t)
s = self.hallSpeed.read(t)
d = 0.75 # TODO
b = max(0, min(254, int(254 * d)))
if human:
print 'accY = {v}'.format(v=self.accelerationToByte(a))
print 'duty = {d}'.format(d=b)
print 'accY = {v}'.format(v=self.accelerationToByte(a))
print 'speed = {s}'.format(s=self.speedToByte(s))
print 'duty = {d}'.format(d=b)
else:
dutycmd = array.array('B', [b])
self.logDuty(dutycmd)
......
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