Class TouchSensorDevice
java.lang.Object
com.cdarobotics.cdalib.devices.Device
com.cdarobotics.cdalib.devices.sensors.TouchSensorDevice
A
Device wrapping a TouchSensor. The sensor is read once per update() and
the result is cached, so any number of isPressed() calls in a loop cost one hardware read.
Getters reflect the value from the most recent update().
-
Constructor Summary
ConstructorsConstructorDescriptionTouchSensorDevice(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String name) Resolves the touch sensor from the hardware map by configured name.TouchSensorDevice(com.qualcomm.robotcore.hardware.TouchSensor sensor) Wraps an already-resolved touch sensor. -
Method Summary
-
Constructor Details
-
TouchSensorDevice
public TouchSensorDevice(com.qualcomm.robotcore.hardware.TouchSensor sensor) Wraps an already-resolved touch sensor. -
TouchSensorDevice
Resolves the touch sensor from the hardware map by configured name.
-
-
Method Details
-
isPressed
public boolean isPressed()- Returns:
- whether the sensor was pressed as of the last
update().
-
getValue
public double getValue()- Returns:
- the raw sensor value (0.0–1.0 for analog touch sensors) as of the last
update().
-
getSensor
public com.qualcomm.robotcore.hardware.TouchSensor getSensor()- Returns:
- the wrapped SDK sensor, for operations not exposed here.
-
update
public void update()Description copied from class:DeviceFlush pending writes to, or refresh cached reads from, the underlying hardware.
-