javaclient
Class MapInterface

java.lang.Object
  extended by javaclient.PlayerDevice
      extended by javaclient.MapInterface

public class MapInterface
extends PlayerDevice

The map interface provides acces to an occupancy grid map. This interface returns no data and accepts no commands. The map is delivered in tiles, via a sequence of configuration requests.

Version:
Author:
Radu Bogdan Rusu

Field Summary
protected static short PLAYER_MAP_GET_DATA_REQ
           
protected static short PLAYER_MAP_GET_INFO_REQ
           
static short PLAYER_MAP_MAX_CELLS_PER_TILE
          the max number of cells we can send in one tile
 
Fields inherited from class javaclient.PlayerDevice
device, DIFFERENCE_SYNCH_FACTOR, index, is, os, pc, PLAYER_MAX_REQREP_SIZE, PLAYER_STXX, reserved, size, t_sec, t_usec, ts_sec, ts_usec
 
Constructor Summary
MapInterface(PlayerClient pc, short indexOfDevice)
          Constructor for MapInterface.
 
Method Summary
 int getHeight()
          Get the height of the map (pixels)
 void getMapData(int col, int row, int width, int height)
          Configuration request: Get map data.
 void getMapInformation()
          Configuration request: Get map information.
 int getScale()
          Get the scale of the map (pixels per kilometer)
 int getTileCol()
          Get the tile origin (X - pixels)
 int[] getTileData()
          Get a tile data
 int getTileHeight()
          Get the height of a tile in the map (pixels)
 int getTileRow()
          Get the tile origin (Y - pixels)
 int getTileWidth()
          Get the width of a tile in the map (pixels)
 int getWidth()
          Get the width of the map (pixels)
 void handleNARMessage()
          Handle negative acknowledgement response messages.
 void handleResponse(int size)
          Handle acknowledgement response messages (threaded mode).
 
Methods inherited from class javaclient.PlayerDevice
getTimeForDataSampled_sec, getTimeForDataSampled_usec, getTimeForDataSampled, getTimeForDataSent_sec, getTimeForDataSent_usec, getTimeForDataSent, handleEARMessage, readData, readHeader, sendHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAYER_MAP_MAX_CELLS_PER_TILE

public static final short PLAYER_MAP_MAX_CELLS_PER_TILE
the max number of cells we can send in one tile

See Also:
Constant Field Values

PLAYER_MAP_GET_INFO_REQ

protected static final short PLAYER_MAP_GET_INFO_REQ
See Also:
Constant Field Values

PLAYER_MAP_GET_DATA_REQ

protected static final short PLAYER_MAP_GET_DATA_REQ
See Also:
Constant Field Values
Constructor Detail

MapInterface

public MapInterface(PlayerClient pc,
                    short indexOfDevice)
Constructor for MapInterface.

Parameters:
pc - a reference to the PlayerClient object
indexOfDevice - the index of the device
Method Detail

getMapInformation

public void getMapInformation()
Configuration request: Get map information.

Retrieve the size and scale information of a current map. This request is used to get the size information before you request the actual map data. Set the subtype to PLAYER_MAP_GET_INFO_REQ; the server will reply with the size information filled in.

See the player_map_info structure from player.h


getMapData

public void getMapData(int col,
                       int row,
                       int width,
                       int height)
Configuration request: Get map data.

Retrieve the map data. Beacause of the limited size of a request-reply messages, the map data is tranfered in tiles. In the request packet, set the column and row index of a specific tile; the server will reply with the requested map data filled in.

See the player_map_data structure from player.h

Parameters:
col - the tile origin (X - pixels)
row - the tile origin (Y - pixels)
width - the width of the tile in the map (pixels)
height - the height of the tile in the map (pixels)

handleResponse

public void handleResponse(int size)
Handle acknowledgement response messages (threaded mode).

Overrides:
handleResponse in class PlayerDevice
Parameters:
size - size of the payload

getScale

public int getScale()
Get the scale of the map (pixels per kilometer)

Returns:
the scale of the map as an int

getWidth

public int getWidth()
Get the width of the map (pixels)

Returns:
the width of the map as an int

getHeight

public int getHeight()
Get the height of the map (pixels)

Returns:
the height of the map as an int

getTileCol

public int getTileCol()
Get the tile origin (X - pixels)

Returns:
the tile origin (X - pixels) as an int

getTileRow

public int getTileRow()
Get the tile origin (Y - pixels)

Returns:
the tile origin (Y - pixels) as an int

getTileWidth

public int getTileWidth()
Get the width of a tile in the map (pixels)

Returns:
the width of a tile the map as an int

getTileHeight

public int getTileHeight()
Get the height of a tile in the map (pixels)

Returns:
the height of a tile in the map as an int

getTileData

public int[] getTileData()
Get a tile data

Returns:
the data of a specified tile as an array of integers
See Also:
getMapData(int, int, int, int)

handleNARMessage

public void handleNARMessage()
Handle negative acknowledgement response messages.

Overrides:
handleNARMessage in class PlayerDevice