def __init__(self, end_point): """ """ self.grid = grid.Grid(tile_num_height, tile_num_width, tile_size) self.client = Client() self.sensor_state = SensorState() #Visualization self.master: Tk = Tk() self.canvas: Canvas = None #TODO: update heading self.heading = 0 self.prev_draw_c1c0_ids = [None, None] self.tile_dict: Dict[grid.Tile, int] = None # Generates random enviroment on the grid generator = RandomObjects(self.grid) generator.create_env(22, 0, 0, 22, 9) self.sensor_generator = GenerateSensorData(self.grid) self.create_widgets() # starting location for middle self.curr_tile = self.grid.grid[int(tile_num_width / 2)][int( tile_num_height / 2)] self.client.send_data({'end_point': end_point}) print("sent") self.main_loop() self.master.mainloop()
def __init__(self, master, fullMap, emptyMap, path): """A class to represent a GUI with a map Arguments: master {Tk} -- Tkinter GUI generator inputMap {grid} -- The grid to draw on path {tile list} -- the path of grid tiles visited FIELDS: master {Tk} -- Tkinter GUI generator tile_dict {dict} -- a dictionary that maps tiles to rectangles canvas {Canvas} -- the canvas the GUI is made on path {Tile list} -- the list of tiles visited by robot on path pathSet {Tile Set} -- set of tiles that have already been drawn (So GUI does not draw over the tiles) pathIndex {int} -- the index of the path the GUI is at in anumation curr_tile {Tile} -- the current tile the robot is at in animation grid {Grid} -- the Grid object that the simulation was run on """ # Tinker master, used to create GUI self.master = master self.tile_dict = None self.canvas = None self.path = path self.pathSet = set() self.pathIndex = len(path) - 1 self.curr_tile = None self.gridFull = fullMap self.gridEmpty = emptyMap self.create_widgets() self.generate_sensor = GenerateSensorData(self.gridFull)
def __init__(self, master, fullMap, emptyMap, path, endPoint, squareList, state): """A class to represent a GUI with a map Arguments: master {Tk} -- Tkinter GUI generator inputMap {grid} -- The grid to draw on path {tile list} -- the path of grid tiles visited squareList -- the list of all the square objects FIELDS: master {Tk} -- Tkinter GUI generator tile_dict {dict} -- a dictionary that maps tiles to rectangles canvas {Canvas} -- the canvas the GUI is made on path {Tile list} -- the list of tiles visited by robot on path pathSet {Tile Set} -- set of tiles that have already been drawn (So GUI does not draw over the tiles) pathIndex {int} -- the index of the path the GUI is at in anumation curr_tile {Tile} -- the current tile the robot is at in animation grid {Grid} -- the Grid object that the simulation was run on squareList -- the list of all the square objects """ # Tinker master, used to create GUI super().__init__(master, fullMap, emptyMap, path, squareList, 0) self.initPhase = True self.brokenPath = None self.brokenPathIndex = 0 self.visitedSet = set() for i in self.path: self.pathSet.add(i) self.recalc_count = recalc_wait self.recalc_cond = False self.stepsSinceRecalc = 0 self.create_widgets(True) self.generate_sensor = GenerateSensorData(self.gridFull) self.endPoint = endPoint self.next_tile = None self.obstacleState = state # set of tiles that were marked as available path in simulation's previous iteration self.last_iter_seen = set() # TODO: This is a buggggg..... we must fix the entire coordinate system? change init heading to 0 self.heading = 180 # TODO: change to custom type or enum self.output_state = "stopped" self.desired_heading = None self.angle_trace = None self.des_angle_trace = None
def __init__(self, master, fullMap, emptyMap, path, endPoint): """A class to represent a GUI with a map Arguments: master {Tk} -- Tkinter GUI generator inputMap {grid} -- The grid to draw on path {tile list} -- the path of grid tiles visited FIELDS: master {Tk} -- Tkinter GUI generator tile_dict {dict} -- a dictionary that maps tiles to rectangles canvas {Canvas} -- the canvas the GUI is made on path {Tile list} -- the list of tiles visited by robot on path pathSet {Tile Set} -- set of tiles that have already been drawn (So GUI does not draw over the tiles) pathIndex {int} -- the index of the path the GUI is at in anumation curr_tile {Tile} -- the current tile the robot is at in animation grid {Grid} -- the Grid object that the simulation was run on """ # Tinker master, used to create GUI self.master = master self.tile_dict = None self.canvas = None self.path = path self.brokenPath = None self.brokenPathIndex = 0 self.visitedSet = set() self.pathSet = set() for i in self.path: self.pathSet.add(i) self.pathIndex = 0 self.curr_tile = None self.prev_tile = None self.gridFull = fullMap self.gridEmpty = emptyMap self.recalc = False self.create_widgets() self.generate_sensor = GenerateSensorData(self.gridFull) self.endPoint = endPoint self.next_tile = None self.prev_vector = None self.recalc_count = recalc_wait self.recalc_cond = False self.way_point = None self.last_iter_seen = set( ) # set of tiles that were marked as available path in simulation's previous iteration # TODO: This is a buggggg..... we must fix the entire coordinate system? change init heading to 0 self.heading = 180 # TODO: change to custom type or enum self.output_state = "stopped" self.desired_heading = None self.angle_trace = None self.des_angle_trace = None self.oldError = 0 self.errorHistory = 0 self.mean = random.randint(-1, 1) / 12.0 self.standard_deviation = random.randint(0, 1.0) / 10.0 self.pid = None self.counter = 0 self.prev_draw_c1c0_ids = [ None, None ] # previous IDs representing drawing of C1C0 on screen
def __init__(self, master, inputMap, path, squareList): super().__init__(master, inputMap, None, path, squareList, len(path) - 1) self.create_widgets(False) self.generate_sensor = GenerateSensorData(self.gridFull)