Skip to content

hal.routing.astar

AStar2DRouter

AStar2DRouter(grid, node_expansion_val, edge_expansion_val)

Initialize the router with a 3D grid.

Parameters: grid (np.ndarray): A 3D NumPy array where obstacles (and previously routed paths) are marked (e.g., with 2 or 4).

route

route(start, goal)

Compute and return an optimal path from start to goal using the A* algorithm.

Parameters: start (Tuple[int, int, int]): The starting position. goal (Tuple[int, int, int]): The target position.

Returns: A list of (x, y, z) tuples representing the path from start to goal if one is found, or False if no path exists.

AStar3DRouter

AStar3DRouter(grid)

Initialize the router with a 3D grid.

Parameters: grid (np.ndarray): A 3D NumPy array where obstacles (and previously routed paths) are marked (e.g., with 2 or 4).

route

route(start, goal)

Compute and return an optimal path from start to goal using the A* algorithm.

Parameters: start (Tuple[int, int, int]): The starting position. goal (Tuple[int, int, int]): The target position.

Returns: A list of (x, y, z) tuples representing the path from start to goal if one is found, or False if no path exists.

astar

astar(array, start, goal)

A* on 2D occupancy grid with 4-neighborhood.

Args: array (np.ndarray): 2D grid of cell states. start (tuple[int,int]): Start cell (x, y). goal (tuple[int,int]): Goal cell (x, y).

Returns: list[tuple[int,int]] | bool: Path as list of cells (excluding start), or False if none.

heuristic

heuristic(a, b)

Euclidean distance between 2D points a and b.

heuristic_2d

heuristic_2d(a, b)

Manhattan distance in XY plane.

heuristic_3d

heuristic_3d(a, b)

Manhattan distance in 3D.

heuristic_3d_neighbor

heuristic_3d_neighbor(a, b)

Neighbor step cost in 3D using Manhattan difference.

manhattan_heuristic

manhattan_heuristic(a, b)

Computes the Manhattan distance between two points a and b in 3D. This is the sum of the absolute differences of their coordinates.

Since only axis-aligned moves are allowed, each move changes one coordinate by 1 unit. Therefore, the Manhattan distance is an admissible and consistent heuristic.