11#include <wpi/driverstation/MatchState.hpp>
12#include <wpi/driverstation/RobotState.hpp>
13#include <wpi/system/Notifier.hpp>
20class AutoFeedEnable final {
24 static AutoFeedEnable &autoFeedEnable = *
new AutoFeedEnable{};
25 return autoFeedEnable;
30 wpi::Notifier _enableNotifier;
31 uint32_t _startCount = 0;
35 std::string_view robotMode;
36 if (wpi::RobotState::IsEnabled()) {
39 switch (wpi::RobotState::GetRobotMode()) {
40 case wpi::RobotMode::UNKNOWN:
42 robotMode =
"Unknown";
44 case wpi::RobotMode::AUTONOMOUS:
45 robotMode =
"Autonomous";
47 case wpi::RobotMode::TELEOPERATED:
50 case wpi::RobotMode::UTILITY:
51 robotMode =
"Utility";
57 if (wpi::RobotState::IsEStopped()) {
58 robotMode =
"EStopped";
60 robotMode =
"Disabled";
64 std::string_view allianceStation{};
66 auto const alliance = wpi::MatchState::GetAlliance();
67 auto const location = wpi::MatchState::GetLocation();
68 if (alliance && location) {
70 case wpi::Alliance::RED:
73 allianceStation =
"Red 1";
76 allianceStation =
"Red 2";
79 allianceStation =
"Red 3";
85 case wpi::Alliance::BLUE:
88 allianceStation =
"Blue 1";
91 allianceStation =
"Blue 2";
94 allianceStation =
"Blue 3";
119 std::lock_guard<std::mutex> lock{_lck};
120 if (_startCount < UINT32_MAX) {
121 if (_startCount++ == 0) {
123 _enableNotifier.StartPeriodic(10_ms);
135 std::lock_guard<std::mutex> lock{_lck};
136 if (_startCount > 0) {
137 if (--_startCount == 0) {
139 _enableNotifier.Stop();
static ctre::phoenix::StatusCode WriteBoolean(std::string_view name, bool value, wpi::units::second_t latencySeconds=0_s)
Writes the boolean to the log file.
Definition SignalLogger.hpp:333
static ctre::phoenix::StatusCode WriteString(std::string_view name, std::string_view value, wpi::units::second_t latencySeconds=0_s)
Writes the string to the log file.
Definition SignalLogger.hpp:388
Definition AutoFeedEnable.hpp:20
void Start()
Starts feeding the enable signal to CTRE actuators.
Definition AutoFeedEnable.hpp:117
static AutoFeedEnable & GetInstance()
Definition AutoFeedEnable.hpp:22
void Stop()
Stops feeding the enable signal to CTRE actuators.
Definition AutoFeedEnable.hpp:133
Definition CallbackHelper.hpp:13
Definition ExternalFeedbackConfigs.hpp:16
CTREXPORT void FeedEnable(int timeoutMs)
Feed the robot enable.
Definition motor_constants.h:14