Simulated sensor backed by a HAL SimDevice.
All fields report the real supplier value on a physical robot. In simulation they surface in the Glass UI and can be overridden with trigger-based values for automated testing scenarios.
Basic usage (construct directly)
wpi::hardware::DigitalInput beamBreak{0};
SensorData{
"Triggered", [&beamBreak] {
return !beamBreak.Get(); },
false},
}};
Definition SensorData.hpp:24
bool GetAsBoolean() const
Builder usage (SimSensorConfig)
wpi::hardware::DigitalInput beamBreak{0};
wpi::hardware::Encoder encoder{1, 2};
SimSensorConfig cfg{"IntakeSensors"};
cfg.WithField("BeamBreak", [&beamBreak] { return !beamBreak.Get(); }, false)
.WithField("EncoderCount", [&encoder] { return encoder.Get(); }, 0)
.WithSimulatedValue("BeamBreak", 1_s, 3_s, true);
Sensor& sensor = cfg.GetSensor();
bool triggered = sensor.GetAsBoolean("BeamBreak");
int ticks = sensor.GetAsInt("EncoderCount");
Sensor(std::string sensorName, std::vector< SensorData > fields)
Trigger-based override
sensor.AddSimTrigger("BeamBreak",
[&arm] { return arm.GetAngle() < 10_deg; });
static HAL_Value Convert(double value)