Package yams.motorcontrollers.simulation
Class SensorData
java.lang.Object
yams.motorcontrollers.simulation.SensorData
Sensor data class to encapsulate sensor data.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionSensorData(String name, BooleanSupplier supplier, boolean defaultVal) Sensor data constructor.SensorData(String name, DoubleSupplier supplier, double defaultVal) Sensor data constructor.SensorData(String name, IntSupplier supplier, int defaultVal) Sensor data constructor.SensorData(String name, LongSupplier supplier, long defaultVal) Sensor data constructor.SensorData(String name, Supplier<HALValue> supplier, HALValue defaultValue, SensorData.HALValueType type) Sensor data constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSimTrigger(HALValue value, BooleanSupplier trigger) Add a value set based on a trigger.static HALValueconvert(boolean value) Convert a boolean into aHALValue.static HALValueconvert(double value) Convert a double into aHALValue.static HALValueconvert(int value) Convert an int into aHALValue.static HALValueconvert(long value) Convert a long into aHALValue.convert(BooleanSupplier supplier) Convert aBooleanSupplierinto aSupplier<HALValue>.convert(DoubleSupplier supplier) Convert aDoubleSupplierinto aSupplier<HALValue>.convert(IntSupplier supplier) Convert anIntSupplierinto aSupplier<HALValue>.convert(LongSupplier supplier) Convert aLongSupplierinto aSupplier<HALValue>.createValue(SimDevice device, SimDevice.Direction direction) Get theSimValuefor the sensor.booleanGet the sensor value as a boolean.doubleGet the sensor value as a double.intgetAsInt()Get the sensor value as an int.longGet the sensor value as a long.Get the default value.getName()Get the sensor name.getType()Get the sensor data type.getValue()Get the sensor value, real sensor value if the robot is real.voidset(boolean val) Set the sensor value.voidset(double val) Set the sensor value.voidset(int val) Set the sensor value.voidset(long val) Set the sensor value.voidSet the sensor value.
-
Constructor Details
-
SensorData
public SensorData(String name, Supplier<HALValue> supplier, HALValue defaultValue, SensorData.HALValueType type) Sensor data constructor.- Parameters:
name- Name of sensor.supplier-Supplier<HALValue>of sensor. Useconvert(java.util.function.DoubleSupplier)to convert primitive suppliers.defaultValue- Default value of sensor.type-SensorData.HALValueTypeof sensor.
-
SensorData
Sensor data constructor.- Parameters:
name- Name of sensor.supplier-DoubleSuppliersupplierdefaultVal- Double default value.
-
SensorData
Sensor data constructor.- Parameters:
name- Name of sensor.supplier-IntSupplierdefaultVal- Int default value.
-
SensorData
Sensor data constructor.- Parameters:
name- Name of sensor.supplier-BooleanSupplierdefaultVal- Boolean default value.
-
SensorData
Sensor data constructor.- Parameters:
name- Name of sensor.supplier-LongSupplierdefaultVal- Long default value.
-
-
Method Details
-
convert
Convert aDoubleSupplierinto aSupplier<HALValue>.- Parameters:
supplier- Double supplier.- Returns:
- HALValue supplier.
-
convert
Convert anIntSupplierinto aSupplier<HALValue>.- Parameters:
supplier- Int supplier.- Returns:
- HALValue supplier.
-
convert
Convert aBooleanSupplierinto aSupplier<HALValue>.- Parameters:
supplier- Boolean supplier.- Returns:
- HALValue supplier.
-
convert
Convert aLongSupplierinto aSupplier<HALValue>. -
convert
Convert a double into aHALValue.- Parameters:
value- Double value.- Returns:
HALValue.
-
convert
Convert an int into aHALValue.- Parameters:
value- Int value.- Returns:
HALValue.
-
convert
Convert a boolean into aHALValue.- Parameters:
value- Boolean value.- Returns:
HALValue.
-
convert
Convert a long into aHALValue.- 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
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
Get the sensor value, real sensor value if the robot is real.- Returns:
- Sensor value.
-
addSimTrigger
Add a value set based on a trigger.- Parameters:
value-HALValueto set.trigger-BooleanSupplierwhen to use.
-
getName
Get the sensor name.- Returns:
- Sensor name.
-
getType
Get the sensor data type.- Returns:
SensorData.HALValueType
-
getDefault
Get the default value.- Returns:
HALValuedefault value.
-
createValue
Get theSimValuefor the sensor.- Parameters:
device-SimDeviceto create theSimValuefor.direction-SimDevice.Directionof theSimValue.- Returns:
SimValuefor the sensor.
-