dLife Home Page

dlife.robot.hemisson
Class HemissonPlayer

java.lang.Object
  extended by java.util.Observable
      extended by dlife.robot.Robot
          extended by dlife.robot.player.PlayerRobot
              extended by dlife.robot.hemisson.HemissonPlayer

public class HemissonPlayer
extends PlayerRobot

Class for communicating with a simulated Hemission in the Player/Stage system. The HemissonPlayer class creates a connection to a Player server with a Hemisson model simulation running. This class can be used just as a regular Hemisson robot as long as a valid Player server is running. This class uses a PlayerClient to communicate with the server. The provided playerclient2.jar contains the necessary class files to run. Note: when adding a HemissonSonar, player can only send back 1 echo. Therefore, an exception is thrown if a HemissonSonar is added requesting more than 1 echo.

Version:
Feb. 19, 2010
Author:
Russell Toris, Dickinson College

Field Summary
static PlayerDeviceConfiguration PLAYER_PROXIMITY_CONFIG
          The configuration data for player for the Hemisson IR sensor.
static PlayerDeviceConfiguration PLAYER_SONAR_CONFIG
          The configuration data for player for the Hemisson Sonar sensor.
static int PROX_GROUND_CONSTANT
          Since player cannot use the ground proximity sensors, a default value will be returned each time for that sensor.
 
Fields inherited from class dlife.robot.player.PlayerRobot
PLAYER_POSITION_CONFIG, TIMEOUT
 
Constructor Summary
HemissonPlayer()
          Construct a new HemissonPlayer.
HemissonPlayer(File dLifePlayerConfig, int port, boolean noise)
          Connect to a HemissonPlayer with the given DLP configuration file, port to attempt to connect to, and if we should load and use the noise profile for this robot.
HemissonPlayer(File dLifePlayerConfig, int port, boolean noise, String playerCmd)
          Connect to a HemissonPlayer with the given DLP configuration file, port to attempt to connect to, if we should load and use the noise profile for this robot, and absolute player command..
HemissonPlayer(PlayerSimulation sim, int port, boolean noise)
          Connect to a HemissonPlayer using the configuration contained in the PlayerSimuation object.
HemissonPlayer(PlayerSimulation sim, String playerCmd, int port, boolean noise)
          Connect to a HemissonPlayer using the configuration contained in the PlayerSimuation object.
HemissonPlayer(String address, int port)
          Creates a new HemissonPlayer and connects to a Player Server at the supplied address and port number.
 
Method Summary
static String[] getPlayerConfigBody()
          Get the main body definition for player.
static PlayerRobotIconInfo getPlayerSimulationBuilderIcon()
          This will return a Polygon containing the icon of this robot to be used in a PlayerSimulationBuilder.
protected  boolean isValidDevice(Device newDevice)
          Checks if the device is valid for a HemissonPlayer.
 String sendMessage(String msg)
          Interpret the message intended for a Hemisson robot and make the necessary calls to player.
 
Methods inherited from class dlife.robot.player.PlayerRobot
addDevice, getAddress, getAngle, getGripperData, getPlayerClient, getPort, getRotation, getSonarValues, getTranslation, getXPos, getYPos, hasGripper, resetPositionData, setGripper, setPositionData, setPositionUnits, setSonarUnits, setSpeed, shutDown, startUp
 
Methods inherited from class dlife.robot.Robot
freeze, getDevices, getRunTime, isAlive, removeDevice, setAlive
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAYER_SONAR_CONFIG

public static final PlayerDeviceConfiguration PLAYER_SONAR_CONFIG
The configuration data for player for the Hemisson Sonar sensor. This should be passed to the addSensorToRobot method of a PlayerSimulation class.


PLAYER_PROXIMITY_CONFIG

public static final PlayerDeviceConfiguration PLAYER_PROXIMITY_CONFIG
The configuration data for player for the Hemisson IR sensor. This should be passed to the addSensorToRobot method of a PlayerSimulation class.


PROX_GROUND_CONSTANT

public static final int PROX_GROUND_CONSTANT
Since player cannot use the ground proximity sensors, a default value will be returned each time for that sensor.

See Also:
Constant Field Values
Constructor Detail

HemissonPlayer

public HemissonPlayer()
Construct a new HemissonPlayer. A dialog box appears to ask the user to enter the IP address and port at which the Player server is running or location of a .dlp file.

