mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[wpilibj] Use DS cache for iterative robot control word cache (#3748)
The root cause of #3747 is CommandScheduler's ds state checks are behind iterative robots checks. This means that the iterative robot state could return enabled, but the DS cache could still be reporting disabled. This results in a race in the Disabled -> Enabled transition, which manifests in commands not running. Previously, iterative robot base pulled from the DS cache. This meant that the ds cache was always updated before an iterative robot base loop could run. This still had a race, but this could only occur on the Enabled -> Disable transition, which is much less noticeable and would usually just result in a command running for an extra loop. We can move back to the old behavior by grabbing the new iterative robot base check variables to use the DS cache.
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import edu.wpi.first.hal.ControlWord;
|
||||
import edu.wpi.first.hal.HAL;
|
||||
|
||||
/** A wrapper around Driver Station control word. */
|
||||
public class DSControlWord {
|
||||
@@ -22,7 +21,7 @@ public class DSControlWord {
|
||||
|
||||
/** Update internal Driver Station control word. */
|
||||
public void update() {
|
||||
HAL.getControlWord(m_controlWord);
|
||||
DriverStation.updateControlWordFromCache(m_controlWord);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1324,6 +1324,18 @@ public class DriverStation {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces a control word cache update, and update the passed in control word.
|
||||
*
|
||||
* @param word Word to update.
|
||||
*/
|
||||
public static void updateControlWordFromCache(ControlWord word) {
|
||||
synchronized (m_controlWordMutex) {
|
||||
updateControlWord(true);
|
||||
word.update(m_controlWordCache);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the data in the control word cache. Updates if the force parameter is set, or if 50ms
|
||||
* have passed since the last update.
|
||||
|
||||
Reference in New Issue
Block a user