Ejemplo n.º 1
0
  def __init__(self, mapMsg, graphFile, source, target):

    # Setup member variables
    self.source = source
    self.target = target
    self.manager = ObstacleManager(mapMsg)

    # Generate the Graph on the fly if required
    self.radius = 100
    if graphFile is None:
      n = 500
      bases = [2,3,5] # Should be prime numbers
      lower = [0,0,0] # The lowest possible values for the config
      upper = [64,75,2*numpy.pi] # The highest possible values for the config

      G = GraphGenerator.euclidean_halton_graph(n, self.radius, bases, lower, upper, source, target, mapMsg) # Create the graph
      nx.write_graphml(G, "haltonGraph.graphml") # Save the graph
      self.graph = nx.read_graphml("haltonGraph.graphml") # Read the graph (that we just saved, probably not necessary)

    else:
      # Check if graph file exists
      print(os.path.isfile(graphFile))
      if not os.path.isfile(graphFile):
        print "ERROR: graph file not found!"
        quit()
      self.graph = nx.read_graphml(graphFile) # Load the graph
      print "graph loaded"
      
      # Insert source and target if provided
      if source is not None:
        GraphGenerator.insert_vertices(self.graph, [source], self.radius)

      if target is not None:
        GraphGenerator.insert_vertices(self.graph, [target], self.radius)
Ejemplo n.º 2
0
    def __init__(self, mapMsg, graphFile, source, target):

        # Setup member variables
        self.source = source
        self.target = target
        self.manager = ObstacleManager(mapMsg)

        # Generate the Graph on the fly if required
        self.radius = 100
        if graphFile is None:
            n = 500
            bases = [2, 3, 5]
            lower = [0, 0, 0]
            upper = [64, 75, 2 * numpy.pi]

            G = GraphGenerator.euclidean_halton_graph(n, self.radius, bases,
                                                      lower, upper, source,
                                                      target, mapMsg)
            nx.write_graphml(G, "haltonGraph.graphml")
            self.graph = nx.read_graphml("haltonGraph.graphml")

        else:
            # Check if graph file exists
            if not os.path.isfile(graphFile):
                print "ERROR: map file not found!"
                quit()
            self.graph = nx.read_graphml(graphFile)

            if source is not None:
                GraphGenerator.insert_vertices(self.graph, [source],
                                               self.radius)

            if target is not None:
                GraphGenerator.insert_vertices(self.graph, [target],
                                               self.radius)