Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions yams/java/yams/mechanisms/positional/Pivot.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,19 @@ public void simIterate()
m_smc.getSimSupplier().get().starveUpdateSim();
if (m_config.getLowerHardLimit().isPresent() && m_dcmotorSim.get().getAngularVelocityRadPerSec() < 0 &&
m_smc.getMechanismPosition().lt(m_config.getLowerHardLimit().get()))
// Stop the motor from moving further in the direction of the hard limit
m_dcmotorSim.get().setAngularVelocity(0);
m_smc.setDutyCycle(0);
{
m_smc.setEncoderPosition(m_config.getLowerHardLimit().get());
}
if (m_config.getUpperHardLimit().isPresent() && m_dcmotorSim.get().getAngularVelocityRadPerSec() > 0 &&
m_smc.getMechanismPosition().gt(m_config.getUpperHardLimit().get()))
{
m_smc.setEncoderPosition(m_config.getUpperHardLimit().get());
// Stop the motor from moving further in the direction of the hard limit
m_dcmotorSim.get().setAngularVelocity(0);
m_smc.setDutyCycle(0);
}
RoboRioSim.setVInVoltage(BatterySim.calculateDefaultBatteryLoadedVoltage(m_dcmotorSim.get()
.getCurrentDrawAmps()));
Expand Down