Class SharpIR
java.lang.Object
org.wpilib.hardware.range.SharpIR
- All Implemented Interfaces:
AutoCloseable, TelemetryLoggable
SharpIR analog distance sensor class. These distance measuring sensors output an analog voltage
corresponding to the detection distance.
Teams are advised that the case of these sensors are conductive and grounded, so they should not be mounted on a metallic surface on an FRC robot.
-
Constructor Summary
ConstructorsConstructorDescriptionSharpIR(int channel, double a, double b, double min, double max) Manually construct a SharpIR object. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intGet the analog input channel number.doublegetRange()Get the range in meters from the distance sensor.Gets the telemetry table type.static SharpIRGP2Y0A02YK0F(int channel) Sharp GP2Y0A02YK0F is an analog IR sensor capable of measuring distances from 20 cm to 150 cm.static SharpIRGP2Y0A21YK0F(int channel) Sharp GP2Y0A21YK0F is an analog IR sensor capable of measuring distances from 10 cm to 80 cm.static SharpIRGP2Y0A41SK0F(int channel) Sharp GP2Y0A41SK0F is an analog IR sensor capable of measuring distances from 4 cm to 30 cm.static SharpIRGP2Y0A51SK0F(int channel) Sharp GP2Y0A51SK0F is an analog IR sensor capable of measuring distances from 2 cm to 15 cm.voidlogTo(TelemetryTable table) Logs the object to aTelemetryTable.
-
Constructor Details
-
SharpIR
public SharpIR(int channel, double a, double b, double min, double max) Manually construct a SharpIR object. The distance is computed using this formula: A*v ^ B. Prefer to use one of the static factories to create this device instead.- Parameters:
channel- AnalogInput channela- Constant Ab- Constant Bmin- Minimum distance to report in metersmax- Maximum distance to report in meters
-
-
Method Details
-
GP2Y0A02YK0F
Sharp GP2Y0A02YK0F is an analog IR sensor capable of measuring distances from 20 cm to 150 cm.- Parameters:
channel- Analog input channel the sensor is connected to- Returns:
- sensor object
-
GP2Y0A21YK0F
Sharp GP2Y0A21YK0F is an analog IR sensor capable of measuring distances from 10 cm to 80 cm.- Parameters:
channel- Analog input channel the sensor is connected to- Returns:
- sensor object
-
GP2Y0A41SK0F
Sharp GP2Y0A41SK0F is an analog IR sensor capable of measuring distances from 4 cm to 30 cm.- Parameters:
channel- Analog input channel the sensor is connected to- Returns:
- sensor object
-
GP2Y0A51SK0F
Sharp GP2Y0A51SK0F is an analog IR sensor capable of measuring distances from 2 cm to 15 cm.- Parameters:
channel- Analog input channel the sensor is connected to- Returns:
- sensor object
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getChannel
public int getChannel()Get the analog input channel number.- Returns:
- analog input channel
-
getRange
public double getRange()Get the range in meters from the distance sensor.- Returns:
- range in meters of the target returned by the sensor
-
logTo
Description copied from interface:TelemetryLoggableLogs the object to aTelemetryTable.- Specified by:
logToin interfaceTelemetryLoggable- Parameters:
table- telemetry table
-
getTelemetryType
Description copied from interface:TelemetryLoggableGets the telemetry table type. Default is no specified table type (null). A mismatch in type during logging results in a reported warning, so this should always return the same value.- Specified by:
getTelemetryTypein interfaceTelemetryLoggable- Returns:
- Table type
-