#include <ArMap.h>
ArMap encapsulates the data contained in a .map file. It provides methods to read and write a .map file, and to obtain and modify the contents of the map. In addition, the application may install callbacks on the map to be notified when its contents are modified.
Aria maps contain the following types of data:
See below for the exact format of the actual .map file.
If you are going to use setMapObjects(), setPoints(), setLines(), or setMapInfo(), then you should lock() the map beforehand, call the methods, then call mapChanged() to invoke the callbacks, and then finally unlock() the map when done. Note that mapChanged() will only invoke the callbacks if the data has actually changed.
The readFile() and writeFile() methods do automatically lock the map while they read and write.
A rectangle object may have an associated angle of rotation as well, stored in the object pose theta value (ArMapObject::getPose().getTh()). The actual global coordinates of the rectangle must be calculated using this angle and its "from-to" values. You can get a list of the 4 ArLineSegment objects taht compose the rectangle's edges using ArMapObject::getFromToSegments(). If you want to do your own calculations, see ArMapObject::ArMapObject().
MapInfo: GoalType Name=SpecialGoal "Label=Special" "Desc=Doing special stuff" Heading=Required Shape=VBars "Color0=0xff0000"The new goal type will appear be available in Mapper3 and MobilePlanner in a drop-down menu. Instances in the map will also be displayed by MobileEyes.
Please read the following information carefully if you plan to use this feature.
Each MapInfo line is of the format:
MapInfo: <Keyword> ([ParamName=ParmValue] )*
(([ParamName=ParamValue] )*
is a space separated list of "key=value
codes.)
The following Keywords are supported:
The available parameters depend on the Keyword. Unless otherwise specified, parameters are optional.
If a parameter value contains a space, then both the parameter name and value must be enclosed within quotes. For example:
"Label=Normal Goal"Neither the name nor the value can contain the special characters #, ;, , or ".
The following ParamNames are valid for all keywords:
For GoalType, DockType, and LocationType, the following ParamNames are also supported:
0x
, and followed by two digits for the red component, two digits for green, and two digits for blue. For example, 0xff00ff
.For SectorType, the following ParamNames are also supported:
All blank lines should be ignored. As an exception to ABNF, literal strings are case-sensitive.
A map is the line "2D-Map" followed by the metadata section, followed by some number of data sections:
ARMAP = ("2D-Map" NEWLINE) (MetadataSection) (*DataSection)
The MetadataSection section provides information about the map data, adds objects (Cairns) and also provides storage of application-specific/custom information.
MetadataSection = *MetadataLine MetadataLine = MDKey ":" *(WS MDVal) NEWLINE MDKey = StringID MDVal = Integer / Float / StringID / KeyValPair
Most metadata lines fall into one of two categories: a simple list of numeric tokens, or a StringID followed by a list of either numeric tokens or a set of KeyValuePair tokens.
Sensor data sections contain data that was recorded with sensors (e.g. a Laser Rangefinder for the "DATA" section) and which represent more or less permanent, solid objects detectable by a robot's range sensors. (This data can be used for localization and path planning, for instance.) The DATA section is a collection of points detected by a high-resolution sensor like the LRF. LINES abstracts the world into a set of flat surfaces.
DataSection = ("DATA" NEWLINE *PointLine) / ("LINES" NEWLINE *LineLine) PointLine = XPos WS YPos NEWLINE LineLine = XPos WS YPos WS XPos WS YPos NEWLINE
"Cairn" is a common instance of MDKey. A "Cairn" metadata entry looks like this:
MetaDataLine =/ Cairn NEWLINE Cairn = "Cairn:" WS CairnType WS XPos WS YPos WS Theta WS InternalName WS IconName WS Label [WS TypeSpecificData] CairnType = StringID XPos = Integer YPos = Integer Theta = Integer InternalName = QuotedString IconName = QuotedString Label = QuotedString TypeSpecificData = *(WS MDKey)
"MapInfo" is another common instance of MDKey. A "MapInfo" entry can describe custom map object types for your application beyond the usual Cairn types (see above).
MetaDataLine =/ MapInfo NEWLINE MapInfo = "MapInfo:" WS MapInfoClass WS *(KeyValuePair) MapInfoClass = StringID
Data types:
KeyValPair = (StringID "=" MDVal) / QUOTE ALNUM "=" Text QUOTE Integer = ["-"] *1(DIGIT) Float = ["-"] *1(DIGIT | ".") StringID = *1 ALNUM ; One or more alphanumeric characters QuotedText = QUOTE Text QUOTE Text = *(ALNUM / WS / PUNCTUATION) DIGIT = ("0"-"9") ALPHA = ("a"-"z" / "A"-"Z") ALNUM = ALPHA / DIGIT WS = *(" ") ; Any number of ASCII space characters (incl. 0) QUOTE = d34 ; ASCII double quote mark (") NEWLINE = d10 ; ASCII newline (
) PUNCTUATION = d32-%d47 / d58-%d64 / d92-%d96 / d123-%d126 ANY = d32-%d126 ; Any ASCII text
Notes:
MinPos
MaxPos
NumPoints
LineMinPos
LineMaxPos
NumLines
Resolution
Cairn
MapInfo
Goal
GoalWithHeading
RobotHome
Dock
ForbiddenLine
TypeSpecificData =/ ForbiddenLineData ForbiddenLineData = XPos WS YPos WS XPos WS YPosThe normal Cairn pose is not used for
ForbiddenLine
. ForbiddenArea
TypeSpecificData =/ ForbiddenAreaData ForbiddenAreaData = XPos WS YPos WS XPos WS YPosThe normal Cairn pose for
ForbiddenArea
defines an offset of the geometric center of the area, plus a rotation of the area. (Typically, XPos and YPos will always be 0
for ForbiddenArea
, but Theta may be used to provide the rotation of the rectangular area). "ICON"
. You should preserve them when reading and writing map files though, as they may be used in the future. GoalType
DockType
LocationType
BoundaryType
SectorType
Name=
Text Label=
Text Desc=
Text MapInfo
metadata, see the discussion above.
Definition at line 397 of file ArMap.h.
Public Types | |
enum | { INFO_COUNT = LAST_INFO + 1 } |
enum | InfoType { META_INFO, TASK_INFO, ROUTE_INFO, SCHED_TASK_INFO, SCHED_INFO, LAST_INFO = SCHED_INFO } |
List of the standard Info categories defined for the map. More... | |
Public Member Functions | |
void | addMapChangedCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a callback called when the map is changed. | |
void | addPreMapChangedCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a callback called before the map changed callbacks are called. | |
ArMap (const char *baseDirectory="./", bool addToGlobalConfig=true, const char *configSection="Files", const char *configParam="Map", const char *configDesc="Map of the environment we'll use to navigate", bool ignoreEmptyFileName=true) | |
Constructor. | |
ArMapObject * | findFirstMapObject (const char *name, const char *type) |
Gets the first map object of given name and type if it exists. | |
ArMapObject * | findMapObject (const char *name, const char *type=NULL) |
Gets a map object of given name and type if it exists. | |
const char * | getBaseDirectory (void) const |
Gets the base directory. | |
const char * | getFileName (void) const |
Gets the fileName that was loaded. | |
bool | getIgnoreEmptyFileName (void) |
Gets whether we ignore empty file names or fail if we encounter one. | |
std::list< ArArgumentBuilder * > * | getInfo (int infoType) |
Gets the strings for the specified Info category. | |
ArTime | getInfoChanged (int infoType) |
Returns the last time that the specified Info category was changed. | |
ArPose | getLineMaxPose (void) |
Gets the upper right point of the lines. | |
ArPose | getLineMinPose (void) |
Gets the lower left point of the lines. | |
std::vector< ArLineSegment > * | getLines (void) |
Gets the lines. | |
ArTime | getLinesChanged (void) |
Gets the last time the lines were changed. | |
ArLog::LogLevel | getMapChangedLogLevel (void) |
Gets the level we log our map changed callback at. | |
std::list< ArArgumentBuilder * > * | getMapInfo (void) |
Gets the map info strings. | |
ArTime | getMapInfoChanged (void) |
Gets the last time the map info was changed. | |
std::list< ArMapObject * > * | getMapObjects (void) |
Gets the map objects. | |
ArTime | getMapObjectsChanged (void) |
Gets the last time the map objects were changed. | |
ArPose | getMaxPose (void) |
Gets the upper right point of the points. | |
ArPose | getMinPose (void) |
Gets the lower left point of the points. | |
int | getNumLines (void) |
Gets the number of lines. | |
int | getNumPoints (void) |
Gets the number of points. | |
std::vector< ArPose > * | getPoints (void) |
Gets the map points. | |
ArTime | getPointsChanged (void) |
Gets the last time the points were changed. | |
int | getResolution (void) |
Gets the resolution (-1 if none specified). | |
bool | isLoadingDataStarted () |
bool | isLoadingLinesAndDataStarted () |
void | loadDataPoint (double x, double y) |
Adds the specified data point to the loading points. | |
void | loadLineSegment (double x1, double y1, double x2, double y2) |
Adds the specified line segment to the loading lines. | |
int | lock () |
Lock the map instance. | |
void | mapChanged (void) |
Function that will call the map changed CBs if needed. | |
bool | parseLine (char *line) |
Parses a map line. | |
void | parsingComplete (void) |
Says that the parsing by lines is done and to use the parsed data. | |
bool | readDataPoint (char *line) |
Reads a data point from the given line, and adds it to the loading points. | |
bool | readFile (const char *fileName, char *errorBuffer=NULL, size_t errorBufferLen=0) |
Reads a map. | |
bool | readLineSegment (char *line) |
Reads a line segment from the given line, and adds it to the loading lines. | |
void | remMapChangedCB (ArFunctor *functor) |
Removes a callback called when the map is changed. | |
void | remPreMapChangedCB (ArFunctor *functor) |
Removes a callback called before the map changed callbacks are called. | |
void | setBaseDirectory (const char *baseDirectory) |
Sets the base directory. | |
void | setIgnoreEmptyFileName (bool ignore) |
Sets whether we ignore empty file names or fail if we encounter one. | |
bool | setInfo (int infoType, const std::list< ArArgumentBuilder * > *infoList) |
Sets the contents of the specified Info category. | |
void | setLines (const std::vector< ArLineSegment > *lines) |
Sets the lines (copies those passed in). | |
void | setMapChangedLogLevel (ArLog::LogLevel level) |
Sets the level we log our map changed callback at. | |
void | setMapInfo (const std::list< ArArgumentBuilder * > *mapInfo) |
Sets the map info (copies those passed in). | |
void | setMapObjects (const std::list< ArMapObject * > *mapObjects) |
Sets the map objects (copies those passed in). | |
void | setPoints (const std::vector< ArPose > *points) |
Sets the points (copies those passed in). | |
void | setResolution (int resolution) |
int | tryLock () |
Try to lock the map instance without blocking. | |
int | unlock () |
Unlock the map instance. | |
bool | writeFile (const char *fileName, bool internalCall=false) |
Write out a map file. | |
void | writeLinesToFunctor (ArFunctor2< int, std::vector< ArLineSegment > * > *functor) |
Writes the map line segments to a functor. | |
void | writeObjectsToFunctor (ArFunctor1< const char * > *functor, const char *endOfLineChars) |
Writes the map header information and objects to a text-based functor. | |
void | writePointsToFunctor (ArFunctor2< int, std::vector< ArPose > * > *functor) |
Writes the map data points to a functor. | |
void | writeToFunctor (ArFunctor1< const char * > *functor, const char *endOfLineChars) |
Writes all of the map to a functor instead of a to a file. | |
virtual | ~ArMap (void) |
Destructor. | |
Protected Types | |
enum | { MAX_MAP_NAME_LENGTH = 512 } |
Protected Member Functions | |
virtual const char * | getInfoName (int infoType) |
Returns the name of the specified Info category (i.e. the "xInfo:" tag at the beginning of the line). | |
bool | handle2DMap (ArArgumentBuilder *arg) |
bool | handleData (ArArgumentBuilder *arg) |
bool | handleInfo (ArArgumentBuilder *arg, int info) |
bool | handleLine (ArArgumentBuilder *arg) |
bool | handleLineMaxPos (ArArgumentBuilder *arg) |
bool | handleLineMinPos (ArArgumentBuilder *arg) |
bool | handleLines (ArArgumentBuilder *arg) |
bool | handleMapInfo (ArArgumentBuilder *arg) |
bool | handleMapObject (ArArgumentBuilder *arg) |
bool | handleMaxPos (ArArgumentBuilder *arg) |
bool | handleMinPos (ArArgumentBuilder *arg) |
bool | handleNumLines (ArArgumentBuilder *arg) |
bool | handleNumPoints (ArArgumentBuilder *arg) |
bool | handlePoint (ArArgumentBuilder *arg) |
bool | handleResolution (ArArgumentBuilder *arg) |
bool | processFile (char *errorBuffer, size_t errorBufferLen) |
bool | reset (void) |
Protected Attributes | |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | my2DMapCB |
std::string | myBaseDirectory |
char | myConfigMapName [MAX_MAP_NAME_LENGTH] |
std::string | myConfigParam |
bool | myConfigProcessedBefore |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myDataCB |
std::string | myFileName |
bool | myIgnoreEmptyFileName |
std::list< ArArgumentBuilder * > * | myInfoArray |
ArRetFunctor2C< bool, ArMap, ArArgumentBuilder *, int > ** | myInfoCBArray |
ArTime * | myInfoChangedArray |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myLineCB |
ArPose | myLineMax |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myLineMaxPosCB |
ArPose | myLineMin |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myLineMinPosCB |
std::vector< ArLineSegment > | myLines |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myLinesCB |
ArTime | myLinesChanged |
bool | myLoadingDataStarted |
bool | myLoadingGot2DMap |
bool | myLoadingGotLineMaxPos |
bool | myLoadingGotLineMinPos |
bool | myLoadingGotMaxPos |
bool | myLoadingGotMinPos |
std::list< ArArgumentBuilder * > * | myLoadingInfoArray |
ArPose | myLoadingLineMax |
ArPose | myLoadingLineMaxFromFile |
ArPose | myLoadingLineMin |
ArPose | myLoadingLineMinFromFile |
std::vector< ArLineSegment > | myLoadingLines |
bool | myLoadingLinesAndDataStarted |
int | myLoadingLinesRead |
std::list< ArArgumentBuilder * > | myLoadingMapInfo |
std::list< ArMapObject * > | myLoadingMapObjects |
ArPose | myLoadingMax |
ArPose | myLoadingMaxFromFile |
ArPose | myLoadingMin |
ArPose | myLoadingMinFromFile |
int | myLoadingNumLines |
int | myLoadingNumPoints |
ArFileParser * | myLoadingParser |
std::vector< ArPose > | myLoadingPoints |
int | myLoadingPointsRead |
int | myLoadingResolution |
std::list< ArFunctor * > | myMapChangedCBList |
ArTime * | myMapChangedInfoArray |
ArLog::LogLevel | myMapChangedLogLevel |
ArTime | myMapChangedMapInfo |
ArTime | myMapChangedMapObjects |
ArTime | myMapChangedPoints |
std::list< ArArgumentBuilder * > | myMapInfo |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myMapInfoCB |
ArTime | myMapInfoChanged |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myMapObjectCB |
std::list< ArMapObject * > | myMapObjects |
ArTime | myMapObjectsChanged |
ArPose | myMax |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myMaxPosCB |
ArPose | myMin |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myMinPosCB |
ArMutex | myMutex |
int | myNumInfos |
Number of different Info categories available in this map. | |
int | myNumLines |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myNumLinesCB |
int | myNumPoints |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myNumPointsCB |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myPointCB |
std::vector< ArPose > | myPoints |
ArTime | myPointsChanged |
std::list< ArFunctor * > | myPreMapChangedCBList |
ArRetFunctor2C< bool, ArMap, char *, size_t > | myProcessFileCB |
stat | myReadFileStat |
int | myResolution |
ArRetFunctor1C< bool, ArMap, ArArgumentBuilder * > | myResolutionCB |
Static Protected Attributes | |
static const char * | ourInfoNames [INFO_COUNT] |
Array of names for the standard Info categories; see InfoType. |
|
|
|
List of the standard Info categories defined for the map.
|
|
Constructor. myRouteInfoCB(this, &ArMap::handleRouteInfo), |
|
Adds a callback called when the map is changed. Adds a read callback that is called when the map is read in, the map is locked when this callback happens so you don't need to worry about that. |
|
Adds a callback called before the map changed callbacks are called. Adds a read callback that is called when the map is read in, BEFORE the map changed callbacks... note that anything added here CANNOT care about what is in the map file... this is for adding things that the map changed callbacks might care about..., the map is locked when this callback happens so you don't need to worry about that. |
|
Gets the first map object of given name and type if it exists.
|
|
Gets a map object of given name and type if it exists.
|
|
Gets the strings for the specified Info category.
|
|
Returns the last time that the specified Info category was changed.
|
|
Returns the name of the specified Info category (i.e. the "xInfo:" tag at the beginning of the line). If subclasses define additional Info categories, then they must override this method.
|
|
bool ArMap::handleRouteInfo(ArArgumentBuilder *arg) { ArArgumentBuilder *routeInfo = NULL; routeInfo = new ArArgumentBuilder(*arg); myLoadingRouteInfo.push_back(routeInfo); return true; } |
|
This value returns true once the DATA tag has been reached. The rest of the map contains data points. |
|
This value returns true once the LINES tag has been reached. The rest of the map contains data points. |
|
Says that the parsing by lines is done and to use the parsed data. If you've been giving the map lines to parse with parseLine and you are finished then you should call this function call to move all of that data from the loading zone into the main variables. |
|
Reads a map.
|
|
Sets the contents of the specified Info category.
|
|
Sets the lines (copies those passed in). Deletes and clears the old lines (and the info about our lines) and then makes a copy of the ones passed in.
|
|
Sets the map info (copies those passed in). Deletes and clears the old mapInfo and then makes a copy of the ones passed in.
|
|
Sets the map objects (copies those passed in). Deletes and clears the old map objects and then makes a copy of the ones passed in.
|
|
Sets the points (copies those passed in). Deletes and clears the old points (and the info about our points) and then makes a copy of the ones passed in.
|
|
Write out a map file. Writes a file out... The map is locked while the write happens.
|
|
Writes the map line segments to a functor. A pointer to the entire line segment vector is passed directly to the modify the vector's contents. |
|
Writes the map header information and objects to a text-based functor. This method writes everything up to and including the DATA tag to the given functor. The data points are not written. |
|
Writes the map data points to a functor. A pointer to the entire data point vector is passed directly to the functor in order to improve performance. The functor should not modify the vector's contents. |
|
Writes all of the map to a functor instead of a to a file. This function calls the functor with each line of the map, the lines do not have any \n or \r characters on them |
|
Initial value: { "MetaInfo:", "TaskInfo:", "RouteInfo:", "SchedTaskInfo:", "SchedInfo:" }
|