Aria  2.8.0
ArMapObject Class Reference

A point or region of interest in an Aria map. More...

#include <ArMapObject.h>

Public Types

enum  { ARG_INDEX_COUNT = LAST_ARG_INDEX + 1 }
 
enum  ArgIndex {
  TYPE_ARG_INDEX = 0, POSE_X_ARG_INDEX = 1, POSE_Y_ARG_INDEX = 2, TH_ARG_INDEX = 3,
  DESC_ARG_INDEX = 4, ICON_ARG_INDEX = 5, NAME_ARG_INDEX = 6, LAST_POSE_ARG_INDEX = NAME_ARG_INDEX,
  FROM_X_ARG_INDEX = 7, FROM_Y_ARG_INDEX = 8, TO_X_ARG_INDEX = 9, TO_Y_ARG_INDEX = 10,
  LAST_ARG_INDEX = TO_Y_ARG_INDEX
}
 ArArgumentBuilder indices for the various map object attributes.
 

Public Member Functions

 ArMapObject (const char *type, ArPose pose, const char *description, const char *iconName, const char *name, bool hasFromTo, ArPose fromPose, ArPose toPose)
 Constructor. More...
 
 ArMapObject (const ArMapObject &mapObject)
 Copy constructor.
 
ArPose findCenter (void) const
 Computes the center pose of the map object. More...
 
const char * getBaseType (void) const
 Returns the "base" (or root) type of the map object. More...
 
const char * getDescription () const
 Returns the optional description of the map object.
 
const char * getFileName (void) const
 Gets the fileName of the object (probably never used for maps) More...
 
ArPose getFromPose (void) const
 Returns the "from" pose for lines and rectangles; valid only if hasFromTo() More...
 
double getFromToRotation (void) const
 Returns the optional rotation of a rectangle; or 0 if none. More...
 
ArLineSegment getFromToSegment (void)
 Gets a line segment that goes from the from to the to. More...
 
std::list< ArLineSegmentgetFromToSegments (void)
 Gets a list of fromTo line segments that have been rotated. More...
 
const char * getIconName (void) const
 Returns the icon string of the object. More...
 
int getId () const
 Returns the numerical identifier of the object, when auto-numbering is on. More...
 
const char * getName (void) const
 Returns the name of the map object (if any) More...
 
ArPose getPose (void) const
 Returns the primary pose of the object. More...
 
const char * getStringRepresentation () const
 Returns the text representation of the map object. More...
 
ArPose getToPose (void) const
 Returns the "to" pose for lines and rectangles; valid only if hasFromTo() More...
 
const char * getType (void) const
 Returns the type of the map object. More...
 
bool hasFromTo (void) const
 Returns true if the map object has valid "from/to" poses (i.e. is a line or rectangle) More...
 
void log (const char *intro=NULL) const
 Writes the map object to the ArLog. More...
 
bool operator< (const ArMapObject &other) const
 Less than operator (for sets), orders by position.
 
ArMapObjectoperator= (const ArMapObject &mapObject)
 Assignment operator.
 
void setDescription (const char *description)
 Sets the description of the map object. More...
 
const char * toString () const
 Returns the text representation of the map object. More...
 
virtual ~ArMapObject ()
 Destructor.
 

Static Public Member Functions

static ArMapObjectcreateMapObject (ArArgumentBuilder *arg)
 Creates a new ArMapObject whose attributes are as specified in the given arguments. More...
 

Protected Attributes

std::string myBaseType
 If non-empty, then myType ends with "WithHeading" and this is the "root".
 
std::string myDescription
 The description of the map object.
 
ArPose myFromPose
 The "from" pose of a region map object; valid only if myHasFromTo is true.
 
ArLineSegment myFromToSegment
 For line objects, the line.
 
std::list< ArLineSegmentmyFromToSegments
 For rectangle objects, the line segments that comprise the perimeter (even if rotated)
 
bool myHasFromTo
 Whether the map object is a region (line or rect) with "from/to" poses.
 
