Coder Social home page Coder Social logo

astar-search's Introduction

astar-search

A* Search Algorithm, implemented in Python 3.


Usage

Simply clone this repository to start testing out the python scripts.

The command to run this script is as such:

python3 test.py -i [INPUT FILE PATH] -o [OUTPUT FILE PATH] -x [CARTESIAN X-COORDINATE OF GOAL] -y [CARTESIAN Y-COORDINATE OF GOAL]

E.g.

python3 test.py -i input.png -o output.png -x 0 -y 600

This will create an output.png that will contain the path generated.


Tweakable Parameters

As this code was meant to be used for a specific project, the algorithm process and the parameters have been pre-set according to our project specifications. The image is converted to a grid map with a Cartesian co-ordinate system, whose origin is considered to be at the center-bottom of the image prior to adding the padding, i.e. for a given image, the origin is located at ((width - 1) / 2, height - padding - 0.5). Regardless, by tweaking some of the parameters (including the starting point of the algorithm), the algorithm can be generalized without issues.

First, in Map.py, there are three parameters: OBS_THRESHOLD, PADDING, and DIM_RESIZE.

OBS_THRESHOLD is essentially the minimum distance (in pixels) from any obstacle (or wall) to the optimal path calculated - for example, if you set this value to 0, the path may end up hugging the walls or the obstacles. On the other hand, if this value is set to 5, then all nodes in the path will be at least 5 pixels away from any obstacles and/or walls. It is recommended to set it to a value that would allow an agent to comfortably avoid the obstacles while ensuring that a path can still be found.

PADDING is the number of white pixels added to all four sides of the image. This was added as an assumption that an unseen environment is traversable without any obstacles, and is specific to the abovementioned project; the value may be set to 0 if this assumption is not necessary.

DIM_RESIZE is simply the dimensions that the image will be resized to.

Next, in astar.py, there are three parameters: GOAL_THRESHOLD, STEP, and START.

GOAL_THRESHOLD is essentially the minimum distance (in pixels) that the end of the path can be from the given goal. The larger the value, the less strict the conditions for reaching the goal will be. Setting this to 0 will mean that the algorithm will try to find a path that can reach the exact values of the given goal coordinates.

STEP is the distance (in pixels) between each node, and START is the starting point (in cartesian values).

astar-search's People

Contributors

lhw-1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.