Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation Of Astar Path Planning #22

Closed
wants to merge 6 commits into from

Conversation

shantanuparabumd
Copy link

@shantanuparabumd shantanuparabumd commented Jan 21, 2025

PR Description: A* Path Planning Implementation for Autonomous Vehicles

Overview

This PR introduces an A* path planner designed for autonomous vehicle applications. The implementation includes robust grid-based path planning, obstacle handling, and visualization, along with the ability to generate sparse paths for cubic spline interpolation. Below are the key features, considerations, and future enhancements of this project.


Key Features

  1. Grid-Based A* Path Planning:

    • The planner creates a grid representation of the map based on the provided map size (x_lim, y_lim) and resolution.
    • Higher resolution grids enable quicker exploration, while smaller resolution grids capture finer details of the environment.
  2. Obstacle Handling and Clearance:

    • The planner accepts a list of obstacles (with dimensions and rotation) and marks them on the grid.
    • Clearance is calculated by combining the vehicle clearance and obstacle clearance to ensure safe navigation, even though the vehicle is currently modeled as a point object.
  3. Action Set:

    • The planner utilizes an 8-action set, enabling movement in four cardinal directions (up, down, left, right) and diagonals.
    • This is suitable for point-object modeling but will need refinement when transitioning to a car-specific configuration space (C-space).
  4. Visualization:

    • An optional visualization mode displays the grid, exploration process, and reconstructed path.
    • Visual distinctions between free space, clearance, and obstacles are implemented, though the aesthetics (e.g., colors and styles) can be improved.
  5. Efficient Exploration:

    • The use of a min-heap for the open list significantly improves the efficiency of exploration.
  6. Sparse Path Generation:

    • After computing the path, it is sparsified to reduce the number of points while retaining the overall trajectory.
    • The sparse path is compatible with cubic spline interpolation, enabling smooth trajectory generation for vehicles.
  7. Integration with CubicSplineCourse:

    • The sparse path is designed to be fed into the CubicSplineCourse class, which creates a smooth course for the vehicle to follow.

Considerations and Future Enhancements

  1. Improved Motion Model:

    • Replace the current point-object assumption with a car-specific C-space that accounts for the vehicle's dimensions and kinematics.
  2. Action Set Optimization:

    • Update the 8-action set to consider car-specific movements, such as steering constraints, reversing, and turning radii.
  3. Visualization Improvements:

    • Enhance the grid visualization with better color schemes and more detailed representations of obstacles, clearance, and the path.
  4. Animation Speed:

    • While the exploration process is efficient, the animation is slow and can be optimized for faster playback.
  5. Dynamic Obstacles:

    • Extend support for dynamic environments with moving obstacles.

How to Use

  1. Input:

    • Provide the map dimensions (x_lim, y_lim) and resolution.
    • Define obstacles with parameters such as position, dimensions, and rotation.
  2. Path Planning:

    • Execute the A* planner to compute the path, taking into account clearance and obstacles.
  3. Sparse Path Generation:

    • Generate a sparse path from the full path for efficient trajectory planning.
  4. Cubic Spline Integration:

    • Use the sparse path as input to the CubicSplineCourse class to create a smooth course.

Limitations

  • Currently assumes a point-object model for the vehicle.
  • Visualization aesthetics and animation speed need refinement.
  • Not yet optimized for car-specific kinematic constraints.

Conclusion

This implementation provides a foundational A* path planner with efficient exploration, robust obstacle handling, and integration with cubic spline trajectory generation. It serves as a base for further enhancements to address car-specific needs and dynamic environments.

@ShisatoYano ShisatoYano linked an issue Jan 22, 2025 that may be closed by this pull request
@@ -36,6 +36,8 @@ def __init__(self, state, accel_mps2=0.0, yaw_rate_rps=0.0,
[width_m, width_m, -width_m, -width_m, width_m]])
self.array = XYArray(contour)



Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These added two lines are empty, they should be reverted before merging.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pycache file should not be committed. You can add this to .gitignore to ignore.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class includes a grid map construction algorithm simultaneously. This can be divided into the following two algorithm classes.

  1. Binary occupancy grid map construction class with clearances.
  2. A* global path planner class

A grid map base class has already existed in the repository and been used for the existing NDT map construction class. You also can refer to them. And then, it is required to be able to save the constructed map data as an external file like json. I consider that the A* path planner class can plan a global path by importing the saved external map data file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created 2 separate PR's for the other 2 classes.

@@ -0,0 +1,120 @@
"""
ndt_map_construction.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the file name in this header comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This simulation should be divided into the following three simulation files.

  1. Binary occupancy grid map construction simulation file
    A binary occupancy grid map with clearances can be constructed and the map data can be saved and exported as an external file like json or image.

  2. A* global path planning simulation file
    A global path from start to goal can be planned by importing the above map data file. And then, the planned global path data can be saved and exported as an external file like json.

  3. Path tracking simulation file
    The vehicle tracks the above planned global path interpolated with Cubic spline by importing the above path data file.

Please implement these simulation files individually and send me those PRs sequentially from 1 to 3.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created the first 2. For the third one I wasn't sure if it should just have the path tracking or everything together. If the 3rd requires just the path tracking I will make the changes. Every class has it's own way of saving and loading results.

@ShisatoYano
Copy link
Owner

After you completed resolving each conversations, please add those unit test codes refer to the existing test codes finally.

@ShisatoYano ShisatoYano added the enhancement New feature or request label Jan 22, 2025
@ShisatoYano
Copy link
Owner

This PR can not be accepted because should be recreated as multiple new PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implementation of A-Star Algorithm
2 participants