mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Fix multiple motor safety issues (#4784)
Java was missing the motor safety thread entirely C++ accidentally used a manual reset event, causing the motor safety thread to spin. C++ PWMMotorController would not feed the watch kitty. Both languages would call feed() from the StopMotor call, causing some ping ponging.
This commit is contained in:
@@ -24,7 +24,7 @@ class Thread : public wpi::SafeThread {
|
||||
};
|
||||
|
||||
void Thread::Main() {
|
||||
wpi::Event event{true, false};
|
||||
wpi::Event event{false, false};
|
||||
HAL_ProvideNewDataEventHandle(event.GetHandle());
|
||||
|
||||
int safetyCounter = 0;
|
||||
|
||||
@@ -12,6 +12,7 @@ using namespace frc;
|
||||
|
||||
void PWMMotorController::Set(double speed) {
|
||||
m_pwm.SetSpeed(m_isInverted ? -speed : speed);
|
||||
Feed();
|
||||
}
|
||||
|
||||
double PWMMotorController::Get() const {
|
||||
@@ -31,7 +32,8 @@ void PWMMotorController::Disable() {
|
||||
}
|
||||
|
||||
void PWMMotorController::StopMotor() {
|
||||
Set(0);
|
||||
// Don't use Set(0) as that will feed the watch kitty
|
||||
m_pwm.SetSpeed(0);
|
||||
}
|
||||
|
||||
std::string PWMMotorController::GetDescription() const {
|
||||
|
||||
Reference in New Issue
Block a user