Package yams.motorcontrollers.simulation
Class Sensor
java.lang.Object
yams.motorcontrollers.simulation.Sensor
Sensor class using
SimDevice; All fields will use the given supplier on real robots. Fake
data is only given when connected to simulation.-
Constructor Summary
ConstructorsConstructorDescriptionSensor(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.Sensor(SensorConfig cfg) Sensor simulation constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSimTrigger(String field, HALValue value, BooleanSupplier trigger) Set a simulated value based on a trigger.booleangetAsBoolean(String name) Get a field from the simulated or real sensor.doublegetAsDouble(String name) Get a field from the simulated or real sensor.intGet a field from the simulated or real sensor.longGet a field from the simulated or real sensor.Get the simulated device.Get a field from the simulated or real sensor.
-
Constructor Details
-
Sensor
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. SeeSensorData.
-
Sensor
Sensor simulation constructor.- Parameters:
cfg-SensorConfigclass
-
-
Method Details
-
getField
Get a field from the simulated or real sensor.- Parameters:
name- Name of the field- Returns:
SensorDataof the field.
-
getAsDouble
Get a field from the simulated or real sensor.- Parameters:
name- Name of the field- Returns:
- Value of the field as a double.
-
getAsInt
Get a field from the simulated or real sensor.- Parameters:
name- Name of the field- Returns:
- Value of the field as an int.
-
getAsBoolean
Get a field from the simulated or real sensor.- Parameters:
name- Name of the field- Returns:
- Value of the field as a boolean.
-
getAsLong
Get a field from the simulated or real sensor.- Parameters:
name- Name of the field- Returns:
- Value of the field as a long.
-
getDevice
Get the simulated device.- Returns:
- Simulated device.
-
addSimTrigger
Set a simulated value based on a trigger.- Parameters:
field- Field name to set.value-HALValueto set.trigger-BooleanSupplierwhen to use.
-