public class ShortestPathFinder extends java.lang.Object implements PathFinder
| Modifier and Type | Class and Description |
|---|---|
class |
ShortestPathFinder.Node |
| Modifier and Type | Field and Description |
|---|---|
private java.util.ArrayList<ShortestPathFinder.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.
|
private int |
_count |
private boolean |
_debug |
private ShortestPathFinder.Node |
_destination |
private java.util.ArrayList<Line> |
_map
The map of the obstacles
|
private java.util.ArrayList<ShortestPathFinder.Node> |
_reached
the set of nodes that are candidates for being in the shortest path, and
whose distance from the start node is known
|
private ShortestPathFinder.Node |
_source |
private static float |
BIG |
private java.util.ArrayList<WaypointListener> |
listeners |
| Constructor and Description |
|---|
ShortestPathFinder(LineMap map) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(WaypointListener wpl) |
private Path |
findPath(Point start,
Point finish,
java.util.ArrayList<Line> theMap)
Finds the shortest path between start and finish Points while avoiding
the obstacles represented by lines in the map
|
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 ( collection
of lines) in the constructor.
|
int |
getIterationCount() |
java.util.ArrayList<Line> |
getMap() |
int |
getNodeCount() |
private Path |
getRoute(ShortestPathFinder.Node destination)
helper method for find path()
calculates the route backtracking through predecessor chain |
boolean |
inCandidateSet(ShortestPathFinder.Node aNode)
helper method for findPath; check if aNode is in the set of candidate
nodes
|
private void |
initialize() |
private boolean |
inReachedSet(ShortestPathFinder.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
|
private boolean |
segmentBlocked(ShortestPathFinder.Node from,
ShortestPathFinder.Node theDest)
Helper method for findPath().
|
void |
setDebug(boolean yes) |
void |
setMap(java.util.ArrayList<Line> theMap) |
void |
setMap(LineMap theMap) |
void |
startPathFinding(Pose start,
Waypoint end) |
private java.util.ArrayList<WaypointListener> listeners
private int _count
private static final float BIG
private ShortestPathFinder.Node _destination
private ShortestPathFinder.Node _source
private java.util.ArrayList<ShortestPathFinder.Node> _candidate
private java.util.ArrayList<ShortestPathFinder.Node> _reached
private java.util.ArrayList<Line> _map
private boolean _debug
public ShortestPathFinder(LineMap map)
public Path findRoute(Pose start, Waypoint finish) throws DestinationUnreachableException
findRoute in interface PathFinderstart - 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();private Path findPath(Point start, Point finish, java.util.ArrayList<Line> theMap) throws DestinationUnreachableException
start - : the beginning of the pathfinish - : the destinationtheMap - that contains the obstaclesDestinationUnreachableExceptionprivate boolean segmentBlocked(ShortestPathFinder.Node from, ShortestPathFinder.Node theDest)
from - the beginning of the line segmenttheDest - the end of the line segmentprivate boolean inReachedSet(ShortestPathFinder.Node aNode)
aNode - public boolean inCandidateSet(ShortestPathFinder.Node aNode)
aNode - private Path getRoute(ShortestPathFinder.Node destination)
destination - public void setMap(java.util.ArrayList<Line> theMap)
public void setMap(LineMap theMap)
public void setDebug(boolean yes)
public void lengthenLines(float delta)
delta - added to each end of each lineprivate void initialize()
public java.util.ArrayList<Line> getMap()
public int getIterationCount()
public int getNodeCount()
public void addListener(WaypointListener wpl)
addListener in interface PathFinderpublic void startPathFinding(Pose start, Waypoint end)
startPathFinding in interface PathFinder