|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
dlife.robot.Robot
dlife.robot.player.PlayerRobot
public abstract class PlayerRobot
This is an abstract class to represent a PlayerRobot. Any implementation of this class should make calls to player using the protected playerClient field. Any class that decides to override the startUp or shutDown methods should make a call to super. When a PlayerRobot is constructed, fields are populated with Player interfaces if they exist. If they do not exist, they will be initialized to null. Note that once a PlayerRobot has been shut down using the shutDown method, it can no longer be started up again. Instead, a new PlayerRobot must be constructed. In order to use a PlayerRobot in the PlayerSimulation class, the static getPlayerConfigBody MUST be overwritten. An exception will be thrown otherwise. In addition, any devices for the PlayerSimulation class should be made static and final using a PlayerDeviceConfiguration object.
| Field Summary | |
|---|---|
static PlayerDeviceConfiguration |
PLAYER_POSITION_CONFIG
The configuration data for player for the position2d interface. |
static int |
TIMEOUT
The time allowed to wait for player to start in milliseconds. |
| Constructor Summary | |
|---|---|
PlayerRobot()
Displays a PlayerConnectionDialog to help connect to player. |
|
PlayerRobot(File dlpFile,
int port,
boolean noise)
Connect to a PlayerRobot 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. |
|
PlayerRobot(File dlpFile,
int port,
boolean noise,
String playerCmd)
Connect to a PlayerRobot 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.. |
|
PlayerRobot(javaclient2.PlayerClient pc)
Create a PlayerRobot using the given PlayerClient which should already be connected to Player. |
|
PlayerRobot(PlayerSimulation sim,
int port,
boolean noise)
Connect to a PlayerRobot using the configuration contained in the PlayerSimuation object. |
|
PlayerRobot(PlayerSimulation sim,
String playerCmd,
int port,
boolean noise)
Connect to a PlayerRobot using the configuration contained in the PlayerSimuation object. |
|
PlayerRobot(String address,
int port)
Attempts to connect to a robot in player with the given address and port. |
|
| Method Summary | |
|---|---|
void |
addDevice(Device newDevice)
The Device is first checked to make sure it is a valid Device for the PlayerRobot. |
String |
getAddress()
Get the address Player is running on |
protected float |
getAngle()
Returns the position's angle in radians relative to the x-axis or wherever the robot was facing when resetPositionData was last called. |
protected int[] |
getGripperData()
Attempt to get the gripper data for the GripperInterface if it exists. |
javaclient2.PlayerClient |
getPlayerClient()
Get a reference to the PlayerClient. |
static String[] |
getPlayerConfigBody()
This method must be overridden or a PlayerConfigurationDataException is thrown. |
static PlayerRobotIconInfo |
getPlayerSimulationBuilderIcon()
This method must be overridden or a PlayerConfigurationDataException is thrown. |
int |
getPort()
Get the port this robot is connected to. |
protected float |
getRotation()
Return the rotation speed in radians per second. |
protected float[] |
getSonarValues(int numSensors)
Attempt to get the sonar data for the SonarInterface with the given number of sensors. |
protected float |
getTranslation()
Return the translation speed in meters per second. |
protected float |
getXPos()
Returns the position's x value in the units set in setPositionUnits relative to the center of the map or wherever resetPositionData was last called. |
protected float |
getYPos()
Returns the position's y value in the units set in setPositionUnits relative to the center of the map or wherever resetPositionData was last called. |
protected boolean |
hasGripper()
Returns true if a gripper device was found on this PlayerRobot on the Player server. |
protected abstract boolean |
isValidDevice(Device newDevice)
Should return if the device is valid and supported for this PlayerRobot. |
protected void |
resetPositionData()
Reset the position information for this robot. |
protected void |
setGripper(int cmd,
int arg)
Set the gripper for this robot if it exists. |
protected void |
setPositionData(float x,
float y,
float theta)
Set the position information for this robot. |
protected void |
setPositionUnits(int unit)
Set the units for which a the position data from Player will be returned. |
protected void |
setSonarUnits(int numSensors,
int unit)
Set the units for which a particular SonarInterface will return its readings in. |
protected void |
setSpeed(float speed,
float turnrate)
Set the wheel speeds for this robot. |
void |
shutDown()
Closes the connection to the Player server and also marks the robot as not alive. |
void |
startUp()
Marks the robot as alive. |
| Methods inherited from class dlife.robot.Robot |
|---|
freeze, getDevices, getRunTime, isAlive, removeDevice, sendMessage, 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 |
|---|
public static final PlayerDeviceConfiguration PLAYER_POSITION_CONFIG
public static final int TIMEOUT
| Constructor Detail |
|---|
public PlayerRobot()
RobotCreationCanceledException - if the user cancels the creation
of the robot via the dialog box.
RobotCommunicationException - thrown if there was a problem
communicating with Player during creation of the robot
UnknownHostException - thrown if the host name cannot be resolved
public PlayerRobot(String address,
int port)
throws UnknownHostException
address - the address of the player serverport - the port of the robot
UnknownHostException - thrown if the host name cannot be resolved
RobotCommunicationException - thrown if there was a problem
communicating with Player during creation of the robotpublic PlayerRobot(javaclient2.PlayerClient pc)
pc - the PlayerClient for this robot
RobotCommunicationException - thrown if there was a problem
communicating with Player during creation of the robot
public PlayerRobot(PlayerSimulation sim,
int port,
boolean noise)
sim - the PlayerSimulation used to setup playerport - the port to connect tonoise - if noise should be used
RobotCommunicationException - thrown if there was a problem
communicating with Player during creation of the robot
public PlayerRobot(PlayerSimulation sim,
String playerCmd,
int port,
boolean noise)
sim - the PlayerSimulation used to setup playerplayerCmd - the absolute system command to start playerport - the port to connect tonoise - if noise should be used
RobotCommunicationException - thrown if there was a problem
communicating with Player during creation of the robot
public PlayerRobot(File dlpFile,
int port,
boolean noise)
dlpFile - the DLP file for this simulationport - the port of the robot to connect to in Playernoise - if a noise profile should be loaded and used
RobotCommunicationException - thrown if there was a problem
communicating with Player during creation of the robot
public PlayerRobot(File dlpFile,
int port,
boolean noise,
String playerCmd)
dlpFile - the DLP file for this simulationport - the port of the robot to connect to in Playernoise - if a noise profile should be loaded and usedplayerCmd - the absolute system command to start player
RobotCommunicationException - thrown if there was a problem
communicating with Player during creation of the robot| Method Detail |
|---|
public int getPort()
public String getAddress()
public javaclient2.PlayerClient getPlayerClient()
protected abstract boolean isValidDevice(Device newDevice)
newDevice - the Device to check
public void addDevice(Device newDevice)
addDevice in class RobotnewDevice - the Device to add to this PlayerRobot.
InvalidPlayerDeviceException - thrown if the sensor is not valid
for this PlayerRobotpublic void startUp()
startUp in class Robotpublic void shutDown()
shutDown in class Robotprotected float[] getSonarValues(int numSensors)
numSensors - the number of sensors in the sonar array we want to
read from
RobotCommunicationException - thrown if we loose communication with
Player
protected void setSonarUnits(int numSensors,
int unit)
numSensors - the number of sensors in the sonar array we want to
read fromunit - a unit constant found in the PlayerConstants class
RobotCommunicationException - thrown if we loose communication with
Playerprotected void setPositionUnits(int unit)
unit - a unit constant found in the PlayerConstants class
RobotCommunicationException - thrown if we loose communication with
Playerprotected void resetPositionData()
RobotCommunicationException - thrown if we loose communication with
Player
protected void setPositionData(float x,
float y,
float theta)
x - the x coordinate in the units set in setPositionUnitsy - the y coordinate in the units set in setPositionUnitstheta - the angle in radians
RobotCommunicationException - thrown if we loose communication with
Playerprotected float getXPos()
protected float getYPos()
protected float getAngle()
protected void setSpeed(float speed,
float turnrate)
speed - the translation speed in units/secturnrate - the turnrate in rad/sec
RobotCommunicationException - thrown if we loose communication with
Playerprotected float getTranslation()
RobotCommunicationException - thrown if we loose communication with
Playerprotected float getRotation()
RobotCommunicationException - thrown if we loose communication with
Playerprotected boolean hasGripper()
protected void setGripper(int cmd,
int arg)
cmd - the gripper command to sendarg - the argument for the gripper command
RobotCommunicationException - thrown if we loose communication with
Player or if the gripper does not exist.protected int[] getGripperData()
RobotCommunicationException - thrown if we loose communication with
Player or the gripper does not existpublic static String[] getPlayerConfigBody()
PlayerConfigurationDataException - if this method was not
overriddenpublic static PlayerRobotIconInfo getPlayerSimulationBuilderIcon()
PlayerConfigurationDataException - if this method was not
overridden
|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||