Fixed Error Message output in sensor.py. Added some more Documentation.
This commit is contained in:
parent
0f1b696a20
commit
aca3c3b70f
3 changed files with 28 additions and 24 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
"""
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue