mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Add option to flush NetworkTables every iterative loop
This functionality is disabled by default, but can be enabled by the user program by calling setNetworkTablesFlushEnabled.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "frc/IterativeRobotBase.h"
|
||||
|
||||
#include <hal/DriverStation.h>
|
||||
#include <networktables/NetworkTableInstance.h>
|
||||
#include <wpi/Format.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
@@ -98,6 +99,10 @@ void IterativeRobotBase::TestPeriodic() {
|
||||
}
|
||||
}
|
||||
|
||||
void IterativeRobotBase::SetNetworkTablesFlushEnabled(bool enabled) {
|
||||
m_ntFlushEnabled = enabled;
|
||||
}
|
||||
|
||||
void IterativeRobotBase::LoopFunc() {
|
||||
m_watchdog.Reset();
|
||||
|
||||
@@ -179,6 +184,9 @@ void IterativeRobotBase::LoopFunc() {
|
||||
|
||||
m_watchdog.Disable();
|
||||
|
||||
// Flush NetworkTables
|
||||
if (m_ntFlushEnabled) nt::NetworkTableInstance::GetDefault().Flush();
|
||||
|
||||
// Warn on loop time overruns
|
||||
if (m_watchdog.IsExpired()) {
|
||||
m_watchdog.PrintEpochs();
|
||||
|
||||
Reference in New Issue
Block a user