java.lang.Object
me.nabdev.pathfinding.structures.Map

public class Map extends Object
Represents all the obstacles on the map as well as the visibility graph that the robot can use to navigate.
  • Field Details

    • fieldx

      public final double fieldx
      The x dimension of the field (meters)
    • fieldy

      public final double fieldy
      The y dimension of the field (meters)
    • originx

      public static final double originx
      The 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 originy
      The 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 eps
      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.
      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

      public 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.
      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

      public void calculateDynamicVisibilityGraph(ArrayList<Vertex> additionalVertices, boolean reset)
      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

      public ArrayList<Vertex> getPathVertices()
      Get the uninflated vertices of the obstacles.
      Returns:
      The vertices of the obstacles.
    • getPathVerticesStatic

      public ArrayList<Vertex> getPathVerticesStatic()
      Get the inflated vertices of the obstacles.
      Returns:
      The inflated vertices of the obstacles.
    • getNeighbors

      public ArrayList<Edge> getNeighbors()
      Get the neighbors of the vertices of the static obstacles.
      Returns:
      The neighbors of the vertices of the static obstacles.
    • getNeighborsStatic

      public ArrayList<Edge> getNeighborsStatic()
      Get the neighbors of the dynamic vertices.
      Returns:
      The neighbors of the dynamic vertices.
    • getObstacles

      public ArrayList<Obstacle> getObstacles()
      Get the obstacles for the current map
      Returns:
      the obstacles of the current map
    • getValidObstacleEdges

      public ArrayList<Edge> getValidObstacleEdges()
      Get all obstacle edges which could actually obstruct the robot
      Returns:
      all obstacle edges that could obstruct the robot