Class Device

java.lang.Object
me.autobot.lib.robot.Device
All Implemented Interfaces:
Logger
Direct Known Subclasses:
Motor, Sensor

public class Device extends Object implements Logger
Some sort of device that can be attached to a robot.
  • Field Details

    • devices

      protected static ArrayList<Device> devices
      List of all devices.
  • Constructor Details

    • Device

      public Device()
      Creates a new device.
  • Method Details

    • registerDevice

      public static void registerDevice(Device device)
      Registers a device.
      Parameters:
      device - The device to register.
    • emergencyStopAll

      public static void emergencyStopAll()
      Emergency stops all devices. Used in emergencies.
    • setProperty

      public void setProperty(String key, double value)
      Sets a property of the device.
      Parameters:
      key - The key of the property.
      value - The value of the property.
    • getProperties

      public HashMap<String,Double> getProperties()
      Returns the properties of the device.
      Returns:
      The properties of the device.
    • getProperty

      public double getProperty(String key)
      Get a property of the device.
      Parameters:
      key - The key of the property.
      Returns:
      The value of the property.
    • getVoltage

      public double getVoltage()
      Get the voltage of the device (if applicable).
      Returns:
      The voltage of the device.
    • getCurrent

      public double getCurrent()
      Get the current of the device (if applicable).
      Returns:
      The current of the device.
    • emergencyStop

      public void emergencyStop()
      Called to emergency stop the device. This means: stop all motors, turn off all LEDs, etc. Literally stop everything.
    • setParent

      public void setParent(Robot parent)
      Set the parent of the device, i.e what robot the device is attached to.
      Parameters:
      parent - The parent of the device.
    • enableSimulation

      public void enableSimulation()
      Enable simulation mode for the device.
    • inSimulation

      public boolean inSimulation()
      Check if the device is in simulation mode.
      Returns:
      true if the device is in simulation mode.
    • getParent

      protected Robot getParent()
      Get the parent of the device.
      Returns:
      The parent of the device.