## jrobots.simulation.simulationObjects
Class JRobot2015

    java.lang.Object
      jrobots.simulation.simulationObjects.AbstractPilot
          jrobots.simulation.simulationObjects.Pilot
              jrobots.simulation.simulationObjects.JRobot2015

All Implemented Interfaces:
  java.io.Serializable

Direct Known Subclasses:
  SimpleSonarBot, SonarShooterBot

    public abstract class JRobot2015

extends Pilot

This is the base class for all JRobots participating in the competition.

The class offers methods for communication with the framework (sensors and actuators).

To be able to participate in the competition, inheritance from this specific class is obligatory. JRobots extending different classes cannot participate.

See Also:
  `actions()`, Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class jrobots.simulation.simulationObjects.Pilot
`Pilot.DropperCommand, Pilot.LauncherAmmunition`

Field Summary

Fields inherited from class jrobots.simulation.simulationObjects.Pilot
`DOWN, LEFT, RIGHT, UP`

Fields inherited from class jrobots.simulation.simulationObjects.AbstractPilot
`memoryConsumption`

Constructor Summary
`JRobot2015()`

Method Summary
`protected abstract void` | `actions()` At every simulation cycle every JRobot plans its next actions.
`protected void` | `addDebugArrow(Vector start, Vector end)` Using this method, you can paint lines onto the arena.
`protected void` | `addDebugCrosshair(Vector position)` Using this method, you can paint a mark onto the arena.
`protected void` | `addDebugLine(Vector p1, Vector p2)` Using this method, you can paint lines onto the arena.
`protected static double` | `getEnergyConsumptionBooster()` The booster needs a lot more energy than the tractors.
`protected static double` | `getEnergyConsumptionEngine()`
`protected static double` | `getEnergyConsumptionGrenade()`
`protected static double` | `getEnergyConsumptionSonarForMeterStdDev()` The more energy, the more exact a sonar result will be.
`protected static double` | `getEnergyProductionPerFrame()` The JRobot aquires a small amount of energy in every simulation cycle.
`protected static int` | `getFramesPerSecond()` The physical duration of each simulated frame is constant (whereas the duration in real time may vary).
`protected static double` | `getGrenadeDamageMax()` The maximum damage is inflicted upon a direct hit - either by the grenade or by stepping on a deployed mine.
`protected static double` | `getGrenadeDamageRadius()` The mine does damage in a medium range.
`protected static double` | `getGrenadeSpeed()` The speed of of a grenade is constant and not influenced by the movement of the JRobot it originates from.
`protected static double` | `getGrenadeTriggerRadius()` A deployed mine triggers its detonation at this given radius.
`protected static double` | `getJRobotLength()` With this value you can estimate distances in the arena visually.
`protected SonarTrace` | `getLastSonarTrace()` Retrieves the latest value of the echolocation device.
`protected static double` | `getMaxArenaDiameter()` Two tanks cannot move farther away from each other than this given distance.
`protected static double` | `getMaxBackwardVelocity()` The maximum speed is reached by accelerating infinitely at one given direction.
`protected static double` | `getMaxForwardVelocity()` The maximum speed is reached by accelerating infinitely at one given direction.
`protected Angle` | `getOrientation()` Retrieves the current orientation of this tank's body.
`protected Vector` | `getPosition()` Retrieves the current absolute position of this JRobot.
`protected ProximityScan` | `getProximityScan()` Other than the radar scanner the proximity scanners are aware of flying or lying small objects - in short: projectiles and droppables.
`protected static double` | `getProximityScannerGroundRange()`
`protected static double` | `getProximityScannerProjectileRange()`
`protected Vector` | `getVelocity()` Retrieves this JRobots current absolute velocity.
`protected void` | `setAutopilot(Angle direction, double speed)` This routine sets the built in 'autopilot' to drive in the given direction with given speed.
`protected void` | `setBodyColor(java.awt.Color newColor)` Changes the painting of the tank's body.
`protected void` | `setBoost()` Fires a mighty booster which lets the tank jump forward.
`protected void` | `setLaunchProjectileCommand(Angle command, double range)` This is the 'launch' button to fire grenades.
`protected void` | `setNameColor(java.awt.Color newNameColor)` Changes the color of the writing which draws this pilot's name.
`protected void` | `setSonarEnergy(double energy)` Sets an amount of energy for the sonar scanner.
`protected void` | `setTurretColor(java.awt.Color newColor)` Changes the painting of the tank's turret.

