Ejemplo n.º 1
0
    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
    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)
Ejemplo n.º 3
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.º 4
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.º 5
0
 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.º 6
0
 def respawn(self, pos):
     """Respawn powerup."""
     self.pos = pos
     self.pot_field = PotentialField.create(self.game.tilemap.width,
                                            self.game.tilemap.height, pos)
     self.elapsed_lifetime = 0
     self.elapsed_blink = 0
     self.isalive = True
     self.isvisible = True
Ejemplo n.º 7
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_start = False, show_colorbar = self.colorbar)
     self.pf = PotentialField(self.costmap)
Ejemplo n.º 8
0
 def reinit(self, pos, prototype):
     """Reinit powerup."""
     self.pot_field = PotentialField.create(self.game.tilemap.width,
                                            self.game.tilemap.height, pos)
     self.respawn(pos)
     self.tex = prototype['tex']
     self.actions = prototype['actions']
     self.lifetime = prototype.get('lifetime', 100000)
     self.blinkrate = prototype.get('blinkrate', 100000)
     self.startblinkingat = prototype.get('startblinkingat', 100000)
     self.autorespawn = prototype.get('autorespawn', False)