javaclient
Class SonarInterface

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

public class SonarInterface
extends PlayerDevice

The sonar interface provides access to a collection of fixed range sensors, such as a sonar array. This interface accepts no commands.

Version:
Author:
Maxim A. Batalin & Radu Bogdan Rusu

Field Summary
protected  short PLAYER_SONAR_GET_GEOM_REQ
           
static short PLAYER_SONAR_MAX_SAMPLES
          maximum number of sonar samples
protected  short PLAYER_SONAR_POWER_REQ
           
 
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
SonarInterface(PlayerClient pc, short indexOfDevice)
          Constructor for SonarInterface.
 
Method Summary
 PlayerSonarGeomT getPSGT()
          Get the geometry data.
 int[] getRanges()
          Returns the sonar array data values up to PLAYER_SONAR_MAX_SAMPLES.
 int getSamplesCount()
          Returns the number of ultrasonic sensors specified in the Player world file (the number of valid range readings).
 void handleResponse(int size)
          Handle acknowledgement response messages (threaded mode).
 boolean isPSGTReady()
          Check if geometry data is available.
 void queryGeometry()
          Configuration request: Query geometry.
 void readData()
          Read the sonar values.
 void setSonarPower(int value)
          Configuration request: Sonar power.
 
Methods inherited from class javaclient.PlayerDevice
getTimeForDataSampled_sec, getTimeForDataSampled_usec, getTimeForDataSampled, getTimeForDataSent_sec, getTimeForDataSent_usec, getTimeForDataSent, handleEARMessage, handleNARMessage, readHeader, sendHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAYER_SONAR_GET_GEOM_REQ

protected final short PLAYER_SONAR_GET_GEOM_REQ
See Also:
Constant Field Values

PLAYER_SONAR_POWER_REQ

protected final short PLAYER_SONAR_POWER_REQ
See Also:
Constant Field Values

PLAYER_SONAR_MAX_SAMPLES

public static final short PLAYER_SONAR_MAX_SAMPLES
maximum number of sonar samples

See Also:
Constant Field Values
Constructor Detail

SonarInterface

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

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

readData

public void readData()
Read the sonar values.

Overrides:
readData in class PlayerDevice

getRanges

public int[] getRanges()
Returns the sonar array data values up to PLAYER_SONAR_MAX_SAMPLES.

Returns:
an array filled with the sonar values

getSamplesCount

public int getSamplesCount()
Returns the number of ultrasonic sensors specified in the Player world file (the number of valid range readings).

Returns:
the number of ultrasonic sensors specified in the Player world file as an integer

queryGeometry

public void queryGeometry()
Configuration request: Query geometry.

See the player_sonar_geom structure from player.h


setSonarPower

public void setSonarPower(int value)
Configuration request: Sonar power. ("available only on real robots" (TM))

See the player_sonar_power_config structure from player.h

Parameters:
value - turn power off (0) or on (>0)

handleResponse

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

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

isPSGTReady

public boolean isPSGTReady()
Check if geometry data is available.

Returns:
true if ready, false if not ready

getPSGT

public PlayerSonarGeomT getPSGT()
Get the geometry data.

Returns:
an object of type PlayerSonarGeomT containing the required geometry data