capped wheel speed to 100 (to avoid errors)

This commit is contained in:
d3rped 2018-03-23 21:56:54 +01:00
parent d268198fa4
commit 97af61e5e1

View file

@ -5,6 +5,15 @@ from sensor import Sensor
from odometry import Odometry
def capat100(value):
if(value > 100):
return 100
elif(value < -100):
return -100
else:
return value
class Move:
def __init__(self):
try:
@ -79,8 +88,8 @@ class Move:
while (self._sensor.bumperispressed() is not True and self._sensor.lastcolor is None):
self._camera.refresh()
self._wheel_l.speed_set(self.maxbrightness//2 - self._sensor.getbrightness()//2)
self._wheel_r.speed_set(self._sensor.getbrightness()//2)
self._wheel_l.speed_set(capat100(self.maxbrightness/2 - self._sensor.getbrightness()/2))
self._wheel_r.speed_set(capat100(self._sensor.getbrightness()/2))
self._sensor.getcolor()
if(not isknownstation):
print(self._odometry.degree(self._wheel_l.getmovement(), self._wheel_r.getmovement(), 0))