diff --git a/src/move.py b/src/move.py index 02045e2..a79c8c9 100644 --- a/src/move.py +++ b/src/move.py @@ -28,6 +28,9 @@ class Move: ''' uses odometry and the planet object to map edges that are connected to current node. + + Use either relative motor pos or timed driving to center on node. + Next turn around and detect edges through drops in _sensor.getbrightness() ''' def getstationedges(self): pass diff --git a/src/planet.py b/src/planet.py index c601dea..f724d50 100644 --- a/src/planet.py +++ b/src/planet.py @@ -16,56 +16,57 @@ class Direction(IntEnum): # simple alias, no magic here Weight = int -""" +""" Weight of a given path (received from the server) - value: -1 if broken path + value: -1 if broken path >0 for all other paths never 0 """ class Planet: - """ - Contains the representation of the map and provides certain functions to manipulate it according to the specifications + """ + Contains the representation of the map and provides certain functions to manipulate it according to the specifications """ def __init__(self): """ Initializes the data structure """ + self.planetmap = {((0, 0), Direction.NORTH):((0, 1), Direction.SOUTH), "weight":1} self.target = None def add_path(self, start: Tuple[Tuple[int, int], Direction], target: Tuple[Tuple[int, int], Direction], weight: int): - """ - Adds a bidirectional path defined between the start and end coordinates to the map and assigns the weight to it + """ + Adds a bidirectional path defined between the start and end coordinates to the map and assigns the weight to it - example: + example: add_path(((0, 3), Direction.NORTH), ((0, 3), Direction.WEST), 1) """ - pass + def get_paths(self) -> Dict[Tuple[int, int], Dict[Direction, Tuple[Tuple[int, int], Direction, Weight]]]: - """ - Returns all paths + """ + Returns all paths - example: - get_paths() returns: { + example: + get_paths() returns: { (0, 3): { - Direction.NORTH: ((0, 3), Direction.WEST, 1), - Direction.EAST: ((1, 3), Direction.WEST, 2) + Direction.NORTH: ((0, 3), Direction.WEST, 1), + Direction.EAST: ((1, 3), Direction.WEST, 2) }, (1, 3): { - Direction.WEST: ((0, 3), Direction.EAST, 2), - ... - }, + Direction.WEST: ((0, 3), Direction.EAST, 2), + ... + }, ... } """ pass def shortest_path(self, start: Tuple[int, int], target: Tuple[int, int]) -> Optional[List[Tuple[Tuple[int, int], Direction]]]: - """ - Returns a shortest path between two nodes + """ + Returns a shortest path between two nodes - examples: + examples: shortest_path((0,0), (2,2)) returns: [((0, 0), Direction.EAST), ((1, 0), Direction.NORTH)] shortest_path((0,0), (1,2)) returns: None """ diff --git a/src/sensor.py b/src/sensor.py index b86e44b..db9d081 100644 --- a/src/sensor.py +++ b/src/sensor.py @@ -5,8 +5,8 @@ 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) +RED = (>90, <40, <25) +BLUE = (<25, >75, >90) still needs to be tested and implemented ''' @@ -24,13 +24,13 @@ class Sensor: else: return False else: - print("ERROR: incorrect sensor mode:" + self._sensor.mode) + print("ERROR: incorrect sensor mode:", self._sensor.mode) def getbrightness(self): if(self._sensor.mode == 'COL-REFLECT'): return self._sensor.value() else: - print("ERROR: incorrect sensor mode:" + self._sensor.mode) + print("ERROR: incorrect sensor mode:", self._sensor.mode) def setmode(self, newmode): self._sensor.mode = newmode