Methods inherited from class jrobots.simulation.simulationObjects.Pilot
`getBodyColor, getEnergy, getHealth, getName, getNameColor, getTime, getTurretColor, init`

Methods inherited from class jrobots.simulation.simulationObjects.AbstractPilot
`clone`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JRobot2015

    public JRobot2015()

Method Detail

### actions

    protected abstract void actions()

  At every simulation cycle every JRobot plans its next actions. This happens by the framework calling this method.
  Every participant is programming the decisions the JRobot will take in any possible situation. The following allotment of methods will help you in doing so.

  Every JRobot has only limited knowledge of its surroundings. That limit is set by its sensors. Sensors in general are methods starting with `get...`:

  - Common: `Pilot.getTime()`, `Pilot.getEnergy()`, `getEnergyProductionPerFrame()`
  - Movement: `getPosition()`, `getOrientation()`, `getVelocity()`, `getEnergyConsumptionEngine()`,
  - Scanner: `Pilot.getLastScan()`, `#isScanFromNow()`, `Pilot.getScanAperture()`, `getProximityScan()` `getProximityScannerProjectileRange()`, `getProximityScannerGroundRange()` `getEnergyConsumptionSonarForMeterStdDev()`
  - Launcher: `getGrenadeSpeed()`, `getEnergyConsumptionGrenade()`

  The JRobot is called for `actions`, which are will have effect in the next simulation cycle. Issued actions in general are methods starting with `set...`:

  - Scanner: `setSonarEnergy(double)`,
  - Launcher: `setLaunchProjectileCommand(Angle, double)`
  - Movement: `setAutopilot(Angle, double)`, `setBoost()`
  - Debug: `addDebugArrow(Vector, Vector)`, `addDebugCrosshair(Vector)`, `addDebugLine(Vector, Vector)`
  - Style: `setBodyColor(Color)`, `setTurretColor(Color)`, `setNameColor(Color)`

  In package `jrobots.utils` there are several helper classes to be used as necessary.

  - `Vector`
  - `Angle`
  - `SonarTrace`
  - `ProximityScan`
  - `LinearPredictor`

  You may want to add fields to your JRobot class.

  While it is possible to use static fields, these are not affected by the timeline slider in the GUI, which makes debugging less practical. Please don't use static fields while you can avoid it.

  Runtime and memory are watched by the framework. If a reasonable use of the framework is confined by your programming, the responsible JRobot may be expelled from the competition.
  Exceptions will be caught by the framework and the JRobot will be restarted. Please be aware of exceptions on the console, as the robot loses its memory at every restart.

### addDebugArrow

    protected final void addDebugArrow(Vector start,
                                       Vector end)

  Using this method, you can paint lines onto the arena.

  Use this to visualize your data. This is a kind of visual logging and can be quite helpful for debugging.

  The mark will be painted for only one frame. If you want it to last, paint again every frame.

  Parameters:
    `p1` - - starting point of the line
    `p2` - - ending point of the line; this is where the arrow points to

### addDebugCrosshair

    protected final void addDebugCrosshair(Vector position)

  Using this method, you can paint a mark onto the arena.

  Use this to visualize your data. This is a kind of visual logging and can be quite helpful for debugging.

  The mark will be painted for only one frame. If you want it to last, paint again every frame.

  Parameters:
    `p1` - - absolute position of the painted crosshair

