|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdlife.sys.SerializationBase
dlife.robot.player.PlayerSimulation
public class PlayerSimulation
A PlayerSimulation object is a helpful object to create a Player simulation and all necessary configuration files. The simulation may be modified using the provided methods and you can save the configuration files. Robots are written in alphabetical order by name, not by order added. This is important when figuring out by hand which robot has which port. To run the server, run the following command replacing 'name' with the name giving in the constructor: # player name.cfg In addition, a PlayerSever object can assist with launching the server from dLife. Moreover, a file called 'name.dlp' (where name is replaced by the simulation name) is created which can be loaded and read by a PlayerConnection object.
| Nested Class Summary | |
|---|---|
class |
PlayerSimulation.PlayerSimulationPuck
A PlayerSimulationPuck is used to keep track of the information a puck has in a player simulation. |
class |
PlayerSimulation.PlayerSimulationRobot
A PlayerSimulationRobot is used to keep track of the information a robot has in a player simulation. |
| Constructor Summary | |
|---|---|
PlayerSimulation(String name,
double width,
double height,
File map)
Creates a PlayerSimulation object with the given simulation name, width, height, and map file. |
|
PlayerSimulation(String name,
double width,
double height,
File map,
int startingPort)
Creates a PlayerSimulation object with the given simulation name, width, height, and map file. |
|
| Method Summary | |
|---|---|
void |
addDeviceToRobot(String robotName,
PlayerDeviceConfiguration device)
Adds a PlayerDeviceConfiguration to a given robot. |
void |
addDeviceToRobot(String robotName,
PlayerDeviceConfiguration device,
NoiseProfile<?> np)
Adds a PlayerDeviceConfiguration to a given robot with a given NoiseProfile. |
void |
addPuck(String name,
double xPos,
double yPos,
double dir,
Color color,
double width,
double height)
Add a puck to the simulation with the given name. |
void |
addRobot(String name,
Class<? extends PlayerRobot> robotClass,
double xPos,
double yPos,
double dir,
Color color)
Add a robot to the simulation with the given parameters. |
boolean |
disabled()
If the GUI will be disabled |
void |
disableGUI(boolean disable)
If the GUI will be disabled for this simulation. |
double |
getHeight()
Gets the height in meters of the map for this simulation. |
BufferedImage |
getMapImage()
Gets a copy of the map image. |
String |
getMapImageName()
Gets the name of the map image file. |
String |
getName()
Get the name of the simulation. |
int |
getNumPucks()
Gets the total number of pucks in the simulation. |
int |
getNumRobots()
Get the number of robots in the current simulation. |
ArrayList<String> |
getPuckNames()
Get the names of all the puck types in this PlayerSimulation. |
ArrayList<PlayerSimulation.PlayerSimulationPuck> |
getPucks(String name)
Get a list of all PlayerSimulationPuck objects for the puck given puck type. |
PlayerSimulation.PlayerSimulationRobot |
getRobot(String name)
Get the PlayerSimulationRobot object of the robot for the robot with the given name. |
ArrayList<String> |
getRobotNames()
Get the names of all the robots in this PlayerSimulation. |
int |
getStartingPort()
Get the port which the robots start at in the .cfg file. |
double |
getWidth()
Gets the width in meters of the map for this simulation. |
void |
removePuck(String name,
double xPos,
double yPos)
Remove a specific puck with the given name, x position, and y position if it exits. |
void |
removeRobot(String name)
Remove a robot with the given name if that name exists. |
void |
reset()
Clear and remove all pucks and robots as well as reset the time interval. |
void |
saveConfiguration(String path)
Write the simulation files to the given path. |
void |
setRealTime(boolean realTime)
Set if the simulation should run in real time, or take 1 real-world millisecond to simulate the number of milliseconds in setSimTimeInterval (default of 100ms) |
void |
setSimTimeInterval(int interval)
Set the simulation time update interval for the simulation. |
void |
setStartingPort(int newPort)
Set the starting port to the given value. |
| Methods inherited from class dlife.sys.SerializationBase |
|---|
read, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PlayerSimulation(String name,
double width,
double height,
File map)
name - the name of the simulation. This will be used to name all
files.width - the width in meters of the mapheight - the height in meters of the mapmap - the file of the map image
InvalidParameterException - if name is not of the form
[a-zA-Z][a-zA-Z\d]+
public PlayerSimulation(String name,
double width,
double height,
File map,
int startingPort)
name - the name of the simulation. This will be used to name all
files.width - the width in meters of the mapheight - the height in meters of the mapmap - the file of the map image
InvalidParameterException - if name is not of the form
[a-zA-Z][a-zA-Z\d]+| Method Detail |
|---|
public int getStartingPort()
public void setStartingPort(int newPort)
newPort - the new starting portpublic double getWidth()
public double getHeight()
public String getMapImageName()
public BufferedImage getMapImage()
throws IOException
IOException - thrown if there is a problem reading the map image.public void disableGUI(boolean disable)
disable - if the GUI will be disabledpublic boolean disabled()
public int getNumRobots()
public int getNumPucks()
public String getName()
public void addRobot(String name,
Class<? extends PlayerRobot> robotClass,
double xPos,
double yPos,
double dir,
Color color)
name - the name of the robotrobotClass - the class object of the player robot you will be usingxPos - the x-position (in meters)yPos - the y-position (in meters)dir - the direction (in degrees)color - the color of the robot
InvalidPlayerRobotTypeException - thrown if type does not match one
of the predefined constants from this class
InvalidParameterException - if name is not of the form
[a-zA-Z][a-zA-Z\d]+public ArrayList<String> getRobotNames()
public PlayerSimulation.PlayerSimulationRobot getRobot(String name)
name - the name of the robot to get the PlayerSimulationRobot object
of
public void addDeviceToRobot(String robotName,
PlayerDeviceConfiguration device)
robotName - the name of the robot to add the device todevice - the PlayerDeviceConfiguration provided from that robots
PlayerRobot class.
public void addDeviceToRobot(String robotName,
PlayerDeviceConfiguration device,
NoiseProfile<?> np)
robotName - the name of the robot to add the device todevice - the PlayerDeviceConfiguration provided from that robots
PlayerRobot class.np - the noise profile for this devicepublic void removeRobot(String name)
name - the name of the robot to remove
public void addPuck(String name,
double xPos,
double yPos,
double dir,
Color color,
double width,
double height)
name - the name of the puck typexPos - the x-position (in meters)yPos - the y-position (in meters)dir - the direction (in degrees)color - the colorwidth - the width in the x direction in metersheight - the hight in the y direction in meters
InvalidParameterException - if name is not of the form
[a-zA-Z][a-zA-Z\d]+public ArrayList<String> getPuckNames()
public ArrayList<PlayerSimulation.PlayerSimulationPuck> getPucks(String name)
name - the name of the puck type to get the PlayerSimulationPuck
object list of
public void removePuck(String name,
double xPos,
double yPos)
name - name of the puck to removexPos - the x position of the puckyPos - the y position of the puckpublic void setSimTimeInterval(int interval)
interval - public void setRealTime(boolean realTime)
realTime - if the simulation should run in real timepublic void reset()
public void saveConfiguration(String path)
throws IOException
path - the path (not including the file name) where the files will
be saved
FileNotFoundException - thrown if it cannot write the files.
IOException
|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||