std::string myIconName
 Reserved for future use.
 
std::string myName
 The name of the map object, if any.
 
ArPose myPose
 For pose objects, THE pose; For rectangle objects, contains the optional rotation.
 
std::string myStringRepresentation
 Text representation written to the map file.
 
ArPose myToPose
 The "to" pose of a region map object; valid only if myHasFromTo is true.
 
std::string myType
 The type of the map object.
 

Detailed Description

A point or region of interest in an Aria map.

ArMapObject contains the data related to an Aria map object, i.e a point or region of interest in an Aria map that is not part of the sensed obstacle data. Examples of map objects include goals, docks, forbidden lines, and forbidden areas. Applications may define their own custom ArMapObject types using the ArMap MapInfo mechanism. See ArMap for more information.

The basic attributes of an ArMapObject include the type of the map object, an optional name of the object, and its position information. As mentioned above, there are two basic categories of ArMapObjects:

  • Points: A single ArPose in the map. By convention, if a map object can have an optional heading, then "WithHeading" appears at the end of the object type when the heading is specified. For example, "Goal" designates an (x,y) location in the map (any heading or theta value should be ignored) and "GoalWithHeading" designates an (x,y,th) location.
  • Regions: A set of two ArPoses ("from" and "to") which define a rectangle or a line. Rectangles may have an associated rotation value. It is the rotation to be applied to the "from" and "to" poses around the global origin . To retrieve the list of line segments that comprise the rotated rectangle's perimeter, use the getFromToSegments() method.

Note that the ArMapObject is generally immutable. If an object needs to be changed, then the original version should simply be replaced with a new one. See ArMap::getMapObjects(), ArMap::setMapObjects(), and ArMap::mapChanged().

Constructor & Destructor Documentation

◆ ArMapObject()

ArMapObject::ArMapObject ( const char *  type,
ArPose  pose,
const char *  description,
const char *  iconName,
const char *  name,
bool  hasFromTo,
ArPose  fromPose,
ArPose  toPose 
)

Constructor.

Parameters
typethe char * type of the map object (e.g. "Goal", "ForbiddenLine"); must be non-empty
posethe primary ArPose of the map object; for points, this is its location; for rectangles, this specifies the rotation of the rectangle (in pose.getTh())
descriptionan optional char * description of the object.
iconNamechar * currently unused: use "ICON" or NULL as a dummy value. Must be a non-empty, non-whitespace string.
namethe char * name of the map object; depending on the object type, this may be optional or required
hasFromToa bool set to true if the object is a region (i.e. line or rectangle); false if the object is a point
fromPosethe ArPose that defines the start point of the region object; applicable only when hasFromTo is true
toPosethe ArPose that defines the end point of the region object; applicable only when hasFromTo is true

Member Function Documentation

◆ createMapObject()

ArMapObject * ArMapObject::createMapObject ( ArArgumentBuilder arg)
static

Creates a new ArMapObject whose attributes are as specified in the given arguments.

Parameters
argthe ArArgumentBuilder * from which to create the ArMapObject; this should correspond to a parsed line in the ArMap file
Returns
ArMapObject * the newly created map object, or NULL if an error occurred

◆ findCenter()

ArPose ArMapObject::findCenter ( void  ) const

Computes the center pose of the map object.

This method determines the center of map objects that have a "from" and a "to" pose (i.e. lines and rectangles). For map objects that are poses, this method simply returns the pose.

◆ getBaseType()

const char * ArMapObject::getBaseType ( void  ) const

Returns the "base" (or root) type of the map object.

If the map object type ends with "WithHeading", then the base is the corresponding heading-less type. For example, "GoalWithHeading" has a base type of "Goal".

If the map object type does not end with "WithHeading", then the base is the same as the type.

◆ getFileName()

const char * ArMapObject::getFileName ( void  ) const

Gets the fileName of the object (probably never used for maps)

This method is maintained solely for backwards compatibility. It now returns the same value as getDescription (i.e. any file names that may have been associated with an object can now be found in the description attribute).

