This little library implements the potential avoidance algorithm using numpy and matplotlib. You can create easily and quickly your field with many types of objects. Computing a path and display it are also available on this release.
An example with complet field displaying on matplotlib.
You need first to create your field and add some obstacles.
# Create field obj
field = Field()
# Add field limit
field.add_object(LimitObstacle( 2000,3000 ))
# Add your destination with a PointObstacle
# Don't forget to setup your force negative to attract.
field.add_object(Point(*target,funct_list["exp"](alpha=0.001,beta=-20)))
# Add obstacle on the robot path
poly = [ (1700,2000), (950,1800),(1100,1500),(1300,1300),]
field.add_object(Polygon(poly))
# Then, compute the path
path, _ = compute(field, (1100,90),(1000, 2680), max_it=1000)
# And finaly plot it
plot_scalar(field, (0,2000),(0,3000), path=path)
Result :
You can find 3 basic object model introduced just bellow.
The most basic object, it's only a punctual source. You can use it as a destination in your field.
![]() |
![]() |
Polygon object can be used as an obstacle on your field.
![]() |
![]() |
This object can help you to limit your robot's playground.
![]() |
![]() |
Three functions are available on this lib. Logarithm, Linear, and Exponential can be found at package Field.funct . You can see them on the following graph.
Just use the setup script available on the root. You just have to run it like this :
python3 setup.py install --user