mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Fixed race condition between PIDController enable/disable and PIDWrite() call
To make this work in PIDController.java, the use of synchronized had to be replaced with ReentrantLock and try-catch blocks. The locking in PIDController.java was made equivalent to PIDController.cpp and some existing race conditions in PIDController.java were fixed in the process. Fixes #30.
This commit is contained in:
committed by
Peter Johnson
parent
a76b1aa800
commit
de63e1c8a1
@@ -172,7 +172,11 @@ class PIDController : public LiveWindowSendable, public PIDInterface {
|
||||
std::shared_ptr<PIDSource> m_origSource;
|
||||
LinearDigitalFilter m_filter{nullptr, {}, {}};
|
||||
|
||||
mutable wpi::mutex m_mutex;
|
||||
mutable wpi::mutex m_thisMutex;
|
||||
|
||||
// Ensures when Disable() is called, PIDWrite() won't run if Calculate()
|
||||
// is already running at that time.
|
||||
mutable wpi::mutex m_pidWriteMutex;
|
||||
|
||||
std::unique_ptr<Notifier> m_controlLoop;
|
||||
Timer m_setpointTimer;
|
||||
|
||||
Reference in New Issue
Block a user