Deprecated:

This method is maintained solely for backwards compatibility. It now returns the same value as getDescription (i.e. any file names that may have been associated with an object can now be found in the description attribute).

Deprecated:

◆ getFromPose()

ArPose ArMapObject::getFromPose ( void  ) const

Returns the "from" pose for lines and rectangles; valid only if hasFromTo()

Gets the from pose (could be for line or box, depending)

◆ getFromToRotation()

double ArMapObject::getFromToRotation ( void  ) const

Returns the optional rotation of a rectangle; or 0 if none.

Note that this function doesn't know whether it actually makes sense for this map object to have the rotation. (For example, it makes sense on a ForbiddenArea but not a ForbiddenLine.)

◆ getFromToSegment()

ArLineSegment ArMapObject::getFromToSegment ( void  )

Gets a line segment that goes from the from to the to.

Note that this function doesn't know whether this is supposed to be a rectangle or a line. (For example, it makes sense on a ForbiddenLine but not a ForbiddenAra.) This is just here to store it. Note that this might be a little more CPU/Memory intensive transfering these around, so you may want to keep a copy of them if you're using them a lot (but make sure you clear the copy if the map changes). It may not make much difference on a modern processor though (its set up this way for safety).

◆ getFromToSegments()

std::list< ArLineSegment > ArMapObject::getFromToSegments ( void  )

Gets a list of fromTo line segments that have been rotated.

Note that this function doesn't know whether it actually makes sense for this map object to have the rotation. (For example, it makes sense on a ForbiddenArea but not a ForbiddenLine.) This is just here so that everyone doesn't have to do the same calculation. Note that this might be a little more CPU/Memory intensive transfering these around, so you may want to keep a copy of them if you're using them a lot (but make sure you clear the copy if the map changes). It may not make much difference on a modern processor though (its set up this way for safety).

◆ getIconName()

const char * ArMapObject::getIconName ( void  ) const

Returns the icon string of the object.

Gets the icon string of the object.

The use of the ICON field is application-dependent. It currently contains either the string "ICON" or "ID=<n>". The ID is used only when auto-numbering has been turned on in the MapInfo.

◆ getId()

int ArMapObject::getId ( ) const

Returns the numerical identifier of the object, when auto-numbering is on.

This method returns 0 when auto-numbering is off.

◆ getName()

const char * ArMapObject::getName ( void  ) const

Returns the name of the map object (if any)

Gets the name of the object (if any)

◆ getPose()

ArPose ArMapObject::getPose ( void  ) const

Returns the primary pose of the object.

Gets the pose of the object.

For points, this is the map object's location; for rectangles, this specifies the rotation of the rectangle (in getPose().getTh())

◆ getStringRepresentation()

const char* ArMapObject::getStringRepresentation ( ) const
inline

Returns the text representation of the map object.

This method is equivalent to toString();

◆ getToPose()

ArPose ArMapObject::getToPose ( void  ) const

Returns the "to" pose for lines and rectangles; valid only if hasFromTo()

Gets the to pose (could be for line or box, depending)

◆ getType()

const char * ArMapObject::getType ( void  ) const

Returns the type of the map object.

Gets the type of the object.

◆ hasFromTo()

bool ArMapObject::hasFromTo ( void  ) const

Returns true if the map object has valid "from/to" poses (i.e. is a line or rectangle)

Gets the addition args of the object.

◆ log()

void ArMapObject::log ( const char *  intro = NULL) const

Writes the map object to the ArLog.

Parameters
introan optional string that should appear before the object

◆ setDescription()

void ArMapObject::setDescription ( const char *  description)

Sets the description of the map object.

This method really should only be called immediately after the object is created, and before it is added to the map. (Since the map object isn't intended to be mutable.) It exists for backwards compatibility.

◆ toString()

const char * ArMapObject::toString ( void  ) const

Returns the text representation of the map object.

The returned string is suitable for writing to the ArMap file. Note that the string does NOT include the map object's optional parameters.


The documentation for this class was generated from the following files: