Class Sensor

java.lang.Object
yams.motorcontrollers.simulation.Sensor

public class Sensor extends Object
Sensor class using SimDevice; All fields will use the given supplier on real robots. Fake data is only given when connected to simulation.
  • Constructor Details

    • Sensor

      public Sensor(String sensorName, List<SensorData> sensorFields)
      Sensor constructor, for a sensor that will report the real data when connected to the robot or Simulation GUI data when connected to Sim.
      Parameters:
      sensorName - Name of the sensor.
      sensorFields - List of sensor fields. See SensorData.
    • Sensor

      public Sensor(SensorConfig cfg)
      Sensor simulation constructor.
      Parameters:
      cfg - SensorConfig class
  • Method Details

    • getField

      public SensorData getField(String name)
      Get a field from the simulated or real sensor.
      Parameters:
      name - Name of the field
      Returns:
      SensorData of the field.
    • getAsDouble

      public double getAsDouble(String name)
      Get a field from the simulated or real sensor.
      Parameters:
      name - Name of the field
      Returns:
      Value of the field as a double.
    • getAsInt

      public int getAsInt(String name)
      Get a field from the simulated or real sensor.
      Parameters:
      name - Name of the field
      Returns:
      Value of the field as an int.
    • getAsBoolean

      public boolean getAsBoolean(String name)
      Get a field from the simulated or real sensor.
      Parameters:
      name - Name of the field
      Returns:
      Value of the field as a boolean.
    • getAsLong

      public long getAsLong(String name)
      Get a field from the simulated or real sensor.
      Parameters:
      name - Name of the field
      Returns:
      Value of the field as a long.
    • getDevice

      public Optional<SimDevice> getDevice()
      Get the simulated device.
      Returns:
      Simulated device.
    • addSimTrigger

      public void addSimTrigger(String field, HALValue value, BooleanSupplier trigger)
      Set a simulated value based on a trigger.
      Parameters:
      field - Field name to set.
      value - HALValue to set.
      trigger - BooleanSupplier when to use.