Class SensorData

java.lang.Object
yams.motorcontrollers.simulation.SensorData

public class SensorData extends Object
Sensor data class to encapsulate sensor data.
  • Constructor Details

  • Method Details

    • convert

      public static Supplier<HALValue> convert(DoubleSupplier supplier)
      Convert a DoubleSupplier into a Supplier<HALValue>.
      Parameters:
      supplier - Double supplier.
      Returns:
      HALValue supplier.
    • convert

      public static Supplier<HALValue> convert(IntSupplier supplier)
      Convert an IntSupplier into a Supplier<HALValue>.
      Parameters:
      supplier - Int supplier.
      Returns:
      HALValue supplier.
    • convert

      public static Supplier<HALValue> convert(BooleanSupplier supplier)
      Convert a BooleanSupplier into a Supplier<HALValue>.
      Parameters:
      supplier - Boolean supplier.
      Returns:
      HALValue supplier.
    • convert

      public static Supplier<HALValue> convert(LongSupplier supplier)
      Convert a LongSupplier into a Supplier<HALValue>.
      Parameters:
      supplier - Long supplier.
      Returns:
      Supplier<HALValue>.
    • convert

      public static HALValue convert(double value)
      Convert a double into a HALValue.
      Parameters:
      value - Double value.
      Returns:
      HALValue.
    • convert

      public static HALValue convert(int value)
      Convert an int into a HALValue.
      Parameters:
      value - Int value.
      Returns:
      HALValue.
    • convert

      public static HALValue convert(boolean value)
      Convert a boolean into a HALValue.
      Parameters:
      value - Boolean value.
      Returns:
      HALValue.
    • convert

      public static HALValue convert(long value)
      Convert a long into a HALValue.
      Parameters:
      value - Long value.
      Returns:
      HALValue.
    • getAsDouble

      public double getAsDouble()
      Get the sensor value as a double.
      Returns:
      Sensor value.
    • getAsInt

      public int getAsInt()
      Get the sensor value as an int.
      Returns:
      Sensor value.
    • getAsLong

      public long getAsLong()
      Get the sensor value as a long.
      Returns:
      Sensor value.
    • getAsBoolean

      public boolean getAsBoolean()
      Get the sensor value as a boolean.
      Returns:
      Sensor value.
    • set

      public void set(HALValue val)
      Set the sensor value.
      Parameters:
      val - Value to set.
    • set

      public void set(int val)
      Set the sensor value.
      Parameters:
      val - Integer value to set.
      Implementation Note:
      The value is not checked for validity, ensure that this is the right data type for the field.
    • set

      public void set(double val)
      Set the sensor value.
      Parameters:
      val - Double value to set.
      Implementation Note:
      The value is not checked for validity, ensure that this is the right data type for the field.
    • set

      public void set(long val)
      Set the sensor value.
      Parameters:
      val - Long value to set.
      Implementation Note:
      The value is not checked for validity, ensure that this is the right data type for the field.
    • set

      public void set(boolean val)
      Set the sensor value.
      Parameters:
      val - Boolean value to set.
      Implementation Note:
      The value is not checked for validity, ensure that this is the right data type for the field.
    • getValue

      public HALValue getValue()
      Get the sensor value, real sensor value if the robot is real.
      Returns:
      Sensor value.
    • addSimTrigger

      public void addSimTrigger(HALValue value, BooleanSupplier trigger)
      Add a value set based on a trigger.
      Parameters:
      value - HALValue to set.
      trigger - BooleanSupplier when to use.
    • getName

      public String getName()
      Get the sensor name.
      Returns:
      Sensor name.
    • getType

      public SensorData.HALValueType getType()
      Get the sensor data type.
      Returns:
      SensorData.HALValueType
    • getDefault

      public HALValue getDefault()
      Get the default value.
      Returns:
      HALValue default value.
    • createValue

      public SimValue createValue(SimDevice device, SimDevice.Direction direction)
      Get the SimValue for the sensor.
      Parameters:
      device - SimDevice to create the SimValue for.
      direction - SimDevice.Direction of the SimValue.
      Returns:
      SimValue for the sensor.