### addDebugLine

    protected final void addDebugLine(Vector p1,
                                      Vector p2)

  Using this method, you can paint lines onto the arena.

  Use this to visualize your data. This is a kind of visual logging and can be quite helpful for debugging.

  The mark will be painted for only one frame. If you want it to last, paint again every frame.

  Parameters:
    `p1` - - starting point of the line
    `p2` - - ending point of the line

### getEnergyConsumptionBooster

    protected static final double getEnergyConsumptionBooster()

  The booster needs a lot more energy than the tractors.

  Returns:
    energy consumed by the booster for one simulation cycle

### getEnergyConsumptionEngine

    protected static final double getEnergyConsumptionEngine()

  Returns:
    consumed energy for maximum tractor acceleration ('autopilot' is running at levels -1 or +1)

### getEnergyConsumptionGrenade

    protected static final double getEnergyConsumptionGrenade()

  Returns:
    amount of energy needed for one grenade

### getEnergyConsumptionSonarForMeterStdDev

    protected static final double getEnergyConsumptionSonarForMeterStdDev()

  The more energy, the more exact a sonar result will be.

  Returns:
    energy needed to retrieve one sonar trace with a standard deviation of one meter

### getEnergyProductionPerFrame

    protected static final double getEnergyProductionPerFrame()

  The JRobot aquires a small amount of energy in every simulation cycle. The energy is stored and can be used for arbitrary actions.

  Returns:
    amount of energy the robot generates at each cycle.
    Energy growth is reduced at higher levels of stored energy.

### getFramesPerSecond

    protected static final int getFramesPerSecond()

  The physical duration of each simulated frame is constant (whereas the duration in real time may vary).

  This value is helpful if you want to know the amount of time passed between two calls of `actions()`.

  Returns:
    number of simulation cycles per simulated second [1/s]

### getGrenadeDamageMax

    protected static final double getGrenadeDamageMax()

  The maximum damage is inflicted upon a direct hit - either by the grenade or by stepping on a deployed mine.

  Returns:
    maximum damage of the mine grenade in percent [0; 1]

### getGrenadeDamageRadius

    protected static final double getGrenadeDamageRadius()

  The mine does damage in a medium range.

  Returns:
    detonation radius of the mine in [m]

### getGrenadeSpeed

    protected static final double getGrenadeSpeed()

  The speed of of a grenade is constant and not influenced by the movement of the JRobot it originates from.

  Returns:
    muzzle velocity [m/s]

### getGrenadeTriggerRadius

    protected static final double getGrenadeTriggerRadius()

  A deployed mine triggers its detonation at this given radius.

  Returns:
    mine trigger distance in [m]

### getJRobotLength

    protected static final double getJRobotLength()

  With this value you can estimate distances in the arena visually. It is also relevant for hitting a JRobot.

  Returns:
    Length of a JRobot; [m]

### getLastSonarTrace

    protected final SonarTrace getLastSonarTrace()

  Retrieves the latest value of the echolocation device.

  To be able to retrieve a sonar trace, the device must have been powered by `setSonarEnergy()` at a prior time.

  Note: The value is not consumed by the call. To select only the current value make sure that
  `getLastSonarTrace().timestamp == getTime()` holds.

  Returns:
    the latest sonar trace
    `null`, if there has been no call to `setSonarEnergy()` yet with a positive energy quantity.
  See Also:
    `Pilot.getLastSonarTrace()`

### getMaxArenaDiameter

    protected static final double getMaxArenaDiameter()

  Two tanks cannot move farther away from each other than this given distance. If they try so, they tense an invisible rubber band in between them. The band pulls them back together, but is harmless otherwise.

  Returns:
    Maximum distance between two tanks in [m]; i.e. length of relaxed 'rubber band'

### getMaxBackwardVelocity

    protected static final double getMaxBackwardVelocity()

  The maximum speed is reached by accelerating infinitely at one given direction.

  Returns:
    maximum backward speed [m/s]

### getMaxForwardVelocity

    protected static final double getMaxForwardVelocity()

  The maximum speed is reached by accelerating infinitely at one given direction.

  Returns:
    maximum forward speed [m/s]

