16 #include <hal/DriverStationTypes.h>
17 #include <wpi/Twine.h>
18 #include <wpi/condition_variable.h>
19 #include <wpi/deprecated.h>
20 #include <wpi/mutex.h>
22 #include "frc/ErrorBase.h"
23 #include "frc/RobotState.h"
27 class MatchDataSender;
35 enum Alliance { kRed, kBlue, kInvalid };
36 enum MatchType { kNone, kPractice, kQualification, kElimination };
72 static constexpr
int kJoystickPorts = 6;
369 void InDisabled(
bool entering) { m_userInDisabled = entering; }
395 void InTest(
bool entering) { m_userInTest = entering; }
424 void ReportJoystickUnpluggedError(
const wpi::Twine& message);
431 void ReportJoystickUnpluggedWarning(
const wpi::Twine& message);
435 void SendMatchData();
437 std::unique_ptr<MatchDataSender> m_matchDataSender;
440 wpi::mutex m_buttonEdgeMutex;
441 std::array<HAL_JoystickButtons, kJoystickPorts> m_previousButtonStates;
442 std::array<uint32_t, kJoystickPorts> m_joystickButtonsPressed;
443 std::array<uint32_t, kJoystickPorts> m_joystickButtonsReleased;
446 std::thread m_dsThread;
447 std::atomic<bool> m_isRunning{
false};
449 wpi::mutex m_waitForDataMutex;
450 wpi::condition_variable m_waitForDataCond;
451 int m_waitForDataCounter;
454 bool m_userInDisabled =
false;
455 bool m_userInAutonomous =
false;
456 bool m_userInTeleop =
false;
457 bool m_userInTest =
false;
459 double m_nextMessageTime = 0;
bool IsDisabled() const
Check if the robot is disabled.
void InTest(bool entering)
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purpose...
Definition: DriverStation.h:395
bool IsDSAttached() const
Check if the DS is attached.
void GetData()
Copy data from the DS task for the user.
bool IsFMSAttached() const
Is the driver station attached to a Field Management System?
double GetMatchTime() const
Return the approximate match time.
int GetStickAxisCount(int stick) const
Returns the number of axes on a given joystick port.
void WaitForData()
Wait until a new packet comes from the driver station.
MatchType GetMatchType() const
Returns the type of match being played provided by the FMS.
int GetMatchNumber() const
Returns the match number provided by the FMS.
int GetStickPOV(int stick, int pov)
Get the state of a POV on the joystick.
bool GetStickButton(int stick, int button)
The state of one joystick button.
int GetStickPOVCount(int stick) const
Returns the number of POVs on a given joystick port.
bool IsEnabled() const
Check if the DS has enabled the robot.
void InOperatorControl(bool entering)
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purpose...
Definition: DriverStation.h:387
static void ReportWarning(const wpi::Twine &error)
Report a warning to the DriverStation messages window.
double GetStickAxis(int stick, int axis)
Get the value of the axis on a joystick.
bool IsNewControlData() const
Has a new control packet from the driver station arrived since the last time this function was called...
bool IsAutonomous() const
Check if the DS is commanding autonomous mode.
int GetReplayNumber() const
Returns the number of times the current match has been replayed from the FMS.
bool IsTest() const
Check if the DS is commanding test mode.
int GetJoystickType(int stick) const
Returns the type of joystick at a given port.
bool IsEStopped() const
Check if the robot is e-stopped.
bool GetStickButtonPressed(int stick, int button)
Whether one joystick button was pressed since the last check.
bool GetStickButtonReleased(int stick, int button)
Whether one joystick button was released since the last check.
int GetLocation() const
Return the driver station location on the field.
int GetStickButtons(int stick) const
The state of the buttons on the joystick.
Base class for most objects.
Definition: ErrorBase.h:104
static DriverStation & GetInstance()
Return a reference to the singleton DriverStation.
void WakeupWaitForData()
Forces WaitForData() to return immediately.
double GetBatteryVoltage() const
Read the battery voltage.
void InDisabled(bool entering)
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purpose...
Definition: DriverStation.h:369
static void ReportError(const wpi::Twine &error)
Report an error to the DriverStation messages window.
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
std::string GetEventName() const
Returns the name of the competition event provided by the FMS.
std::string GetJoystickName(int stick) const
Returns the name of the joystick at the given port.
bool IsOperatorControl() const
Check if the DS is commanding teleop mode.
Alliance GetAlliance() const
Return the alliance that the driver station says it is on.
void InAutonomous(bool entering)
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purpose...
Definition: DriverStation.h:378
Provide access to the network communication data to / from the Driver Station.
Definition: DriverStation.h:33
bool GetJoystickIsXbox(int stick) const
Returns a boolean indicating if the controller is an xbox controller.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:85
std::string GetGameSpecificMessage() const
Returns the game specific message provided by the FMS.
int GetStickButtonCount(int stick) const
Returns the number of buttons on a given joystick port.
int GetJoystickAxisType(int stick, int axis) const
Returns the types of Axes on a given joystick port.