Applied commit: a540201

This commit is contained in:
haselnussbier 2018-03-24 17:35:40 +01:00 committed by d3rped
parent 678c94532e
commit 78ce8da918
2 changed files with 16 additions and 7 deletions

View file

@ -87,13 +87,16 @@ class Move:
self._wheel_r.speed_set(self._sensor.edgebrightness//2)
self._wheel_l.run()
self._wheel_r.run()
while (not self._sensor.bumperwaspressed and self._sensor.lastcolor is None):
while (not self._sensor.bumperwaspressed):
self._sensor.refresh()
self._sensor.checkbumper()
self._sensor.getcolor()
if (not (self._sensor.lastcolor is None)):
break
self._wheel_l.speed_set(capat100(self._sensor.edgebrightness/2 - self._sensor.getbrightness()/2)+self.defaultspeed)
self._wheel_r.speed_set(capat100(self._sensor.getbrightness()/2 - self._sensor.edgebrightness/2)+self.defaultspeed)
self._sensor.getcolor()
if(not isknownstation):
self._odometry.pos_update((self._wheel_l.getmovement(), self._wheel_r.getmovement()))
# if() bumper or color
self._wheel_l.stop()
self._wheel_r.stop()

View file

@ -24,8 +24,8 @@ Y=(0.299 x R) + (0.587 x G) + (0.114 x B);
class Color(tuple, Enum):
RED = (85, 40, 25)
BLUE = (25, 70, 85)
RED = (65, 30, 20)
BLUE = (20, 45, 60)
class Sensor:
@ -43,7 +43,7 @@ class Sensor:
self.lastcolor = None
self.edgebrightness = None
def refresh(self): # do we still want to check if the propper camera/sensor mode is set?
def refresh(self):
self.RGB = self._camera.bin_data("hhh")
self._brightness = self._camera.value()
@ -69,5 +69,11 @@ class Sensor:
if(self.RGB[0] < Color.BLUE[0] and (self.RGB[1], self.RGB[2]) > (Color.BLUE[1], Color.BLUE[2])):
self.lastcolor = Color.BLUE
def calibrateRGB(self):
pass
def calibrateRGB(self, color):
self.refresh()
if (color is Color.RED):
newRED = (self.RGB[0]-5, self.RGB[1]+5, self.RGB[2]+5)
Color.RED = newRED
elif (color is Color.BLUE):
newBLUE = (self.RGB[0]+5, self.RGB[1]-5, self.RGB[2]-5)
Color.BLUE = newBLUE