示例#1
0
def _run_brushfire(c):
    """Runs the brushfire"""
    import time; time.sleep(3)
    from brushfire import BrushfireExpansion
    be = BrushfireExpansion(c)
    be.set_ignition_cells([(0,0)])
    while be.step_solution():
        pass
示例#2
0
    def reset_algorithm(self):
        """Resets the algorithm"""
        self.costmap_widget.canvas.freeze = True
        self.costmap[:] = 0.0
        Obstacle(3, 3, 3, 3).draw(self.costmap)
        Obstacle(9, 5, 3, 3).draw(self.costmap)
        Obstacle(16, 4, 3, 3).draw(self.costmap)

        self.be = BrushfireExpansion(self.costmap)
        temp = self.costmap_widget.canvas.start_coord
        self.start_coord = (floor(temp[0] + 0.5), floor(temp[1] + 0.5))
        self.be.set_ignition_cells([self.start_coord])
        self.costmap_widget.canvas.freeze = False
        self.costmap_widget.canvas.on_map_update()
示例#3
0
class BrushfireAlgorithmWidget(AlgorithmWidget):
    def __init__(self, parent=None, colorbar=False):
        self.colorbar = colorbar
        AlgorithmWidget.__init__(self, "Brushfire Algorithm", parent)
        self.pack_buttons()

    def setup_algorithm(self):
        """Sets up the algorithm"""
        self.costmap = Costmap2D(DEFAULT_WIDTH,
                                 DEFAULT_HEIGHT,
                                 resolution=DEFAULT_RESOLUTION)
        Obstacle(3, 3, 3, 3).draw(self.costmap)
        Obstacle(9, 5, 3, 3).draw(self.costmap)
        Obstacle(16, 4, 3, 3).draw(self.costmap)

        self.costmap_widget = Costmap2DWidget(self.costmap,
                                              parent=self,
                                              show_goal=False,
                                              show_colorbar=self.colorbar)
        self.costmap_widget.canvas.show_start = True
        self.costmap_widget.canvas.show_goal = False
        self.be = BrushfireExpansion(self.costmap)
        temp = self.costmap_widget.canvas.start_coord
        self.start_coord = (floor(temp[0] + 0.5), floor(temp[1] + 0.5))
        self.be.set_ignition_cells([self.start_coord])

    def step_solution(self):
        """Steps the solution"""
        return self.be.step_solution()

    def reset_algorithm(self):
        """Resets the algorithm"""
        self.costmap_widget.canvas.freeze = True
        self.costmap[:] = 0.0
        Obstacle(3, 3, 3, 3).draw(self.costmap)
        Obstacle(9, 5, 3, 3).draw(self.costmap)
        Obstacle(16, 4, 3, 3).draw(self.costmap)

        self.be = BrushfireExpansion(self.costmap)
        temp = self.costmap_widget.canvas.start_coord
        self.start_coord = (floor(temp[0] + 0.5), floor(temp[1] + 0.5))
        self.be.set_ignition_cells([self.start_coord])
        self.costmap_widget.canvas.freeze = False
        self.costmap_widget.canvas.on_map_update()
示例#4
0
    def setup_algorithm(self):
        """Sets up the algorithm"""
        self.costmap = Costmap2D(DEFAULT_WIDTH,
                                 DEFAULT_HEIGHT,
                                 resolution=DEFAULT_RESOLUTION)
        Obstacle(3, 3, 3, 3).draw(self.costmap)
        Obstacle(9, 5, 3, 3).draw(self.costmap)
        Obstacle(16, 4, 3, 3).draw(self.costmap)

        self.costmap_widget = Costmap2DWidget(self.costmap,
                                              parent=self,
                                              show_goal=False,
                                              show_colorbar=self.colorbar)
        self.costmap_widget.canvas.show_start = True
        self.costmap_widget.canvas.show_goal = False
        self.be = BrushfireExpansion(self.costmap)
        temp = self.costmap_widget.canvas.start_coord
        self.start_coord = (floor(temp[0] + 0.5), floor(temp[1] + 0.5))
        self.be.set_ignition_cells([self.start_coord])
