|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lejos.robotics.pathfinding.ShortestPathFinder
public class ShortestPathFinder
This class calculates the shortest path from a starting point to a finish point. while avoiding obstacles that are represented as a set of straight lines. The path passes through the end points of some of these lines, which is where the changes of direction occur. Since the robot is not point, the lines representing the obstacles should be lengthened so the actual robot will miss the actual obstacles. Use the lengthenLines() method to do this. Uses modification of the A* algorithm,which is a a variant of the Dijkstra shortest path algorithm. This variant adds nodes needed. It uses the Node inner class for its internal representation of points.
Nested Class Summary | |
---|---|
class |
ShortestPathFinder.Node
|
Constructor Summary | |
---|---|
ShortestPathFinder(LineMap map)
|
Method Summary | |
---|---|
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 ( collection of lines) in the constructor. |
int |
getIterationCount()
|
ArrayList<Line> |
getMap()
|
int |
getNodeCount()
|
boolean |
inCandidateSet(ShortestPathFinder.Node aNode)
helper method for findPath; check if aNode is in the set of candidate nodes |
void |
lengthenLines(float delta)
lengthens all the lines in the map by delta at each end |
void |
setDebug(boolean yes)
|
void |
setMap(ArrayList<Line> theMap)
|
void |
setMap(LineMap theMap)
|
void |
startPathFinding(Pose start,
Waypoint end)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ShortestPathFinder(LineMap map)
Method Detail |
---|
public Path findRoute(Pose start, Waypoint finish) throws DestinationUnreachableException
findRoute
in interface PathFinder
start
- the initial robot posefinish
- the final robot location
DestinationUnreachableException
- 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 obstacles
DestinationUnreachableException
- if, for example, you nave not called setMap();public boolean inCandidateSet(ShortestPathFinder.Node aNode)
aNode
-
public void setMap(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 linepublic 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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |