Package me.nabdev.pathfinding.structures
Class Map
java.lang.Object
me.nabdev.pathfinding.structures.Map
Represents all the obstacles on the map as well as the visibility graph that
the robot can use to navigate.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
A small epsilon value that that is used to slightly inflate the path vertices so that points on the same edge can have a valid line of sight.final double
The x dimension of the field (meters)final double
The y dimension of the field (meters)static final double
The x coordinate of the origin of the field (meters) Used to compute if a point is inside of the field bounds.static final double
The y coordinate of the origin of the field (meters) Used to compute if a point is inside of the field bounds. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
calculateDynamicVisibilityGraph
(ArrayList<Vertex> additionalVertices, boolean reset) Calculates the neighbors of the non-static path vertices.calculateStaticNeighbors
(ArrayList<Vertex> vertices, ArrayList<Edge> obsEdges, ArrayList<Vertex> obsVertices) Calculates the neighbors of the static path vertices (regenerates cached visibility graph) Will save the neighbors to the vertices themselves.void
checkPathVertices
(ArrayList<Vertex> vertices, ArrayList<Obstacle> obstacles) Check all obstacle vertices to see if they are outside of field bounds or inside of another obstacle, in which case, mark them to be skipped during visibility graph generation.Get the neighbors of the vertices of the static obstacles.Get the neighbors of the dynamic vertices.Get the obstacles for the current mapGet the uninflated vertices of the obstacles.Get the inflated vertices of the obstacles.Get all obstacle edges which could actually obstruct the robotgetValidObstacleEdges
(ArrayList<Edge> obstacleEdges, ArrayList<Vertex> obstacleVertices) Check all obstacle edges to see if they are completely outside of field bounds, and if they aren't add them to the validObstacleEdges list.void
Regenerates the visibility graph with the current path vertices and obstacles.
-
Field Details
-
fieldx
public final double fieldxThe x dimension of the field (meters) -
fieldy
public final double fieldyThe y dimension of the field (meters) -
originx
public static final double originxThe x coordinate of the origin of the field (meters) Used to compute if a point is inside of the field bounds.- See Also:
-
originy
public static final double originyThe y coordinate of the origin of the field (meters) Used to compute if a point is inside of the field bounds.- See Also:
-
eps
public static final double epsA small epsilon value that that is used to slightly inflate the path vertices so that points on the same edge can have a valid line of sight.- See Also:
-
-
Constructor Details
-
Map
public Map(ArrayList<Obstacle> obs, ArrayList<Vertex> obVertices, ArrayList<Edge> obEdges, double clearance, double fieldx, double fieldy) Create a new map with the given obstacles, vertices, and clearance parameter.- Parameters:
obs
- The obstacles.obVertices
- The vertices of the obstacles.obEdges
- The edges of the obstacles.clearance
- The clearance parameter to inflate the obstacles by.fieldx
- The x dimension of the field (meters)fieldy
- The y dimension of the field (meters)
-
-
Method Details
-
regenerateVisibilityGraph
public void regenerateVisibilityGraph()Regenerates the visibility graph with the current path vertices and obstacles. -
checkPathVertices
Check all obstacle vertices to see if they are outside of field bounds or inside of another obstacle, in which case, mark them to be skipped during visibility graph generation.- Parameters:
vertices
- The vertices to check.obstacles
- The obstacles to check against.
-
getValidObstacleEdges
public ArrayList<Edge> getValidObstacleEdges(ArrayList<Edge> obstacleEdges, ArrayList<Vertex> obstacleVertices) Check all obstacle edges to see if they are completely outside of field bounds, and if they aren't add them to the validObstacleEdges list. This currently only covers some cases, but is good enough for now.- Parameters:
obstacleEdges
- The edges of the obstacles.obstacleVertices
- The vertices of the obstacles.- Returns:
- The edges that are inside of the field bounds.
-
calculateStaticNeighbors
public ArrayList<Edge> calculateStaticNeighbors(ArrayList<Vertex> vertices, ArrayList<Edge> obsEdges, ArrayList<Vertex> obsVertices) Calculates the neighbors of the static path vertices (regenerates cached visibility graph) Will save the neighbors to the vertices themselves.- Parameters:
vertices
- The vertices to calculate the neighbors of.obsEdges
- The edges of the obstacles.obsVertices
- The vertices of the obstacles.- Returns:
- The neighbors of the vertices.
-
calculateDynamicVisibilityGraph
Calculates the neighbors of the non-static path vertices.- Parameters:
additionalVertices
- The vertices to add to the path vertices.reset
- Whether or not to reset the path vertices and neighbors to their static values (For when generating a new path)
-
getPathVertices
Get the uninflated vertices of the obstacles.- Returns:
- The vertices of the obstacles.
-
getPathVerticesStatic
Get the inflated vertices of the obstacles.- Returns:
- The inflated vertices of the obstacles.
-
getNeighbors
Get the neighbors of the vertices of the static obstacles.- Returns:
- The neighbors of the vertices of the static obstacles.
-
getNeighborsStatic
Get the neighbors of the dynamic vertices.- Returns:
- The neighbors of the dynamic vertices.
-
getObstacles
Get the obstacles for the current map- Returns:
- the obstacles of the current map
-
getValidObstacleEdges
Get all obstacle edges which could actually obstruct the robot- Returns:
- all obstacle edges that could obstruct the robot
-