### getOrientation

    protected final Angle getOrientation()

  Retrieves the current orientation of this tank's body. This value is not always similar to the direction of the current velocity because of sliding.

  Returns:
    current orientation of this tank's body

### getPosition

    protected final Vector getPosition()

  Retrieves the current absolute position of this JRobot.

  Returns:
    global position of the tank [m]

### getProximityScan

    protected final ProximityScan getProximityScan()

  Other than the radar scanner the proximity scanners are aware of flying or lying small objects - in short: projectiles and droppables.

  Reveals the position of the nearest projectile/droppable or `null` if there is no such object in range of the proximity scanner.

  Own grenades are not spotted by the proximity scanner until they are deployed and readied.

  The usage of the proximity scanner does not consume energy.

  Returns:
    data of the proximity scan (position, velocity, time) or `null`;

### getProximityScannerGroundRange

    protected static final double getProximityScannerGroundRange()

  Returns:
    maximum range of the proximity scanner for deployed objects [m]
  See Also:
    `#getProximityScan()}`

### getProximityScannerProjectileRange

    protected static final double getProximityScannerProjectileRange()

  Returns:
    maximum range of the proximity scanner for incoming flying objects [m]
  See Also:
    `#getProximityScan()}`

### getVelocity

    protected final Vector getVelocity()

  Retrieves this JRobots current absolute velocity.

  Returns:
    vector of current velocity

### setAutopilot

    protected final void setAutopilot(Angle direction,
                                      double speed)

  This routine sets the built in 'autopilot' to drive in the given direction with given speed.

  The tractor speeds will be automatically set so that the tank's bow will point to that direction eventually.

  The autopilot will be executed until a different command tells otherwise.

  The tractors drain energy when moving. The higher the set speed the more.

  The backward speed is slower than the speed forward.

  Parameters:
    `direction` - - direction to point the bow to
    `speed` - - [-1;+1] values greater than zero drive forward; values less than zero drive backward.

### setBodyColor

    protected final void setBodyColor(java.awt.Color newColor)

  Changes the painting of the tank's body.

  As the metal already has a color, applying a white color will not result in a white paint.

### setBoost

    protected final void setBoost()

  Fires a mighty booster which lets the tank jump forward.

  This consumes more energy than moving there by the tractors, but it can even be used to dodge grenades.

  Once executed, the booster burns for some simulation cycles before it ceases.

### setLaunchProjectileCommand

    protected final void setLaunchProjectileCommand(Angle command,
                                                    double range)

  This is the 'launch' button to fire grenades.

  It sets the direction to fire at and a range at which the grenade will detonate/deploy.

  You can launch one projectile per frame at maximum. If there is already a launch command which was not executed yet, that command will be overwritten.

  This command issues only one fire command. As soon at the cannon is available, it will be executed. To fire a second shot, wait for the first shot to be executed, then set the second command.

  Note that firing projectiles costs energy. The command will not be executed if there is not enough energy.

  Parameters:
    `command` - - direction to fire at
    `range` - - distance to detonate
  See Also:
    `Pilot#setLaunchProjectileCommand(Angle)`

### setNameColor

    protected final void setNameColor(java.awt.Color newNameColor)

  Changes the color of the writing which draws this pilot's name.

### setSonarEnergy

    protected final void setSonarEnergy(double energy)

  Sets an amount of energy for the sonar scanner. The resulting sonar trace will be deliverd at the next frame.

  On your JRobot is mounted a passive echolocation device. If powered, it delivers one `SonarTrace` value per frame.
  The trace is not exact. The trace is of higher quality the more energy is spent.

  The set value is consumed at each simulation step. To constantly receive new sonar traces, the setter has to be called at each frame.

  Parameters:
    `energy` - - amount of energy to be spent for the sonar device at the next simulation step
  See Also:
    `utils#SonarTrace`

### setTurretColor

    protected final void setTurretColor(java.awt.Color newColor)

  Changes the painting of the tank's turret.

  As the metal already has a color, applying a white color will not result in a white paint.