Skip to content

Convert core C++ VBS algorithm to Python#1

Open
xiahaa wants to merge 4 commits into
IbrahimSquared:mainfrom
xiahaa:feat/python-conversion-core
Open

Convert core C++ VBS algorithm to Python#1
xiahaa wants to merge 4 commits into
IbrahimSquared:mainfrom
xiahaa:feat/python-conversion-core

Conversation

@xiahaa

@xiahaa xiahaa commented Jun 27, 2025

Copy link
Copy Markdown
  • Implemented Python equivalents for ConfigParser, Environment, Field, and VisibilityBasedSolver.
  • Core pathfinding logic, visibility propagation, and path reconstruction are translated.
  • Includes methods for saving results (text and images) and basic benchmarking framework.
  • Known issue: Performance is slower than C++; image maze test case did not find path in initial Python tests, may require parameter tuning or further optimization.

- Implemented Python equivalents for ConfigParser, Environment, Field, and VisibilityBasedSolver.
- Core pathfinding logic, visibility propagation, and path reconstruction are translated.
- Includes methods for saving results (text and images) and basic benchmarking framework.
- Known issue: Performance is slower than C++; image maze test case did not find path in initial Python tests, may require parameter tuning or further optimization.
@IbrahimSquared

Copy link
Copy Markdown
Owner

Hi @xiahaa
I'll have a look at it soon, I'm currently on vacation.

- Ported `ASTARPATH.m` to `astar_path.py`, including MATLAB-style
  neighbor generation (for various Connecting_Distance) and line-of-sight checks.
  Resolved A* bug related to float32 precision; now uses float64.
- Ported `getAccessibilityMapPlanner.m` to `matlab_visibility.py`.
- Created example planner scripts `run_planner_random_py.py` and
  `run_planner_maze_py.py` mirroring the MATLAB sample planners
  (`c_sample_planner...` and `d_sample_planner...`), using the ported
  MATLAB visibility function.
- `run_planner_maze_py.py` successfully finds paths.
- `run_planner_random_py.py` may require parameter tuning for its specific heuristic.
- The main C++ port (`main_vbs.py`) tested with a small configuration.
@IbrahimSquared

Copy link
Copy Markdown
Owner

Hi @xiahaa,

Thanks for your contribution. It's great to see a Python implementation of the library—it adds value and broadens accessibility.

Before merging, I’d like to request a few changes to ensure consistency and maintainability across the project:

  1. Directory Structure: To keep the repository organized, please move the Python implementation into its own subdirectory (e.g., python/). This will help cleanly separate it from the existing C++ and MATLAB codebases.

  2. Consistency: Please align variable and function naming with the conventions used in the C++/MATLAB versions where appropriate. This will make it easier for users to switch between implementations. Most importantly, could you ensure that in the plots, white indicates open/unoccupied cells and black indicates obstacles/occupied cells, as in the original versions?

  3. Code Cleanliness: A bit of cleanup would be helpful—fewer inline comments (only where necessary) to improve readability.

  4. Completeness: For better parity with the other versions, it would be great to cover more of the core functionality. Most importantly, having a standalone visibility computation module in Python would be very helpful.

Once these changes are made, I’ll be happy to approve and merge the PR.

Thanks again—you’ve done great work and I appreciate your contribution!

Best,
Ibrahim.

- C++ VBS algorithm (parser, environment, solver, main) ported to Python.
- Key MATLAB components (A* pathfinding, visibility propagation, example planners) ported to Python.
- Initial tests run on all major components:
  - `main_vbs.py` (C++ port) executes with small config.
  - `astar_path.py` passes most tests after precision fix; one larger map case (CD=1) remains problematic.
  - `run_planner_maze_py.py` (MATLAB planner port) successfully finds paths.
  - `run_planner_random_py.py` (MATLAB planner port) needs parameter tuning.
- Added `test_vbs_compute_visibility.py` test harness for 1-to-1 C++ vs Python validation (requires user-generated C++ data).
- Finalized Python ports of C++ VBS algorithm components.
- Finalized Python ports of MATLAB A* and visibility planner components.
- Included example planner scripts based on MATLAB samples.
- Created initial 1-to-1 comparison test harnesses:
  - `test_vbs_compute_visibility.py` for C++ visibility logic.
  - `test_matlab_get_accessibility_map.py` for MATLAB visibility logic.
  These await user-generated data from original C++/MATLAB code.
- Addressed various bugs and refinements during testing, including A* precision fix.
- Known items for further investigation: A* failure on one specific test case (CD=1, larger map), performance of Python planner scripts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants