dLife Home Page

dlife.robot.pioneer
Class PioneerPlayer

java.lang.Object
  extended by java.util.Observable
      extended by dlife.robot.Robot
          extended by dlife.robot.player.PlayerRobot
              extended by dlife.robot.pioneer.PioneerPlayer

public class PioneerPlayer
extends PlayerRobot

A PioneerPlayer creates a connection to a Player server with a Pioneer model simulation running. This class can be used just as a regular Pioneer 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.

Version:
June 15, 2010
Author:
Russell Toris, Dickinson College

Field Summary
static PlayerDeviceConfiguration PLAYER_FRONT_BUMPERS_CONFIG
          The configuration data for player for the front bumper array.
static PlayerDeviceConfiguration PLAYER_GRIPPER_CONFIG
          The configuration data for player for the gripper.
static PlayerDeviceConfiguration PLAYER_REAR_BUMPERS_CONFIG
          The configuration data for player for the rear bumper array.
static PlayerDeviceConfiguration PLAYER_SONAR_CONFIG
          The configuration data for player for the Sonar sensor.
 
Fields inherited from class dlife.robot.player.PlayerRobot
PLAYER_POSITION_CONFIG, TIMEOUT
 
Constructor Summary
PioneerPlayer()
          Construct a new PioneerPlayer.
PioneerPlayer(File dLifePlayerConfig, int port, boolean noise)
          Connect to a PioneerPlayer 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.
PioneerPlayer(File dLifePlayerConfig, int port, boolean noise, String playerCmd)
          Connect to a PioneerPlayer 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..
PioneerPlayer(PlayerSimulation sim, int port, boolean noise)
          Connect to a PioneerPlayer using the configuration contained in the PlayerSimuation object.
PioneerPlayer(PlayerSimulation sim, String playerCmd, int port, boolean noise)
          Connect to a PioneerPlayer using the configuration contained in the PlayerSimuation object.
PioneerPlayer(String address, int port)
          Creates a new PioneerPlayer 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 PlayerRobotIconInfo 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 PioneerPlayer.
 String sendMessage(String msg)
          Interprets the message given and sends an appropriate command to the PlayerClient.
 
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_REAR_BUMPERS_CONFIG

public static final PlayerDeviceConfiguration PLAYER_REAR_BUMPERS_CONFIG
The configuration data for player for the rear bumper array. This should be passed to the addSensorToRobot method of a PlayerSimulation class.


PLAYER_FRONT_BUMPERS_CONFIG

public static final PlayerDeviceConfiguration PLAYER_FRONT_BUMPERS_CONFIG
The configuration data for player for the front bumper array. This should be passed to the addSensorToRobot method of a PlayerSimulation class.


PLAYER_SONAR_CONFIG

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


PLAYER_GRIPPER_CONFIG

public static final PlayerDeviceConfiguration PLAYER_GRIPPER_CONFIG
The configuration data for player for the gripper. This should be passed to the addSensorToRobot method of a PlayerSimulation class.

Constructor Detail

PioneerPlayer

public PioneerPlayer()
Construct a new PioneerPlayer. 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

PioneerPlayer

public PioneerPlayer(PlayerSimulation sim,
                     int port,
                     boolean noise)
Connect to a PioneerPlayer 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

PioneerPlayer

public PioneerPlayer(PlayerSimulation sim,
                     String playerCmd,
                     int port,
                     boolean noise)
Connect to a PioneerPlayer 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

PioneerPlayer

public PioneerPlayer(File dLifePlayerConfig,
                     int port,
                     boolean noise)
Connect to a PioneerPlayer 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

PioneerPlayer

public PioneerPlayer(File dLifePlayerConfig,
                     int port,
                     boolean noise,
                     String playerCmd)
Connect to a PioneerPlayer 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

PioneerPlayer

public PioneerPlayer(String address,
                     int port)
              throws UnknownHostException
Creates a new PioneerPlayer 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 PioneerPlayer. This will also check if that device was found on the Player server. The following are valid for a PioneerPlayer: PioneerSonar, PioneerGripper, PioneerOdometry, PioneerDeadReckoning, PioneerBumpers, PioneerDifferentialDrive,

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

sendMessage

public String sendMessage(String msg)
Interprets the message given and sends an appropriate command to the PlayerClient. When completed, an appropriate message will be returned using the response from the PlayerClient. Will return null if an invalid message is sent. Only messages that are valid to a Pioneer robot running a PioneerServer will be accepted. All invalid messages will be printed out to the terminal and return null. A response will be formated the same way a response from a PioneerServer looks. 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 interpret for the PlayerClient
Returns:
an appropriate response based on msg or null if invalid
Throws:
RobotCommunicationException - thrown if the robot is not alive or communication with Player is lost

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 PlayerRobotIconInfo containing the icon of this robot to be used in a PlayerSimulationBuilder.

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

dLife Home Page