OutOfMemoryError on PC when using (lejos-)Pathfinder

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

OutOfMemoryError on PC when using (lejos-)Pathfinder

Postby matthias » Thu Mar 22, 2012 12:06 pm

Hello,

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
matthias
New User
 
Posts: 20
Joined: Thu Mar 22, 2012 11:44 am

Re: OutOfMemoryError on PC when using (lejos-)Pathfinder

Postby matthias » Wed Mar 28, 2012 12:07 pm

In 0.9.1 this Bug is now fixed for the ShortestPathFinder - but NOT with the DijkstraPathFinder.

Also the ShortestPathFinder produces some System.out output, which is (in my use case) very annoying.

but at least: it finds the path.
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.DijkstraPathFinder$Node.block(DijkstraPathFinder.java:416)
   at lejos.robotics.pathfinding.DijkstraPathFinder.findPath(DijkstraPathFinder.java:103)
   at lejos.robotics.pathfinding.DijkstraPathFinder.findRoute(DijkstraPathFinder.java:48)
   at <MyClass> line with: pathfinder.findRoute(new Pose(0,0,0), new Waypoint(0,30));

Code is - expect the DijkstraPathFinder -the same as in the first post.
matthias
New User
 
Posts: 20
Joined: Thu Mar 22, 2012 11:44 am


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 1 guest

cron
more stuff