Class DistanceSensorDevice
java.lang.Object
com.cdarobotics.cdalib.devices.Device
com.cdarobotics.cdalib.devices.sensors.DistanceSensorDevice
A
Device wrapping a DistanceSensor. The distance is read once per update()
(in centimetres) and cached; getDistance(DistanceUnit) converts the cached reading into
any requested unit without touching hardware again.
Getters reflect the value from the most recent update().
-
Constructor Summary
ConstructorsConstructorDescriptionDistanceSensorDevice(com.qualcomm.robotcore.hardware.DistanceSensor sensor) Wraps an already-resolved distance sensor.DistanceSensorDevice(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String name) Resolves the distance sensor from the hardware map by configured name. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetDistance(org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit unit) doublecom.qualcomm.robotcore.hardware.DistanceSensorvoidupdate()Flush pending writes to, or refresh cached reads from, the underlying hardware.
-
Constructor Details
-
DistanceSensorDevice
public DistanceSensorDevice(com.qualcomm.robotcore.hardware.DistanceSensor sensor) Wraps an already-resolved distance sensor. -
DistanceSensorDevice
Resolves the distance sensor from the hardware map by configured name.
-
-
Method Details
-
getDistanceCm
public double getDistanceCm()- Returns:
- the last measured distance in centimetres.
-
getSensor
public com.qualcomm.robotcore.hardware.DistanceSensor 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.