com.yobotics.simulationconstructionset
Class Simulation

java.lang.Object
  extended by com.yobotics.simulationconstructionset.Simulation
All Implemented Interfaces:
YoVariableHolder, java.io.Serializable

public class Simulation
extends java.lang.Object
implements YoVariableHolder, java.io.Serializable

See Also:
Serialized Form

Constructor Summary
Simulation(Robot[] robots, int dataBufferSize)
           
Simulation(Robot robot, int dataBufferSize)
           
 
Method Summary
 void addScript(Script script)
           
 void addSimulateDoneListener(SimulationDoneListener listener)
           
 void addVarList(VarList newVarList)
           
 boolean checkSimulateDoneCriterion()
           
 void closeAndDispose()
           
 java.util.ArrayList<YoVariable> getAllVariables()
          Returns all the YoVariables in this YoVariableHolder
 YoVariable[] getAllVariablesArray()
          Returns all the YoVariables in this YoVariableHolder
 VarList getCombinedVarList()
           
 DataBuffer getDataBuffer()
           
 double getDT()
           
 long getRecordFreq()
           
 Robot[] getRobots()
           
 Graphics3DAdapter getSimulationGraphics()
           
 SimulationSynchronizer getSimulationSynchronizer()
           
 YoVariable getVariable(java.lang.String varname)
          Gets a YoVariable with the given name if it is in this YoVariableHolder, otherwise returns null.
 YoVariable getVariable(java.lang.String nameSpace, java.lang.String varname)
          Gets a YoVariable with the given nameSpace and name if it is in this YoVariableHolder, otherwise returns null.
 java.util.ArrayList<YoVariable> getVariables(NameSpace nameSpace)
          Returns all the YoVariables with the given nameSpace that are in this YoVariableHolder, empty if there are none.
 java.util.ArrayList<YoVariable> getVariables(java.lang.String varname)
          Returns all the YoVariables with the given name that are in this YoVariableHolder, empty if there are none.
 java.util.ArrayList<YoVariable> getVariables(java.lang.String nameSpace, java.lang.String varname)
          Returns all the YoVariables with the given nameSpace and name that are in this YoVariableHolder, empty if there are none.
 java.util.ArrayList<YoVariable> getVariablesThatContain(java.lang.String searchString, boolean caseSensitive)
           
 java.util.ArrayList<YoVariable> getVariablesThatStartWith(java.lang.String searchString)
           
 java.util.ArrayList<YoVariable> getVars(java.lang.String[] varNames, java.lang.String[] regularExpressions)
           
 boolean hasUniqueVariable(java.lang.String varname)
          Checks if this YoVariableHolder holds exactly one YoVariable with the given name.
 boolean hasUniqueVariable(java.lang.String nameSpace, java.lang.String varname)
          Checks if this YoVariableHolder holds exactly one YoVariable with the given nameSpace and name.
 void notifySimulateDoneListeners()
           
 void notifySimulateDoneListenersOfException(java.lang.Throwable throwable)
           
 void registerCollisionGroup(CollisionGroup group)
           
 void registerCollisionGroups(java.util.ArrayList<CollisionGroup> groups)
           
 void registerVariable(YoVariable variable)
           
 void removeSimulateDoneListener(SimulationDoneListener listener)
           
 void setDT(double simulateDT, int recordFrequency)
           
 void setRecordDT(double recordDT)
           
 void setRobots(Robot[] robots)
           
 void setSimulateDoneCriterion(SimulationDoneCriterion criterion)
           
 void setupSimulationGraphics(java.util.ArrayList<GraphicsRobot> graphicsRobotsToUpdate)
           
 void simulate(double simulationTime)
           
 void simulate(int numTicks)
           
 void tickAndUpdate()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Simulation

public Simulation(Robot robot,
                  int dataBufferSize)

Simulation

public Simulation(Robot[] robots,
                  int dataBufferSize)
Method Detail

getDT

public double getDT()

setDT

public void setDT(double simulateDT,
                  int recordFrequency)

setRecordDT

public void setRecordDT(double recordDT)

getRecordFreq

public long getRecordFreq()

addScript

public void addScript(Script script)

getAllVariables

public java.util.ArrayList<YoVariable> getAllVariables()
Description copied from interface: YoVariableHolder
Returns all the YoVariables in this YoVariableHolder

Specified by:
getAllVariables in interface YoVariableHolder
Returns:
ArrayList

getAllVariablesArray

public YoVariable[] getAllVariablesArray()
Description copied from interface: YoVariableHolder
Returns all the YoVariables in this YoVariableHolder

Specified by:
getAllVariablesArray in interface YoVariableHolder
Returns:
YoVariable[]

getVariable

public YoVariable getVariable(java.lang.String varname)
Description copied from interface: YoVariableHolder
Gets a YoVariable with the given name if it is in this YoVariableHolder, otherwise returns null. If name contains a ".", then the YoVariable's nameSpace ending must match that of name. If there is more than one YoVariable that matches, then throws a RuntimeException.

Specified by:
getVariable in interface YoVariableHolder
Parameters:
varname - String Name of YoVariable to get. If contains a ".", then YoVariable's nameSpace ending must match that of name.
Returns:
YoVariable matching the given name.

hasUniqueVariable

public boolean hasUniqueVariable(java.lang.String varname)
Description copied from interface: YoVariableHolder
Checks if this YoVariableHolder holds exactly one YoVariable with the given name. If so, returns true, otherwise returns false. If name contains a ".", then the YoVariable's nameSpace ending must match that of name. If there is more than one YoVariable that matches, returns false.

