Problem with ShortestPathFinder

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

Moderators: roger, gloomyandy, skoehler

konG80
New User
Posts: 1
Joined: Tue Aug 12, 2014 9:35 am

Problem with ShortestPathFinder

Postby konG80 » Tue Aug 12, 2014 9:57 am

Hi, i have tried to generate a shortest path on a linemap with the shortestpathfinder.

The problem was, the generated path did not respect the boundingrectangle of the linemap. So i modiefied the shortestPathfinder.java from:

Code: Select all

public void setMap(LineMap theMap)
   {
      Line[] lines = theMap.getLines();      
      for (int i = 0; i < lines.length; i++)
         _map.add(lines[i]);
   }


to

Code: Select all

public void setMap(LineMap theMap)
   {
      Line[] lines = theMap.getLines();      
      for (int i = 0; i < lines.length; i++)
         _map.add(lines[i]);
      
      lines = createLinesFromMapBoundingRectangle(theMap);
      for (int i = 0; i < lines.length; i++)
         _map.add(lines[i]);
   }

   public Line[] createLinesFromMapBoundingRectangle(LineMap theMap) {
      Line[] lines =
         {new Line(theMap.getBoundingRect().x,theMap.getBoundingRect().y,theMap.getBoundingRect().width,theMap.getBoundingRect().y)
         ,new Line(theMap.getBoundingRect().x,theMap.getBoundingRect().y,theMap.getBoundingRect().x,theMap.getBoundingRect().height)
         ,new Line(theMap.getBoundingRect().width,theMap.getBoundingRect().height,theMap.getBoundingRect().width,theMap.getBoundingRect().y)
         ,new Line(theMap.getBoundingRect().width,theMap.getBoundingRect().height,theMap.getBoundingRect().x,theMap.getBoundingRect().height)};
      return lines;
   };


as a workaround, so that the rectangle is added to the list of lines which is used during the shortestsPath calculation.

The question : is it a bug that the rectangle is not looked at in shortestpathfinder, or did i only not get it and used it not properly?

lawrie
leJOS Team Member
Posts: 955
Joined: Mon Feb 05, 2007 1:27 pm

Re: Problem with ShortestPathFinder

Postby lawrie » Tue Aug 12, 2014 6:35 pm

This is probably a bug. I will look at adding your fix to the next release.

roger
Moderator
Posts: 370
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Re: Problem with ShortestPathFinder

Postby roger » Wed Aug 20, 2014 6:00 pm

Hi Lawrie,
Should the code that adds the lines of the bounding rectangle to the Lines array be in the ShortestPathFinder or in the LineMap class? I suggest the LineMap class because there may be other algorithms that use that class that would use that class.
Roger


Return to “EV3 Software”

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests