i need some pathfinding and thought "Well i dont need to reinvent the wheel", but i encountered some problems using the DijkstraPathFinder or ShortestPathFinder implementation that ships with lejos 0.9.0.
My Code:
- Code: Select all
//This Map actually represents a ruler on the floor in front of the robot.
//Wanted to stop the robot from driving over the edges of the ruler by adding the vertical Lines, too.
//Without them worked fine - except that the robot drives over the edges of the ruler
LineMap map = new LineMap(new Line[]{new Line(-10, 14, 10,14),new Line(-10, 10, 10, 10),new Line(10,10,10,14),new Line(-10,10,-10,14)},null);
ShortestPathFinder pathfinder = new ShortestPathFinder(map);
pathfinder.lengthenLines(7);//comment this to remove error
Collection<WayPoint> weg = pathfinder.findRoute(new Pose(0,0,0), new WayPoint(0,30));//Exception comes from here.
System.err.println("Found Route...");
produces an Exception:
- Code: Select all
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2772)
at java.util.Arrays.copyOf(Arrays.java:2746)
at java.util.ArrayList.ensureCapacity(ArrayList.java:187)
at java.util.ArrayList.add(ArrayList.java:378)
at lejos.robotics.pathfinding.ShortestPathFinder$Node.block(ShortestPathFinder.java:420)
at lejos.robotics.pathfinding.ShortestPathFinder.findPath(ShortestPathFinder.java:105)
at lejos.robotics.pathfinding.ShortestPathFinder.findRoute(ShortestPathFinder.java:48)
at <My CLASS>
to make sure: this is on a PC - not on the NXT.
The Exception disappears, when commenting out the lenghtenlines.
Any ideas on how i need to change my code to make it working?
Or is it a flaw with both pathfinding algorithms that is already fixed in 0.9.1?
Greetings
Matthias
