Tuesday, September 1, 2026

 PDE patterns:

1. Risk Field PDE for Drone Path Planning (Porous Media / Eikonal Type)

This mirrors the NASA JPL porous media PDE approach: obstacles and risk are encoded as a spatial field, and the drone follows the gradient of the PDE solution.

python

import numpy as np

import matplotlib.pyplot as plt


# Domain

nx, ny = 200, 200

risk = np.zeros((nx, ny))


# Example obstacles encoded as high-risk zones

risk[60:120, 80:120] = 10.0 # rectangular obstacle

risk[150:170, 30:50] = 20.0 # another obstacle


# PDE parameters

dx = dy = 1.0

phi = np.zeros_like(risk) # potential field

phi[0, :] = 1.0 # boundary condition: source

phi[-1, :] = 0.0 # boundary condition: goal


# Solve a diffusion-like PDE: ∇·( (1+risk) ∇phi ) = 0

for _ in range(5000):

    phi_xx = (np.roll(phi, -1, axis=0) - 2*phi + np.roll(phi, 1, axis=0)) / dx**2

    phi_yy = (np.roll(phi, -1, axis=1) - 2*phi + np.roll(phi, 1, axis=1)) / dy**2

    phi = phi + 0.1 * (phi_xx + phi_yy) / (1 + risk)


# Extract a path by gradient descent on phi

path = []

x, y = 10, 10

for _ in range(500):

    path.append((x, y))

    # follow negative gradient

    gx = phi[x+1, y] - phi[x-1, y]

    gy = phi[x, y+1] - phi[x, y-1]

    x -= int(np.sign(gx))

    y -= int(np.sign(gy))

    if x <= 1 or y <= 1 or x >= nx-2 or y >= ny-2:

        break


# Plot

plt.imshow(phi.T, origin='lower', cmap='viridis')

px, py = zip(*path)

plt.plot(px, py, 'r-', linewidth=2)

plt.title("PDE-Based Risk Field and Extracted Drone Path")

plt.show()


What this represents: A drone navigating a continuous risk field (obstacles, no fly zones). The PDE solution acts like a “fluid potential,” and the drone follows streamlines—exactly the porous media analogy used in multi UAV PDE papers.


No comments:

Post a Comment