|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGlobalNavigation.PolygonMap
public class PolygonMap
The 2D worldRect
, PolygonObstacle
obstacles
,
robotStart
, and robotGoal
that
make-up the environment in which the robot will navigate.
You can either make an instance of this class and use it from within your
own program (typical usage), or you can run this code as an indepedent
process (see #main
). The latter mode allows you to display the
contents of a map file, but does not give programmatic access to those
contents, and thus is useful mostly for displaying/debugging map
files.
The format of the map file is as follows (all items are signed doubles in ASCII text format, all units are meters, and all separators are whitespace):
robotStartX robotStartY robotGoalX robotGoalY worldX worldY worldWidth worldHeight obstacle0X0 obstacle0Y0 obstacle0X1 obstacle0Y1 ... ...The first three lines initialize the corresponding instance fields
robotStart
, robotGoal
, and worldRect
, respectively. Each obstacle line gives the coordinates of the
obstacle's vertices in CCW order. There may be zero obstacles.
Field Summary | |
---|---|
static java.lang.String |
APPNAME
Name to use when run as an application. |
protected java.util.LinkedList<PolygonObstacle> |
obstacles
The obstacles (does not include the world boundary). |
protected java.awt.geom.Point2D.Double |
robotGoal
The goal point for the robot origin, read in from the map file (m). |
protected java.awt.geom.Point2D.Double |
robotStart
The start point for the robot origin, read in from the map file (m). |
protected java.awt.geom.Rectangle2D.Double |
worldRect
The location and size of the world boundary, read in from the map file (m). |
Constructor Summary | |
---|---|
PolygonMap()
Create a new un-initialized polygon map. |
|
PolygonMap(java.io.File mapFile)
Create a new map, parsing mapFile . |
|
PolygonMap(java.lang.String mapFile)
Covers PolygonMap(File) . |
Method Summary | |
---|---|
protected void |
driverDisplayHook()
Hook called after painting map objects in instanceMain(java.lang.String) to
allow subclasses to display extra stuff. |
protected java.lang.String |
getAppName()
Get the application name. |
GraphName |
getDefaultNodeName()
|
java.util.List<PolygonObstacle> |
getObstacles()
Get obstacles . |
java.awt.geom.Point2D.Double |
getRobotGoal()
Get robotGoal . |
java.awt.geom.Point2D.Double |
getRobotStart()
Get robotStart . |
java.awt.geom.Rectangle2D.Double |
getWorldRect()
Get worldRect . |
protected void |
instanceMain(java.lang.String mapFile)
Parses the specified map file, prints it out, and displays it in the GUI, if any. |
void |
onShutdown(Node node)
Shutdown hook for ROS when called as stand-alone node |
void |
onShutdownComplete(Node node)
|
void |
onStart(Node node)
Entry hook for ROS when called as stand-alone node |
protected void |
parse(java.io.File mapFile)
Parse mapFile . |
protected double |
parseDouble(java.io.BufferedReader br,
java.lang.String name,
int lineNumber)
Parse a double . |
protected boolean |
parseExtra(java.io.BufferedReader br,
int lineNumber)
Hook called from parse(java.io.File) after the first four lines are parsed
to allow subclasses to parse extra lines before the obstacles. |
protected PolygonObstacle |
parseObs(java.io.BufferedReader br,
java.lang.String name,
int lineNumber)
Parse a PolygonObstacle . |
protected void |
parsePoint(java.awt.geom.Point2D.Double point,
java.io.BufferedReader br,
java.lang.String name,
int lineNumber)
Parse a Point2D.Double . |
protected void |
parseRect(java.awt.geom.Rectangle2D.Double rect,
java.io.BufferedReader br,
java.lang.String name,
int lineNumber)
Parse a Rectangle2D.Double . |
java.lang.String |
toString()
Return a human-readable string representation of this map. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String APPNAME
Name to use when run as an application.
protected java.awt.geom.Point2D.Double robotStart
The start point for the robot origin, read in from the map file (m).
protected java.awt.geom.Point2D.Double robotGoal
The goal point for the robot origin, read in from the map file (m).
protected java.awt.geom.Rectangle2D.Double worldRect
The location and size of the world boundary, read in from the map file (m).
protected java.util.LinkedList<PolygonObstacle> obstacles
The obstacles (does not include the world boundary).
Constructor Detail |
---|
public PolygonMap(java.io.File mapFile) throws java.io.IOException, java.text.ParseException
Create a new map, parsing mapFile
.
mapFile
- the map file to parse, or null if none
java.io.IOException
java.text.ParseException
public PolygonMap(java.lang.String mapFile) throws java.io.IOException, java.text.ParseException
Covers PolygonMap(File)
.
java.io.IOException
java.text.ParseException
public PolygonMap()
Create a new un-initialized polygon map.
You may populate it using the accessors below.
Method Detail |
---|
protected double parseDouble(java.io.BufferedReader br, java.lang.String name, int lineNumber) throws java.io.IOException, java.text.ParseException, java.lang.NumberFormatException
Parse a double
.
br
- the double is expected to be on the next line of this readername
- the name of the doublelineNumber
- the line number of the double
java.io.IOException
- if there was an I/O error
java.text.ParseException
- if there was a format error
java.lang.NumberFormatException
- if there was a format errorprotected void parsePoint(java.awt.geom.Point2D.Double point, java.io.BufferedReader br, java.lang.String name, int lineNumber) throws java.io.IOException, java.text.ParseException, java.lang.NumberFormatException
Parse a Point2D.Double
.
point
- the returned pointbr
- the point is expected to be on the next line of this readername
- the name of the pointlineNumber
- the line number of the point
java.io.IOException
- if there was an I/O error
java.text.ParseException
- if there was a format error
java.lang.NumberFormatException
- if there was a format errorprotected void parseRect(java.awt.geom.Rectangle2D.Double rect, java.io.BufferedReader br, java.lang.String name, int lineNumber) throws java.io.IOException, java.text.ParseException, java.lang.NumberFormatException
Parse a Rectangle2D.Double
.
rect
- the returned rectanglebr
- the rect is expected to be on the next line of this readername
- the name of the rectlineNumber
- the line number of the rect
java.io.IOException
- if there was an I/O error
java.text.ParseException
- if there was a format error
java.lang.NumberFormatException
- if there was a format errorprotected PolygonObstacle parseObs(java.io.BufferedReader br, java.lang.String name, int lineNumber) throws java.io.IOException, java.text.ParseException, java.lang.NumberFormatException
Parse a PolygonObstacle
.
br
- the polygon is expected to be on the next line of this readername
- the name of the polygonlineNumber
- the line number of the polygon
java.io.IOException
- if there was an I/O error
java.text.ParseException
- if there was a format error
java.lang.NumberFormatException
- if there was a format errorprotected boolean parseExtra(java.io.BufferedReader br, int lineNumber) throws java.io.IOException, java.text.ParseException, java.lang.NumberFormatException
Hook called from parse(java.io.File)
after the first four lines are parsed
to allow subclasses to parse extra lines before the obstacles.
Default impl just returns false.
br
- the next line of this reader is the next to be parsedlineNumber
- the line number of the next line of br
java.io.IOException
- if there was an I/O error
java.text.ParseException
- if there was a format error
java.lang.NumberFormatException
- if there was a format errorprotected void parse(java.io.File mapFile) throws java.io.IOException, java.text.ParseException
Parse mapFile
.
Format is specified in the class header doc for PolygonMap
.
mapFile
- the map file, not null
java.io.IOException
java.text.ParseException
public java.awt.geom.Point2D.Double getRobotStart()
Get robotStart
.
robotStart
(you may modify it)public java.awt.geom.Point2D.Double getRobotGoal()
Get robotGoal
.
robotGoal
(you may modify it)public java.awt.geom.Rectangle2D.Double getWorldRect()
Get worldRect
.
worldRect
(you may modify it)public java.util.List<PolygonObstacle> getObstacles()
Get obstacles
.
obstacles
(you may modify it)public java.lang.String toString()
Return a human-readable string representation of this map.
toString
in class java.lang.Object
protected void instanceMain(java.lang.String mapFile)
Parses the specified map file, prints it out, and displays it in the GUI, if any.
Usage: getAppName()
<mapfile> [centralhost]
protected java.lang.String getAppName()
Get the application name.
protected void driverDisplayHook()
Hook called after painting map objects in instanceMain(java.lang.String)
to
allow subclasses to display extra stuff.
Default impl does nothing.
public void onShutdown(Node node)
public void onStart(Node node)
public void onShutdownComplete(Node node)
public GraphName getDefaultNodeName()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |