def compute_route(self, node_source, source_ori, node_target, target_ori):

        self._previous_node = node_source

        a_star = AStar()
        a_star.init_grid(
            self._map.get_graph_resolution()[0],
            self._map.get_graph_resolution()[1],
            self._map.get_walls_directed(node_source, source_ori, node_target,
                                         target_ori), node_source, node_target)

        route = a_star.solve()

        # JuSt a Corner Case
        # Clean this to avoid having to use this function
        if route is None:
            a_star = AStar()
            a_star.init_grid(self._map.get_graph_resolution()[0],
                             self._map.get_graph_resolution()[1],
                             self._map.get_walls(), node_source, node_target)

            route = a_star.solve()

        self._route = route

        return route
Пример #2
0
    def compute_route(self, node_source, source_ori, node_target, target_ori):

        self._previous_node = node_source

        printing_grid = np.copy(self._map._grid._structure)

        np.set_printoptions(edgeitems=3,
                            infstr='inf',
                            threshold=2**31,
                            linewidth=129)

        a_star = AStar()
        a_star.init_grid(
            self._map.get_graph_resolution()[0],
            self._map.get_graph_resolution()[1],
            self._map.get_walls_directed(node_source, source_ori, node_target,
                                         target_ori), node_source, node_target)

        route = a_star.solve(printing_grid)
        printing_grid[node_source[0], node_source[1]] = 7

        printing_grid[node_target[0], node_target[1]] = 2

        # JuSt a Corner Case
        # Clean this to avoid having to use this function
        if route is None:
            printing_grid = np.copy(self._map._grid._structure)
            # printing_grid[node_target[0], node_target[1]] = 3
            printing_grid[node_source[0], node_source[1]] = 7

            printing_grid[node_target[0], node_target[1]] = 2
            a_star = AStar()
            a_star.init_grid(
                self._map.get_graph_resolution()[0],
                self._map.get_graph_resolution()[1],
                self._map.get_walls_directed(node_source,
                                             source_ori,
                                             node_target,
                                             target_ori,
                                             both_walls=False), node_source,
                node_target)

            route = a_star.solve(printing_grid)

        if route is None:
            print('Impossible to find route, returning previous route')
            return self._route

        self._route = route

        return route
Пример #3
0
    def compute_route(self, node_source, source_ori, node_target, target_ori):

        self._previous_node = node_source

        a_star = AStar()
        a_star.init_grid(self._map.get_graph_resolution()[0],
                         self._map.get_graph_resolution()[1],
                         self._map.get_walls_directed(node_source, source_ori,
                                                      node_target, target_ori), node_source,
                         node_target)

        route = a_star.solve()

        # JuSt a Corner Case
        # Clean this to avoid having to use this function
        if route is None:
            a_star = AStar()
            a_star.init_grid(self._map.get_graph_resolution()[0],
                             self._map.get_graph_resolution()[1], self._map.get_walls(),
                             node_source, node_target)

            route = a_star.solve()

        self._route = route

        return route
Пример #4
0
    def __init__(self, city_name):
        self._map = CarlaMap(city_name)

        self._astar = AStar()

        # Refers to the start position of the previous route computation
        self._previous_node = []

        # The current computed route
        self._route = None
Пример #5
0
    def __init__(self, city_name):

        # These values are fixed for every city.
        self._node_density = 50.0
        self._pixel_density = 0.1643

        self._map = CarlaMap(city_name, self._pixel_density, self._node_density)

        self._astar = AStar()

        # Refers to the start position of the previous route computation
        self._previous_node = []

        # The current computed route
        self._route = None