Throws:
RobotCreationCanceledException - if the user cancels the creation of the robot via the dialog box.
UnknownHostException - thrown if the host name cannot be resolved

HemissonPlayer

public HemissonPlayer(PlayerSimulation sim,
                      int port,
                      boolean noise)
Connect to a HemissonPlayer using the configuration contained in the PlayerSimuation object. This configuration will be saved to a temporary location and used to load player. The PlayerRobot will attempt to connect to the port provided and attempt to load noise if 'noise' is true. This will attempt to find a valid player command on your system.

Parameters:
sim - the PlayerSimulation used to setup player
port - the port to connect to
noise - if noise should be used

HemissonPlayer

public HemissonPlayer(PlayerSimulation sim,
                      String playerCmd,
                      int port,
                      boolean noise)
Connect to a HemissonPlayer using the configuration contained in the PlayerSimuation object. This configuration will be saved to a temporary location and used to load player. The PlayerRobot will attempt to connect to the port provided and attempt to load noise if 'noise' is true. This will use the absolute Player command provided.

Parameters:
sim - the PlayerSimulation used to setup player
playerCmd - the absolute system command to start player
port - the port to connect to
noise - if noise should be used

HemissonPlayer

public HemissonPlayer(File dLifePlayerConfig,
                      int port,
                      boolean noise)
Connect to a HemissonPlayer with the given DLP configuration file, port to attempt to connect to, and if we should load and use the noise profile for this robot. The DLP file is assumed to live in the same directory as all other player configuration files for this simulation. A valid player command will be searched for on the system in three likely locations.

Parameters:
dLifePlayerConfig - the DLP file for this simulation
port - the port of the robot to connect to in Player
noise - if a noise profile should be loaded and used

HemissonPlayer

public HemissonPlayer(File dLifePlayerConfig,
                      int port,
                      boolean noise,
                      String playerCmd)
Connect to a HemissonPlayer with the given DLP configuration file, port to attempt to connect to, if we should load and use the noise profile for this robot, and absolute player command.. The DLP file is assumed to live in the same directory as all other player configuration files for this simulation.

Parameters:
dLifePlayerConfig - the DLP file for this simulation
port - the port of the robot to connect to in Player
noise - if a noise profile should be loaded and used
playerCmd - the absolute system command to start player

HemissonPlayer

public HemissonPlayer(String address,
                      int port)
               throws UnknownHostException
Creates a new HemissonPlayer and connects to a Player Server at the supplied address and port number. By using "testing" as the address name, a MockPlayerClient will be created instead which can be used for testing. This constructor assumes Player is running.

Parameters:
address - the address where the Player Server is running
port - the port number that the Player Server is using
Throws:
UnknownHostException - thrown if the host name cannot be resolved.
Method Detail

isValidDevice

protected boolean isValidDevice(Device newDevice)
Checks if the device is valid for a HemissonPlayer. This will also check if that device was found on the Player server. The following are valid for a HemissonPlayer: HemissonSonar, HemissonProximitySensor, HemissonDifferentialDrive When adding a HemissonSonar, player can only send back 1 echo. Therefore, an exception is thrown if a HemissonSonar is added requesting more than 1 echo.

Specified by:
isValidDevice in class PlayerRobot
Parameters:
newDevice - the device to check
Returns:
if the device is valid

sendMessage

public String sendMessage(String msg)
Interpret the message intended for a Hemisson robot and make the necessary calls to player. This will return a formated response that a Hemisson robot would give back. If the message is invalid null is returned. If the robot is not alive, a RobotCommunicationException is thrown. If the robot looses communication with Player a RobotCommunicationException is thrown.

Specified by:
sendMessage in class Robot
Parameters:
msg - the message to interpret
Returns:
a format response if msg is valid, or null if msg is invalid

getPlayerConfigBody

public static String[] getPlayerConfigBody()
Get the main body definition for player. This should be the base robot with no sensors. Each line should be a new element in the array.

Returns:
the main body definition for player

getPlayerSimulationBuilderIcon

public static PlayerRobotIconInfo getPlayerSimulationBuilderIcon()
This will return a Polygon containing the icon of this robot to be used in a PlayerSimulationBuilder.

Returns:
a Polygon containing the icon of this robot to be used in a PlayerSimulationBuilder.
Throws:
PlayerConfigurationDataException - if this method was not overridden

dLife Home Page