public class DijkstraPathFinder extends java.lang.Object implements PathFinder
Modifier and Type | Class and Description |
---|---|
protected class |
DijkstraPathFinder.Node |
Modifier and Type | Field and Description |
---|---|
protected boolean |
_blocked
set by segmentBlocked() used by findPath()
|
protected java.util.ArrayList<DijkstraPathFinder.Node> |
_candidate
the set of nodes that are candidates for being in the shortest path, but
whose distance from the start node is not yet known
|
protected int |
_count |
protected java.util.ArrayList<Line> |
_map
The map of the obstacles
|
protected java.util.ArrayList<DijkstraPathFinder.Node> |
_reached
the set of nodes that are candidates for being in the shortest path, and
whose distance from the start node is known
|
Constructor and Description |
---|
DijkstraPathFinder(LineMap map) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(WaypointListener wpl) |
Path |
findRoute(Pose start,
Waypoint finish)
Finds the shortest path from start to finish using the map (or collection of lines)
in the constructor.
|
Path |
findRoute(Pose start,
Waypoint finish,
LineMap theMap)
Finds the shortest path from start to finish using the map (or collection of lines)
in the constructor.
|
protected DijkstraPathFinder.Node |
getBest(DijkstraPathFinder.Node currentDestination)
Helper method for findPath()
returns the node in the Reached set, whose distance from the start node plus its straight line distance to the destination is the minimum. |
int |
getIterationCount() |
protected java.util.ArrayList<Line> |
getMap() |
int |
getNodeCount() |
protected Path |
getRoute(DijkstraPathFinder.Node destination)
helper method for find path()
calculates the route backtracking through predecessor chain |
protected boolean |
inCandidateSet(DijkstraPathFinder.Node aNode)
helper method for findPath; check if aNode is in the set of candidate nodes
|
protected void |
initialize() |
protected boolean |
inReachedSet(DijkstraPathFinder.Node aNode)
helper method for findPath; check if aNode is in the set of reached nodes
|
void |
lengthenLines(float delta)
lengthens all the lines in the map by delta at each end
|
protected boolean |
segmentBlocked(DijkstraPathFinder.Node from,
DijkstraPathFinder.Node theDest)
helper method for findPath().
|
void |
setMap(java.util.ArrayList<Line> theMap) |
void |
setMap(LineMap theMap) |
void |
startPathFinding(Pose start,
Waypoint end) |
protected int _count
protected boolean _blocked
protected java.util.ArrayList<DijkstraPathFinder.Node> _candidate
protected java.util.ArrayList<DijkstraPathFinder.Node> _reached
protected java.util.ArrayList<Line> _map
public DijkstraPathFinder(LineMap map)
public Path findRoute(Pose start, Waypoint finish) throws DestinationUnreachableException
findRoute
in interface PathFinder
start
- the initial robot posefinish
- the final robot locationDestinationUnreachableException
- if, for example, you nave not called setMap();public Path findRoute(Pose start, Waypoint finish, LineMap theMap) throws DestinationUnreachableException
start
- the initial robot posefinish
- the final robot locationtheMap
- the LineMap of obstaclesDestinationUnreachableException
- if, for example, you nave not called setMap();public void setMap(java.util.ArrayList<Line> theMap)
public void setMap(LineMap theMap)
public void lengthenLines(float delta)
delta
- added to each end of each lineprotected void initialize()
protected boolean segmentBlocked(DijkstraPathFinder.Node from, DijkstraPathFinder.Node theDest)
from
- the beginning of the line segmenttheDest
- the end of the line segmentprotected DijkstraPathFinder.Node getBest(DijkstraPathFinder.Node currentDestination)
currentDestination
- : the current destination node, (in the Candidate set)protected boolean inReachedSet(DijkstraPathFinder.Node aNode)
aNode
- protected boolean inCandidateSet(DijkstraPathFinder.Node aNode)
aNode
- protected Path getRoute(DijkstraPathFinder.Node destination)
destination
- protected java.util.ArrayList<Line> getMap()
public int getIterationCount()
public int getNodeCount()
public void addListener(WaypointListener wpl)
addListener
in interface PathFinder
public void startPathFinding(Pose start, Waypoint end)
startPathFinding
in interface PathFinder