Implementation of Theta* algorithm
Project description
PyThetaStar
Python implementation of the Theta* algorithm (Daniel, Nash, "Theta star, Any-angle path planning on grids"). This is a modified and simplified single-file adaptation of the implementation found here.
Example of path generated:
Dynamic replanning is allowed by modifying new_blocked_cells which is an input to the theta_star function.
Installation
pip install pythetastar
Basic Usage
import numpy as np
from pythetastar import theta_star
grid = np.array([
[0, 0, 0, 0, 1, 0, 1, 1],
[1, 1, 0, 1, 1, 0, 1, 1],
[0, 1, 0, 0, 1, 0, 0, 1],
[1, 1, 1, 0, 1, 1, 0, 1],
[1, 1, 1, 0, 1, 0, 1, 1],
[0, 0, 1, 0, 1, 0, 1, 1],
[0, 1, 1, 0, 0, 0, 1, 1],
[0, 1, 0, 1, 1, 0, 0, 0]
])
grid_width, grid_height = grid.shape
start = (0, 0)
goal = (grid_width, grid_height)
result_path, node_set, durations, lengths, paths = theta_star(start, goal, grid)
print(result_path)
# output: [[0, 0], [1, 2], [5, 4], [6, 4], [8, 8]]
Plotting:
import matplotlib.pyplot as plt
xs = [n[0] for n in result_path]
ys = [n[1] for n in result_path]
plt.imshow(grid.T, origin='lower', extent=[0, grid_width, 0, grid_height], cmap='cividis') # Transpose aligns rows (axis 0) with y-axis and columns (axis 1) with x-axis.
plt.grid(color='black', linestyle='-', linewidth=0.5)
plt.xticks(range(grid_width))
plt.yticks(range(grid_height))
plt.plot(xs, ys, 'r-')
plt.scatter(xs, ys)
plt.show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pythetastar-0.0.1.tar.gz.
File metadata
- Download URL: pythetastar-0.0.1.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
884068191bee2504d0c4bd42a7c8aa8ef27873681b1720dd409ec632868a8539
|
|
| MD5 |
e82d0b307298bc606e6178b69ea4fbfd
|
|
| BLAKE2b-256 |
42200f91604863343fa85d860bee9930a967cc87e562056d567cdcf8fd63f5bf
|
File details
Details for the file pythetastar-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pythetastar-0.0.1-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aedbaeeef5d02194343465106149c91fda380dd13ef1a29f138a901b2afbc657
|
|
| MD5 |
d9208b463c1ef10f0857369fa6b4ff2e
|
|
| BLAKE2b-256 |
4dfcf98a6e65788f1b456237fd0a8b2f52f91b4f6aa9f377f494354c284eb117
|