20#include "wpi/units/time.hpp"
39class DriverStationBackend final {
335 std::string_view group, std::string_view description,
352 std::string_view group = {},
353 std::string_view description = {});
592 DriverStationBackend() =
default;
WPI_Handle WPI_EventHandle
An event handle.
Definition Synchronization.h:18
@ name
Definition base.h:690
A wrapper around Driver Station control word.
Definition DriverStationTypes.hpp:29
bool IsTeleopEnabled() const
Check if the DS is commanding teleop mode and if it has enabled the robot.
Definition DriverStationTypes.hpp:172
bool IsEnabled() const
Check if the DS has enabled the robot.
Definition DriverStationTypes.hpp:91
RobotMode GetRobotMode() const
Gets the current robot mode.
Definition DriverStationTypes.hpp:101
bool IsUtility() const
Check if the DS is commanding utility mode.
Definition DriverStationTypes.hpp:181
bool IsAutonomousEnabled() const
Check if the DS is commanding autonomous mode and if it has enabled the robot.
Definition DriverStationTypes.hpp:155
bool IsAutonomous() const
Check if the DS is commanding autonomous mode.
Definition DriverStationTypes.hpp:146
bool IsDSAttached() const
Check if the DS is attached.
Definition DriverStationTypes.hpp:139
bool IsFMSAttached() const
Is the driver station attached to a Field Management System?
Definition DriverStationTypes.hpp:132
bool IsEStopped() const
Check if the robot is e-stopped.
Definition DriverStationTypes.hpp:124
bool IsUtilityEnabled() const
Check if the DS is commanding utility mode and if it has enabled the robot.
Definition DriverStationTypes.hpp:189
bool IsTeleop() const
Check if the DS is commanding teleop mode.
Definition DriverStationTypes.hpp:164
static bool IsDisabled()
Check if the robot is disabled.
Definition DriverStationBackend.hpp:253
static RobotMode GetRobotMode()
Gets the current robot mode.
Definition DriverStationBackend.hpp:270
static bool GetJoystickIsGamepad(int stick)
Returns a boolean indicating if the controller is an xbox controller.
static bool IsEStopped()
Check if the robot is e-stopped.
Definition DriverStationBackend.hpp:260
static bool IsAutonomous()
Check if the DS is commanding autonomous mode.
Definition DriverStationBackend.hpp:277
static int GetStickButtonsMaximumIndex(int stick)
Returns the maximum button index on a given joystick port.
static bool GetStickButtonReleased(int stick, int button)
Whether one joystick button was released since the last check.
static uint64_t GetStickButtons(int stick)
The state of the buttons on the joystick.
static bool IsTeleop()
Check if the DS is commanding teleop mode.
Definition DriverStationBackend.hpp:295
static int64_t AddOpMode(RobotMode mode, std::string_view name, std::string_view group, std::string_view description, const wpi::util::Color &textColor, const wpi::util::Color &backgroundColor)
Adds an operating mode option.
static std::string GetEventName()
Returns the name of the competition event provided by the FMS.
static bool IsUtility()
Check if the DS is commanding utility mode.
Definition DriverStationBackend.hpp:310
static int GetReplayNumber()
Returns the number of times the current match has been replayed from the FMS.
static std::string GetJoystickName(int stick)
Returns the name of the joystick at the given port.
static TouchpadFinger GetStickTouchpadFinger(int stick, int touchpad, int finger)
Get the finger data of a touchpad on a joystick, if available.
static int GetStickAxesAvailable(int stick)
Returns the mask of available axes on a given joystick port.
static void ObserveUserProgramStarting()
Sets the program starting flag in the DS.
static constexpr int JOYSTICK_PORTS
Number of Joystick ports.
Definition DriverStationBackend.hpp:42
static bool IsTeleopEnabled()
Check if the DS is commanding teleop mode and if it has enabled the robot.
Definition DriverStationBackend.hpp:303
static bool IsEnabled()
Check if the DS has enabled the robot.
Definition DriverStationBackend.hpp:243
static std::optional< std::string > GetGameData()
Returns the game specific message provided by the FMS.
static int GetJoystickGamepadType(int stick)
Returns the type of joystick at a given port.
static double GetStickAxis(int stick, int axis)
Get the value of the axis on a joystick.
static bool GetStickTouchpadFingerAvailable(int stick, int touchpad, int finger)
Whether a finger on a touchpad is available.
static bool GetStickButton(int stick, int button)
The state of one joystick button.
static int GetMatchNumber()
Returns the match number provided by the FMS.
static void StartDataLog(wpi::log::DataLog &log, bool logJoysticks=true)
Starts logging DriverStation data to data log.
static bool IsJoystickConnected(int stick)
Returns if a joystick is connected to the Driver Station.
static std::optional< int > GetLocation()
Return the driver station location from the FMS.
static int64_t GetOpModeId()
Gets the operating mode selected on the driver station.
static void ProvideRefreshedDataEventHandle(WPI_EventHandle handle)
Registers the given handle for DS data refresh notifications.
static std::optional< double > GetStickAxisIfAvailable(int stick, int axis)
Get the value of the axis on a joystick, if available.
static int64_t RemoveOpMode(RobotMode mode, std::string_view name)
Removes an operating mode option.
static bool IsUtilityEnabled()
Check if the DS is commanding Utility mode and if it has enabled the robot.
Definition DriverStationBackend.hpp:318
static std::string GetOpMode()
Gets the operating mode selected on the driver station.
static int GetStickAxesMaximumIndex(int stick)
Returns the maximum axis index on a given joystick port.
static bool GetStickButtonPressed(int stick, int button)
Whether one joystick button was pressed since the last check.
static void ClearOpModes()
Clears all operating mode options and publishes an empty list to the driver station.
static bool IsOpMode(int64_t id)
Check to see if the selected operating mode is a particular value.
Definition DriverStationBackend.hpp:421
static bool IsJoystickConnectionWarningSilenced()
Returns whether joystick connection warnings are silenced.
static wpi::units::second_t GetMatchTime()
Return the approximate match time.
static bool IsFMSAttached()
Is the driver station attached to a Field Management System?
Definition DriverStationBackend.hpp:445
static bool IsOpMode(std::string_view mode)
Check to see if the selected operating mode is a particular value.
Definition DriverStationBackend.hpp:430
static void SilenceJoystickConnectionWarning(bool silence)
Allows the user to specify whether they want joystick connection warnings to be printed to the consol...
static double GetBatteryVoltage()
Read the battery voltage.
static int GetStickPOVsAvailable(int stick)
Returns the mask of available POVs on a given joystick port.
static std::optional< Alliance > GetAlliance()
Get the current alliance from the FMS.
static int GetStickPOVsMaximumIndex(int stick)
Returns the maximum POV index on a given joystick port.
static int64_t AddOpMode(RobotMode mode, std::string_view name, std::string_view group={}, std::string_view description={})
Adds an operating mode option.
static uint64_t GetStickButtonsAvailable(int stick)
Returns the mask of available buttons on a given joystick port.
static bool IsAutonomousEnabled()
Check if the DS is commanding autonomous mode and if it has enabled the robot.
Definition DriverStationBackend.hpp:286
static void PublishOpModes()
Publishes the operating mode options to the driver station.
static hal::ControlWord GetControlWord()
Get the current control word.
Definition DriverStationBackend.hpp:543
static void RemoveRefreshedDataEventHandle(WPI_EventHandle handle)
Unregisters the given handle from DS data refresh notifications.
static void RefreshData()
Copy data from the DS task for the user.
static bool IsDSAttached()
Check if the DS is attached.
Definition DriverStationBackend.hpp:437
static int GetJoystickSupportedOutputs(int stick)
Returns the number of outputs supported by the joystick at the given port.
static POVDirection GetStickPOV(int stick, int pov)
Get the state of a POV on the joystick.
static std::optional< bool > GetStickButtonIfAvailable(int stick, int button)
The state of one joystick button, only if available.
static MatchType GetMatchType()
Returns the type of match being played provided by the FMS.
A data log for high-speed writing of data values.
Definition DataLog.hpp:69
Represents colors that can be used with Addressable LEDs.
Definition Color.hpp:42
RobotMode
The overall robot mode (not including enabled state).
Definition DriverStationTypes.hpp:15
ControlWord GetControlWord()
Definition DriverStation.hpp:11
Definition DriverStationModeThread.hpp:13
Definition DataLogReader.hpp:17
Definition raw_os_ostream.hpp:19
POVDirection
A controller POV direction.
Definition POVDirection.hpp:18
MatchType
The type of robot match that the robot is part of.
Definition MatchType.hpp:12
Touchpad finger data from a joystick.
Definition TouchpadFinger.hpp:12