Ejemplo n.º 1
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
    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
Ejemplo n.º 3
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