A Python package for obstacle detection in voxel maps using Open3D and raycasting
Project description
Obstacle Detection
Obstacle Detection is a Python package designed to facilitate obstacle detection in voxelized environments using raycasting techniques. It leverages Open3D for 3D geometry processing and is optimized for robotics and visualization tasks.
Features
- Voxelized Mesh Handling: Import and process 3D voxel maps for obstacle detection.
- Raycasting: Cast rays in customizable directions to detect obstacles.
- Visualization: Render voxel maps, raycasting results, and directional vectors using Open3D.
- Dominant Direction Analysis: Analyze the dominant direction in a voxel map for robot orientation.
- Flexible APIs: Integrate with other robotics or visualization frameworks.
Installation
Install the package via pip:
pip install obstacle-detection
## Dependencies
The package relies on the following dependencies:
- `numpy`
- `open3d`
- `scikit-learn`
- `urdfpy`
All required dependencies will be installed automatically when using pip install.
Usage
Example 1: Visualizing a Voxel Map
from voxel_object_detection.Obstacle_Detection import Obstacle_Detection
od = Obstacle_Detection()
od.show_voxel_map(file_path="./examples/data/voxel_map_example.json")
Example 2: Detect Obstacles in a Given Direction
from voxel_object_detection.Obstacle_Detection import Obstacle_Detection
max_distance = 30
num_rays = 100
angle_range = 30
threshold = 0.1
file_path = "./examples/data/voxel_map_example.json"
move_direction = [1, 0, 0]
od = Obstacle_Detection(
max_distance=max_distance,
num_rays=num_rays,
angle_range=angle_range
)
voxel_map = od.load_voxel_map_from_json(file_path)
scene, dominant_direction = od.preprocess_voxel_map(voxel_map, render=False)
path_is_clear = od.is_path_clear(
dominant_direction=dominant_direction,
relative_walking_vector=move_direction,
scene=scene,
threshold=threshold,
)
if path_is_clear:
print("Path is clear!")
else:
print("Obstacle detected!")
API Reference
ObstacleDetection
Methods
-
__init__(voxel_map_path: str)- Initialize the class with a JSON voxel map file.
-
visualize_voxel_map()- Render the voxel map and raycasting results using Open3D.
-
check_clear_path(center: list, dominant_direction: list, relative_direction: list, max_distance: float) -> bool- Check if there is a clear path in a given direction, relative to the dominant direction.
Contributing
Contributions are welcome! Please fork the repository and submit a pull request for any features, fixes, or improvements.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
- Open3D: For powerful 3D visualization and raycasting tools.
- NumPy: For numerical computations.
- Scikit-learn: For PCA and other analysis utilities.
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 voxel-obstacle-detection-0.1.0.tar.gz.
File metadata
- Download URL: voxel-obstacle-detection-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2faf7de4fcf4da8c06b7401f8b735d81c5bd2ea2530fef82e3c4a2e401007ff7
|
|
| MD5 |
c40d51575d5ff9683a35753dcbc22067
|
|
| BLAKE2b-256 |
57b889fdea12b43c590f8d8792a8c67b16297f26efb7785819a9a0ca42a443c2
|
File details
Details for the file voxel_obstacle_detection-0.1.0-py3-none-any.whl.
File metadata
- Download URL: voxel_obstacle_detection-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80ebdc1d0d75af2d19a7cbc8c1082a8ea0e1d051e0f957eb17bc1cb7fe108ab6
|
|
| MD5 |
08f3de3c337637420bc332e29eb5cb4c
|
|
| BLAKE2b-256 |
14dcb7c9e4ac78f4a6f5a2f7d0074bc2c9d7c0ca03dc9c02c2b86b9c0993b567
|