[wpilib] Fix docs for Sharp IR simulation (NFC) (#6653)

This commit is contained in:
Peter Johnson
2024-05-24 14:02:22 -07:00
committed by GitHub
parent 5c5e5af0c6
commit 7e00f2d3eb
2 changed files with 28 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.wpilibj.SharpIR;
/** Simulation class for Sharp IR sensors. */
public class SharpIRSim {
private final SimDouble m_simRange;
@@ -30,10 +31,20 @@ public class SharpIRSim {
m_simRange = simDevice.getDouble("Range (cm)");
}
/**
* Set the range in inches returned by the distance sensor.
*
* @param inches range in inches of the target returned by the sensor
*/
public void setRangeInches(double inches) {
m_simRange.set(Units.inchesToMeters(inches) * 100.0);
}
/**
* Set the range in centimeters returned by the distance sensor.
*
* @param cm range in centimeters of the target returned by the sensor
*/
public void setRangeCm(double cm) {
m_simRange.set(cm);
}