|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.base.agent.module.AgentModule<AGENT> cz.cuni.amis.pogamut.base.agent.module.SensorModule<IGhostAgent> cz.cuni.amis.pogamut.ut2004.agent.navigation.floydwarshall.FloydWarshallMap
public class FloydWarshallMap
Private map using Floyd-Warshall for path-finding.
It should be initialized upon receiving MapPointListObtained
event.
It precomputes all the paths inside the environment using Floyd-Warshall
algorithm (O(n^3)). Use getReachable(), getDistance(), getPath() to obtain
the info about the path.
If needed you may call refreshPathMatrix()
to recompute Floyd-Warshall. Especially useful
if you're using NavigationGraphBuilder
to modify the underlying navpoints/edges.
Based upon the implementation from Martin Krulis with his kind consent - Thank you!
NOTE: requires O(navpoints.size^3) of memory ~ which is 10000^3 at max for UT2004 (usually the biggest maps have 3000 navpoints max, but small maps, e.g., DM-1on1-Albatross has 200 navpoints).
Nested Class Summary | |
---|---|
static class |
FloydWarshallMap.PathMatrixNode
|
Field Summary | |
---|---|
static int |
BAD_EDGE_FLAG
Flag mask representing unusable edge. |
protected int |
badEdgeFlag
Prohibited edges. |
protected java.util.Map<java.lang.Integer,NavPoint> |
indicesNavPoints
Mapping indices to nav points. |
protected java.util.Map<UnrealId,java.lang.Integer> |
navPointIndices
Hash table converting navPoint IDs to our own indices. |
protected FloydWarshallMap.PathMatrixNode[][] |
pathMatrix
|
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.SensorModule |
---|
worldView |
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule |
---|
agent, controller, eventBus, log |
Constructor Summary | |
---|---|
FloydWarshallMap(IGhostAgent bot)
|
|
FloydWarshallMap(IGhostAgent bot,
int badEdgeFlag,
java.util.logging.Logger log)
|
|
FloydWarshallMap(IGhostAgent bot,
java.util.logging.Logger log)
|
Method Summary | |
---|---|
boolean |
checkLink(NavPointNeighbourLink edge)
Checks whether the edge is usable. |
IPathFuture<NavPoint> |
computePath(NavPoint from,
NavPoint to)
Returns a future where the path planner will set the result of its computation. |
float |
getDistance(NavPoint from,
NavPoint to)
Calculate's distance between two nav points (using pathfinding). |
java.util.List<NavPoint> |
getPath(NavPoint from,
NavPoint to)
Returns path between navpoints 'from' -> 'to'. |
protected FloydWarshallMap.PathMatrixNode |
getPathMatrixNode(NavPoint np1,
NavPoint np2)
|
protected void |
performFloydWarshall(java.util.List<NavPoint> navPoints)
|
protected void |
performFloydWarshall(MapPointListObtained map)
|
boolean |
reachable(NavPoint from,
NavPoint to)
Whether navpoint 'to' is reachable from the navpoint 'from'. |
void |
refreshPathMatrix()
Force FloydWarshall to run again, useful if you modify navpoints using NavigationGraphBuilder . |
java.lang.String |
toString()
|
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule |
---|
cleanUp, getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, reset, resume, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int BAD_EDGE_FLAG
protected int badEdgeFlag
protected java.util.Map<UnrealId,java.lang.Integer> navPointIndices
protected java.util.Map<java.lang.Integer,NavPoint> indicesNavPoints
WILL BE NULL AFTER CONSTRUCTION! SERVES AS A TEMPORARY "GLOBAL VARIABLE" DURING FLOYD-WARSHALL COMPUTATION AND PATH RECONSTRUCTION.
protected FloydWarshallMap.PathMatrixNode[][] pathMatrix
Constructor Detail |
---|
public FloydWarshallMap(IGhostAgent bot)
public FloydWarshallMap(IGhostAgent bot, java.util.logging.Logger log)
public FloydWarshallMap(IGhostAgent bot, int badEdgeFlag, java.util.logging.Logger log)
Method Detail |
---|
public void refreshPathMatrix()
NavigationGraphBuilder
.
protected void performFloydWarshall(MapPointListObtained map)
protected void performFloydWarshall(java.util.List<NavPoint> navPoints)
public boolean checkLink(NavPointNeighbourLink edge)
from
- Starting nav point.edge
- NeighNav object representing the edge.
protected FloydWarshallMap.PathMatrixNode getPathMatrixNode(NavPoint np1, NavPoint np2)
public boolean reachable(NavPoint from, NavPoint to)
from
- to
-
public float getDistance(NavPoint from, NavPoint to)
public java.util.List<NavPoint> getPath(NavPoint from, NavPoint to)
from
- to
-
public java.lang.String toString()
toString
in class AgentModule<IGhostAgent>
public IPathFuture<NavPoint> computePath(NavPoint from, NavPoint to)
IPathPlanner
Note that the IPathFuture
might already contain the path (i.e., the returned path was
computed inside this method or it was a precomputed result). Always examine status of the future before
attaching listeners to it.
computePath
in interface IPathPlanner<NavPoint>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |