From 7e00f2d3eb8edf1c15d3ca6836624c08a46d512f Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 24 May 2024 14:02:22 -0700 Subject: [PATCH] [wpilib] Fix docs for Sharp IR simulation (NFC) (#6653) --- .../native/include/frc/simulation/SharpIRSim.h | 17 +++++++++++++++++ .../first/wpilibj/simulation/SharpIRSim.java | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/wpilibc/src/main/native/include/frc/simulation/SharpIRSim.h b/wpilibc/src/main/native/include/frc/simulation/SharpIRSim.h index 8ae43daf23..afbc0f4f9a 100644 --- a/wpilibc/src/main/native/include/frc/simulation/SharpIRSim.h +++ b/wpilibc/src/main/native/include/frc/simulation/SharpIRSim.h @@ -11,11 +11,28 @@ namespace frc { +/** Simulation class for Sharp IR sensors. */ class SharpIRSim { public: + /** + * Constructor. + * + * @param sharpIR The real sensor to simulate + */ explicit SharpIRSim(const SharpIR& sharpIR); + + /** + * Constructor. + * + * @param channel Analog channel for this sensor + */ explicit SharpIRSim(int channel); + /** + * Set the range returned by the distance sensor. + * + * @param rng range of the target returned by the sensor + */ void SetRange(units::centimeter_t rng); private: diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SharpIRSim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SharpIRSim.java index db4785a351..eaf3dcb8b1 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SharpIRSim.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SharpIRSim.java @@ -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); }