#include <ArServerHandlerMap.h>
A map can be provided from an ArMap object, or else the filename can be given in the global ArConfig object (see Aria::getConfig()) as "Map" in the "Files" section. This handler can also be configured to only send "point" data, "line" data, or both kinds of data from the map.
This service accepts the following data requests:
getMapId
getMapName
getMap
getGoals
getMapBinary
getMapMultiScans
The following data types will also be broadcast to all clients to indicate certain events:
mapUpdated
goalsUpdated
The getMapId
request replies with... TODO
The getMapName
request replies with a packet containing a NULL-terminated string containing the filename of the map, or an empty string ("") if there is no map.
The getMap
request replies with a packet containing the map as it appears in the map file (see the documentation for ArMap for the file format).
The getGoals
request replies with a series of NULL-terminated strings containing the names of the Goal objects in the map.
The getMapBinary
request replies with the map headers and objects list (see ArMap for map file format) as text, but supplies point "DATA" and/or "LINES" as an undelimited sequence of 2-byte integers. (In the case of point data, each pair of integers is a point; for lines, each sequence of four integers defines a line). This binary representation of data is more compact than the ASCII text representation.
The getMapMultiScans
request is similar to getMapBinary, but it includes a list of the scan sources, along with the point and lines for each scan source in binary format.
The mapUpdated
packet is sent to all connected clients whenever a new map is loaded or the map is changed. The packet contains no data; the new map can be downloaded using one of the above requests.
The goalsUpdated
packet is sent to all connected clients whenever the list of Goal objects changes in the map or a new map is loaded. The packet contains no data; the new list of goals can be downloaded using getGoals
, or by downloading the entire map.
Public Types | |
enum | DataToSend { LINES = 1, POINTS = 2, BOTH = 3 } |
Public Member Functions | |
ArServerHandlerMap (ArServerBase *server, ArMapInterface *arMap=NULL, DataToSend dataToSend=BOTH) | |
Constructor. | |
DataToSend | getDataToSend (void) |
Gets which kind of data we send. | |
ArMapInterface * | getMap (void) |
Gets the map object this is using. | |
bool | loadMap (const char *mapFile) |
Loads the map from a file. | |
void | serverGetGoals (ArServerClient *client, ArNetPacket *packet) |
The command that'll get the goals. | |
void | serverGetMap (ArServerClient *client, ArNetPacket *packet) |
The command that'll get the map itself. | |
void | serverGetMapBinary (ArServerClient *client, ArNetPacket *packet) |
The command that gets the map, with the data in binary format for improved performance. | |
void | serverGetMapId (ArServerClient *client, ArNetPacket *packet) |
Handles the request for the map ID. | |
void | serverGetMapMultiScans (ArServerClient *client, ArNetPacket *packet) |
Requests that the server send the map, including scan data for multiple sources if available. | |
void | serverGetMapName (ArServerClient *client, ArNetPacket *packet) |
The command that gets the map name. | |
void | serverGetMapWithMaxCategory (ArServerClient *client, ArNetPacket *packet) |
Requests that the server send the map with the specified maximum features. | |
void | setDataToSend (DataToSend dataToSend) |
Sets which kind of data we send. | |
void | useMap (ArMapInterface *mapObj, bool takeOwnershipOfMap=false) |
Uses a map already loaded. | |
virtual | ~ArServerHandlerMap () |
Destructor. | |
Protected Member Functions | |
void | handleCheckMap (ArServerClient *client, ArNetPacket *packet) |
void | mapChanged (void) |
bool | processFile (void) |
void | sendMapWithMaxCategory (ArServerClient *client, const char *maxCategory) |
void | writeLinesToClient (int lineCount, std::vector< ArLineSegment > *points, ArServerClient *client) |
void | writeMapToClient (const char *line, ArServerClient *client) |
void | writePointsToClient (int pointCount, std::vector< ArPose > *points, ArServerClient *client) |
Protected Attributes | |
bool | myAlreadyLoaded |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myCheckMapCB |
DataToSend | myDataToSend |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myGetGoalsCB |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myGetMapBinaryCB |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myGetMapCB |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myGetMapIdCB |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myGetMapMaxCategoryCB |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myGetMapMultiScansCB |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myGetMapNameCB |
char | myLastMapFile [1024] |
stat | myLastMapFileStat |
ArMapInterface * | myMap |
ArFunctorC< ArServerHandlerMap > | myMapChangedCB |
char | myMapFileName [512] |
std::string | myMapName |
bool | myOwnMap |
ArRetFunctorC< bool, ArServerHandlerMap > | myProcessFileCB |
ArServerBase * | myServer |
ArServerHandlerMap * | myServerHandlerMap |