Ejemplo n.º 1
0
class PotentialAlgorithmWidget(AlgorithmWidget):
    def __init__(self, parent=None, colorbar = False):
        self.colorbar = colorbar
        AlgorithmWidget.__init__(self, "Potential Field 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_start = False, show_colorbar = self.colorbar)
        self.pf = PotentialField(self.costmap)
    
    def step_solution(self):
        return self.pf.step_solution()
    
    def reset_algorithm(self):
        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.pf = PotentialField(self.costmap)
        self.costmap_widget.canvas.on_map_update()
Ejemplo n.º 2
0
class PotentialAlgorithmWidget(AlgorithmWidget):
    def __init__(self, parent=None, colorbar=False):
        self.colorbar = colorbar
        AlgorithmWidget.__init__(self, "Potential Field 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_start=False,
                                              show_colorbar=self.colorbar)
        self.pf = PotentialField(self.costmap)

    def step_solution(self):
        return self.pf.step_solution()

    def reset_algorithm(self):
        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.pf = PotentialField(self.costmap)
        self.costmap_widget.canvas.on_map_update()