Made an irrelevant adjustment. Also added some documentation to the source code.

This commit is contained in:
d3rped 2018-03-19 00:44:57 +01:00
parent 23fb6e80e7
commit 0f1b696a20
2 changed files with 28 additions and 9 deletions

View file

@ -12,18 +12,29 @@ class Move:
self._sensor = Sensor() self._sensor = Sensor()
self._bumper = ev3.TouchSensor() self._bumper = ev3.TouchSensor()
'''
determine maximum and minimum brightness of lines/white space
depending on environment lighting
'''
def _calibrate(self): def _calibrate(self):
pass pass
'''
Function to correct errors should the robot wander astray
'''
def _aligntoedge(self): def _aligntoedge(self):
pass pass
'''
uses odometry and the planet object to map edges that are connected to
current node.
'''
def getstationedges(self): def getstationedges(self):
pass pass
def traversetonextstation(self, isknownstation): def traversetonextstation(self, isknownstation):
self._wheel_l.speed_set = 20 self._wheel_l.speed_set = 24
self._wheel_r.speed_set = 20 self._wheel_r.speed_set = 24
self._wheel_l.run() self._wheel_l.run()
self._wheel_r.run() self._wheel_r.run()
while(self._bumper.value() == False): while(self._bumper.value() == False):

View file

@ -2,8 +2,14 @@
import ev3dev.ev3 as ev3 import ev3dev.ev3 as ev3
'''
add enum for color definitions (type should be tupel of int's).
later onwards compare the idividual readouts like this to determine the color:
RED(>90, <40, <25)
BLUE(<25, >75, >90)
still needs to be tested and implemented
'''
# add enum for color definitions
class Sensor: class Sensor:
def __init__(self): def __init__(self):
@ -11,18 +17,20 @@ class Sensor:
self._sensor.mode = 'COL-REFLECT' self._sensor.mode = 'COL-REFLECT'
def iscolor(self, color): def iscolor(self, color):
if(self._sensor.mode == 'RGB-RAW'):
curcol = self._sensor.bin_data("hhh") curcol = self._sensor.bin_data("hhh")
if curcol == curcol: if curcol == curcol:
return True return True
else: else:
return False return False
else:
print("ERROR: incorrect sensor mode:" + self._sensor.mode)
# see https://stackoverflow.com/questions/687261/converting-rgb-to-grayscale-intensity
def getbrightness(self): def getbrightness(self):
if(self._sensor.mode == 'COL-REFLECT'): if(self._sensor.mode == 'COL-REFLECT'):
return self._sensor.value() return self._sensor.value()
else: else:
print("ERROR: incorrect sensor mode.") print("ERROR: incorrect sensor mode:" + self._sensor.mode)
def setmode(self, newmode): def setmode(self, newmode):
self._sensor.mode = newmode self._sensor.mode = newmode