From b43ec87f57063a2c47dd67a5db67f71024c9a60f Mon Sep 17 00:00:00 2001 From: Nick Hadley Date: Sun, 5 Feb 2023 14:58:53 -0500 Subject: [PATCH] [wpilib] ElevatorSim: Fix WouldHitLimit methods (#5057) --- wpilibc/src/main/native/cpp/simulation/ElevatorSim.cpp | 4 ++-- .../java/edu/wpi/first/wpilibj/simulation/ElevatorSim.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wpilibc/src/main/native/cpp/simulation/ElevatorSim.cpp b/wpilibc/src/main/native/cpp/simulation/ElevatorSim.cpp index 529fb1a91a3..43b72db2d21 100644 --- a/wpilibc/src/main/native/cpp/simulation/ElevatorSim.cpp +++ b/wpilibc/src/main/native/cpp/simulation/ElevatorSim.cpp @@ -41,11 +41,11 @@ ElevatorSim::ElevatorSim(const DCMotor& gearbox, double gearing, m_simulateGravity(simulateGravity) {} bool ElevatorSim::WouldHitLowerLimit(units::meter_t elevatorHeight) const { - return elevatorHeight < m_minHeight; + return elevatorHeight <= m_minHeight; } bool ElevatorSim::WouldHitUpperLimit(units::meter_t elevatorHeight) const { - return elevatorHeight > m_maxHeight; + return elevatorHeight >= m_maxHeight; } bool ElevatorSim::HasHitLowerLimit() const { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/ElevatorSim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/ElevatorSim.java index 025260a6910..21486092e3f 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/ElevatorSim.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/ElevatorSim.java @@ -162,7 +162,7 @@ public ElevatorSim( * @return Whether the elevator would hit the lower limit. */ public boolean wouldHitLowerLimit(double elevatorHeightMeters) { - return elevatorHeightMeters < this.m_minHeight; + return elevatorHeightMeters <= this.m_minHeight; } /** @@ -172,7 +172,7 @@ public boolean wouldHitLowerLimit(double elevatorHeightMeters) { * @return Whether the elevator would hit the upper limit. */ public boolean wouldHitUpperLimit(double elevatorHeightMeters) { - return elevatorHeightMeters > this.m_maxHeight; + return elevatorHeightMeters >= this.m_maxHeight; } /**