capped wheel speed to 100 (to avoid errors)
This commit is contained in:
parent
d268198fa4
commit
97af61e5e1
1 changed files with 11 additions and 2 deletions
13
src/move.py
13
src/move.py
|
@ -5,6 +5,15 @@ from sensor import Sensor
|
||||||
from odometry import Odometry
|
from odometry import Odometry
|
||||||
|
|
||||||
|
|
||||||
|
def capat100(value):
|
||||||
|
if(value > 100):
|
||||||
|
return 100
|
||||||
|
elif(value < -100):
|
||||||
|
return -100
|
||||||
|
else:
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
class Move:
|
class Move:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
try:
|
try:
|
||||||
|
@ -79,8 +88,8 @@ class Move:
|
||||||
|
|
||||||
while (self._sensor.bumperispressed() is not True and self._sensor.lastcolor is None):
|
while (self._sensor.bumperispressed() is not True and self._sensor.lastcolor is None):
|
||||||
self._camera.refresh()
|
self._camera.refresh()
|
||||||
self._wheel_l.speed_set(self.maxbrightness//2 - self._sensor.getbrightness()//2)
|
self._wheel_l.speed_set(capat100(self.maxbrightness/2 - self._sensor.getbrightness()/2))
|
||||||
self._wheel_r.speed_set(self._sensor.getbrightness()//2)
|
self._wheel_r.speed_set(capat100(self._sensor.getbrightness()/2))
|
||||||
self._sensor.getcolor()
|
self._sensor.getcolor()
|
||||||
if(not isknownstation):
|
if(not isknownstation):
|
||||||
print(self._odometry.degree(self._wheel_l.getmovement(), self._wheel_r.getmovement(), 0))
|
print(self._odometry.degree(self._wheel_l.getmovement(), self._wheel_r.getmovement(), 0))
|
||||||
|
|
Loading…
Reference in a new issue