Skip to content

Commit

Permalink
[wpilib] ElevatorSim: Fix WouldHitLimit methods (#5057)
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley31 authored Feb 5, 2023
1 parent 19267be commit b43ec87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions wpilibc/src/main/native/cpp/simulation/ElevatorSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand Down

0 comments on commit b43ec87

Please sign in to comment.