11#include "frc/DriverStation.h"
12#include "frc/Notifier.h"
24 return *autoFeedEnable;
29 frc::Notifier _enableNotifier;
30 uint32_t _startCount = 0;
34 std::string_view robotMode;
35 if (frc::DriverStation::IsEnabled()) {
38 if (frc::DriverStation::IsAutonomous()) {
39 robotMode =
"Autonomous";
40 }
else if (frc::DriverStation::IsTest()) {
48 if (frc::DriverStation::IsEStopped()) {
49 robotMode =
"EStopped";
51 robotMode =
"Disabled";
55 std::string_view allianceStation{};
57 auto const alliance = frc::DriverStation::GetAlliance();
58 auto const location = frc::DriverStation::GetLocation();
59 if (alliance && location) {
61 case frc::DriverStation::Alliance::kRed:
64 allianceStation =
"Red 1";
67 allianceStation =
"Red 2";
70 allianceStation =
"Red 3";
76 case frc::DriverStation::Alliance::kBlue:
79 allianceStation =
"Blue 1";
82 allianceStation =
"Blue 2";
85 allianceStation =
"Blue 3";
110 std::lock_guard<std::mutex> lock{_lck};
111 if (_startCount < UINT32_MAX) {
112 if (_startCount++ == 0) {
114 _enableNotifier.StartPeriodic(10_ms);
126 std::lock_guard<std::mutex> lock{_lck};
127 if (_startCount > 0) {
128 if (--_startCount == 0) {
130 _enableNotifier.Stop();
static ctre::phoenix::StatusCode WriteBoolean(std::string_view name, bool value, units::time::second_t latencySeconds=0_s)
Writes the boolean to the log file.
Definition SignalLogger.hpp:327
static ctre::phoenix::StatusCode WriteString(std::string_view name, std::string_view value, units::time::second_t latencySeconds=0_s)
Writes the string to the log file.
Definition SignalLogger.hpp:382
Definition AutoFeedEnable.hpp:19
void Start()
Starts feeding the enable signal to CTRE actuators.
Definition AutoFeedEnable.hpp:108
static AutoFeedEnable & GetInstance()
Definition AutoFeedEnable.hpp:21
void Stop()
Stops feeding the enable signal to CTRE actuators.
Definition AutoFeedEnable.hpp:124
CTREXPORT void FeedEnable(int timeoutMs)
Feed the robot enable.
Definition motor_constants.h:14