示例#5
0
文件: hw4.py 项目: ashgti/elect6350
class BrushfireAlgorithmWidget(AlgorithmWidget):
    def __init__(self, parent = None, colorbar = False):
        self.colorbar = colorbar
        AlgorithmWidget.__init__(self, "Brushfire Algorithm", parent)
        self.pack_buttons()
    
    def setup_algorithm(self):
        """Sets up the algorithm"""
        self.costmap = Costmap2D(DEFAULT_WIDTH, DEFAULT_HEIGHT, resolution=DEFAULT_RESOLUTION)
        Obstacle(3,3,3,3).draw(self.costmap)
        Obstacle(9,5,3,3).draw(self.costmap)
        Obstacle(16,4,3,3).draw(self.costmap)
        
        self.costmap_widget = Costmap2DWidget(self.costmap, parent = self, show_goal = False,
                                                show_colorbar = self.colorbar)
        self.costmap_widget.canvas.show_start = True
        self.costmap_widget.canvas.show_goal = False
        self.be = BrushfireExpansion(self.costmap)
        temp = self.costmap_widget.canvas.start_coord
        self.start_coord = (floor(temp[0]+0.5), floor(temp[1]+0.5))
        self.be.set_ignition_cells([self.start_coord])
    
    def step_solution(self):
        """Steps the solution"""
        return self.be.step_solution()
    
    def reset_algorithm(self):
        """Resets the algorithm"""
        self.costmap_widget.canvas.freeze = True
        self.costmap[:] = 0.0
        Obstacle(3,3,3,3).draw(self.costmap)
        Obstacle(9,5,3,3).draw(self.costmap)
        Obstacle(16,4,3,3).draw(self.costmap)
        
        self.be = BrushfireExpansion(self.costmap)
        temp = self.costmap_widget.canvas.start_coord
        self.start_coord = (floor(temp[0]+0.5), floor(temp[1]+0.5))
        self.be.set_ignition_cells([self.start_coord])
        self.costmap_widget.canvas.freeze = False
        self.costmap_widget.canvas.on_map_update()
示例#6
0
文件: hw4.py 项目: ashgti/elect6350
 def reset_algorithm(self):
     """Resets the algorithm"""
     self.costmap_widget.canvas.freeze = True
     self.costmap[:] = 0.0
     Obstacle(3,3,3,3).draw(self.costmap)
     Obstacle(9,5,3,3).draw(self.costmap)
     Obstacle(16,4,3,3).draw(self.costmap)
     
     self.be = BrushfireExpansion(self.costmap)
     temp = self.costmap_widget.canvas.start_coord
     self.start_coord = (floor(temp[0]+0.5), floor(temp[1]+0.5))
     self.be.set_ignition_cells([self.start_coord])
     self.costmap_widget.canvas.freeze = False
     self.costmap_widget.canvas.on_map_update()
示例#7
0
文件: hw4.py 项目: ashgti/elect6350
 def setup_algorithm(self):
     """Sets up the algorithm"""
     self.costmap = Costmap2D(DEFAULT_WIDTH, DEFAULT_HEIGHT, resolution=DEFAULT_RESOLUTION)
     Obstacle(3,3,3,3).draw(self.costmap)
     Obstacle(9,5,3,3).draw(self.costmap)
     Obstacle(16,4,3,3).draw(self.costmap)
     
     self.costmap_widget = Costmap2DWidget(self.costmap, parent = self, show_goal = False,
                                             show_colorbar = self.colorbar)
     self.costmap_widget.canvas.show_start = True
     self.costmap_widget.canvas.show_goal = False
     self.be = BrushfireExpansion(self.costmap)
     temp = self.costmap_widget.canvas.start_coord
     self.start_coord = (floor(temp[0]+0.5), floor(temp[1]+0.5))
     self.be.set_ignition_cells([self.start_coord])
示例#8
0
 def __init__(self, costmap):
     BrushfireExpansion.__init__(self, costmap)
     self.set_ignition_cells(self.get_boundry_cells())
示例#9
0
 def solve(self):
     """Solves the voronoi algorithm"""
     BrushfireExpansion.solve(self)