Specified by:
hasUniqueVariable in interface YoVariableHolder
Parameters:
varname - String Name of YoVariable to check for. If contains a ".", then YoVariable's nameSpace ending must match that of name.
Returns:
boolean Whether or not this YoVariableHolder holds exactly one Variable of the given name.

getVariable

public YoVariable getVariable(java.lang.String nameSpace,
                              java.lang.String varname)
Description copied from interface: YoVariableHolder
Gets a YoVariable with the given nameSpace and name if it is in this YoVariableHolder, otherwise returns null. If name contains a ".", then throws a RuntimeException. If there is more than one YoVariable that matches, then throws a RuntimeException.

Specified by:
getVariable in interface YoVariableHolder
Parameters:
nameSpace - String nameSpaceEnding ending of YoVariable to get. The YoVariable's nameSpace ending must match that of nameSpace.
varname - String Name of YoVariable to get. If contains a ".", then throws a RuntimeException.
Returns:
YoVariable matching the given nameSpace and name.

hasUniqueVariable

public boolean hasUniqueVariable(java.lang.String nameSpace,
                                 java.lang.String varname)
Description copied from interface: YoVariableHolder
Checks if this YoVariableHolder holds exactly one YoVariable with the given nameSpace and name. If so, returns true, otherwise returns false. If name contains a ".", then throws a RuntimeException. If there is more than one YoVariable that matches, returns false.

Specified by:
hasUniqueVariable in interface YoVariableHolder
Parameters:
nameSpace - String NameSpace ending of YoVariable to check for. The YoVariable's nameSpace ending must match that of nameSpace.
varname - String Name of YoVariable to check for. If contains a ".", then throws a RuntimeException.
Returns:
boolean Whether or not this YoVariableHolder holds exactly one Variable that matches the given nameSpace and name.

getVariables

public java.util.ArrayList<YoVariable> getVariables(java.lang.String nameSpace,
                                                    java.lang.String varname)
Description copied from interface: YoVariableHolder
Returns all the YoVariables with the given nameSpace and name that are in this YoVariableHolder, empty if there are none. If name contains a ".", then throws a RuntimeException.

Specified by:
getVariables in interface YoVariableHolder
Parameters:
nameSpace - String NameSpace ending of YoVariables to get. The YoVariable's nameSpace ending must match that of nameSpace.
varname - String Name of YoVariable to get. If contains a ".", then throws a RuntimeException.
Returns:
ArrayList matching the given nameSpace and name.

getVariables

public java.util.ArrayList<YoVariable> getVariables(java.lang.String varname)
Description copied from interface: YoVariableHolder
Returns all the YoVariables with the given name that are in this YoVariableHolder, empty if there are none. If name contains a ".", then the YoVariable's nameSpace ending must match that of name.

Specified by:
getVariables in interface YoVariableHolder
Parameters:
varname - String Name of YoVariable to get. If name contains a ".", then the YoVariable's nameSpace ending must match that of name.
Returns:
ArrayList matching the given name.

getVariables

public java.util.ArrayList<YoVariable> getVariables(NameSpace nameSpace)
Description copied from interface: YoVariableHolder
Returns all the YoVariables with the given nameSpace that are in this YoVariableHolder, empty if there are none.

Specified by:
getVariables in interface YoVariableHolder
Parameters:
nameSpace - NameSpace to match.
Returns:
ArrayList matching YoVariables.

registerVariable

public void registerVariable(YoVariable variable)

getVariablesThatContain

public java.util.ArrayList<YoVariable> getVariablesThatContain(java.lang.String searchString,
                                                               boolean caseSensitive)

getVariablesThatStartWith

public java.util.ArrayList<YoVariable> getVariablesThatStartWith(java.lang.String searchString)

getVars

public java.util.ArrayList<YoVariable> getVars(java.lang.String[] varNames,
                                               java.lang.String[] regularExpressions)

closeAndDispose

public void closeAndDispose()

setRobots

public void setRobots(Robot[] robots)

getDataBuffer

public DataBuffer getDataBuffer()

getRobots

public Robot[] getRobots()

getCombinedVarList

public VarList getCombinedVarList()

setSimulateDoneCriterion

public void setSimulateDoneCriterion(SimulationDoneCriterion criterion)

addSimulateDoneListener

public void addSimulateDoneListener(SimulationDoneListener listener)

removeSimulateDoneListener

public void removeSimulateDoneListener(SimulationDoneListener listener)

notifySimulateDoneListeners

public void notifySimulateDoneListeners()

notifySimulateDoneListenersOfException

public void notifySimulateDoneListenersOfException(java.lang.Throwable throwable)

checkSimulateDoneCriterion

public boolean checkSimulateDoneCriterion()

simulate

public void simulate(int numTicks)
              throws UnreasonableAccelerationException
Throws:
UnreasonableAccelerationException

tickAndUpdate

public void tickAndUpdate()

simulate

public void simulate(double simulationTime)
              throws UnreasonableAccelerationException
Throws:
UnreasonableAccelerationException

setupSimulationGraphics

public void setupSimulationGraphics(java.util.ArrayList<GraphicsRobot> graphicsRobotsToUpdate)

getSimulationGraphics

public Graphics3DAdapter getSimulationGraphics()

addVarList

public void addVarList(VarList newVarList)
                throws DataBuffer.RepeatDataBufferEntryException
Throws:
DataBuffer.RepeatDataBufferEntryException

registerCollisionGroup

public void registerCollisionGroup(CollisionGroup group)

registerCollisionGroups

public void registerCollisionGroups(java.util.ArrayList<CollisionGroup> groups)

getSimulationSynchronizer

public SimulationSynchronizer getSimulationSynchronizer()