![]() |
WPILibC++ 2027.0.0-alpha-4
|
Provide access to the network communication data to / from the Driver Station. More...
#include <wpi/driverstation/DriverStation.hpp>
Classes | |
| struct | TouchpadFinger |
Public Types | |
| enum | Alliance { kRed , kBlue } |
| The robot alliance that the robot is a part of. More... | |
| enum | MatchType { kNone , kPractice , kQualification , kElimination } |
| The type of robot match that the robot is part of. More... | |
| enum | POVDirection : uint8_t { kCenter = HAL_JoystickPOV_kCentered , kUp = HAL_JoystickPOV_kUp , kUpRight = HAL_JoystickPOV_kRightUp , kRight = HAL_JoystickPOV_kRight , kDownRight = HAL_JoystickPOV_kRightDown , kDown = HAL_JoystickPOV_kDown , kDownLeft = HAL_JoystickPOV_kLeftDown , kLeft = HAL_JoystickPOV_kLeft , kUpLeft = HAL_JoystickPOV_kLeftUp } |
| A controller POV direction. More... | |
Static Public Member Functions | |
| static constexpr std::optional< wpi::math::Rotation2d > | GetAngle (POVDirection angle) |
| Gets the angle of a POVDirection. | |
| static bool | GetStickButton (int stick, int button) |
| The state of one joystick button. | |
| static std::optional< bool > | GetStickButtonIfAvailable (int stick, int button) |
| The state of one joystick button, only if available. | |
| static bool | GetStickButtonPressed (int stick, int button) |
| Whether one joystick button was pressed since the last check. | |
| static bool | GetStickButtonReleased (int stick, int button) |
| Whether one joystick button was released since the last check. | |
| static double | GetStickAxis (int stick, int axis) |
| Get the value of the axis on a joystick. | |
| static TouchpadFinger | GetStickTouchpadFinger (int stick, int touchpad, int finger) |
| Get the finger data of a touchpad on a joystick, if available. | |
| static bool | GetStickTouchpadFingerAvailable (int stick, int touchpad, int finger) |
| Whether a finger on a touchpad is available. | |
| static std::optional< double > | GetStickAxisIfAvailable (int stick, int axis) |
| Get the value of the axis on a joystick, if available. | |
| static POVDirection | GetStickPOV (int stick, int pov) |
| Get the state of a POV on the joystick. | |
| static uint64_t | GetStickButtons (int stick) |
| The state of the buttons on the joystick. | |
| static int | GetStickAxesMaximumIndex (int stick) |
| Returns the maximum axis index on a given joystick port. | |
| static int | GetStickAxesAvailable (int stick) |
| Returns the mask of available axes on a given joystick port. | |
| static int | GetStickPOVsMaximumIndex (int stick) |
| Returns the maximum POV index on a given joystick port. | |
| static int | GetStickPOVsAvailable (int stick) |
| Returns the mask of available POVs on a given joystick port. | |
| static int | GetStickButtonsMaximumIndex (int stick) |
| Returns the maximum button index on a given joystick port. | |
| static uint64_t | GetStickButtonsAvailable (int stick) |
| Returns the mask of available buttons on a given joystick port. | |
| static bool | GetJoystickIsGamepad (int stick) |
| Returns a boolean indicating if the controller is an xbox controller. | |
| static int | GetJoystickGamepadType (int stick) |
| Returns the type of joystick at a given port. | |
| static int | GetJoystickSupportedOutputs (int stick) |
| Returns the number of outputs supported by the joystick at the given port. | |
| static std::string | GetJoystickName (int stick) |
| Returns the name of the joystick at the given port. | |
| static bool | IsJoystickConnected (int stick) |
| Returns if a joystick is connected to the Driver Station. | |
| static bool | IsEnabled () |
| Check if the DS has enabled the robot. | |
| static bool | IsDisabled () |
| Check if the robot is disabled. | |
| static bool | IsEStopped () |
| Check if the robot is e-stopped. | |
| static RobotMode | GetRobotMode () |
| Gets the current robot mode. | |
| static bool | IsAutonomous () |
| Check if the DS is commanding autonomous mode. | |
| static bool | IsAutonomousEnabled () |
| Check if the DS is commanding autonomous mode and if it has enabled the robot. | |
| static bool | IsTeleop () |
| Check if the DS is commanding teleop mode. | |
| static bool | IsTeleopEnabled () |
| Check if the DS is commanding teleop mode and if it has enabled the robot. | |
| static bool | IsTest () |
| Check if the DS is commanding test mode. | |
| static bool | IsTestEnabled () |
| Check if the DS is commanding Test mode and if it has enabled the robot. | |
| 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 int64_t | AddOpMode (RobotMode mode, std::string_view name, std::string_view group={}, std::string_view description={}) |
| Adds an operating mode option. | |
| static int64_t | RemoveOpMode (RobotMode mode, std::string_view name) |
| Removes an operating mode option. | |
| static void | PublishOpModes () |
| Publishes the operating mode options to the driver station. | |
| static void | ClearOpModes () |
| Clears all operating mode options and publishes an empty list to the driver station. | |
| static int64_t | GetOpModeId () |
| Gets the operating mode selected on the driver station. | |
| static std::string | GetOpMode () |
| Gets the operating mode selected on the driver station. | |
| static bool | IsOpMode (int64_t id) |
| Check to see if the selected operating mode is a particular value. | |
| static bool | IsOpMode (std::string_view mode) |
| Check to see if the selected operating mode is a particular value. | |
| static bool | IsDSAttached () |
| Check if the DS is attached. | |
| static bool | IsFMSAttached () |
| Is the driver station attached to a Field Management System? | |
| static std::optional< std::string > | GetGameData () |
| Returns the game specific message provided by the FMS. | |
| static std::string | GetEventName () |
| Returns the name of the competition event provided by the FMS. | |
| static MatchType | GetMatchType () |
| Returns the type of match being played provided by the FMS. | |
| static int | GetMatchNumber () |
| Returns the match number provided by the FMS. | |
| static int | GetReplayNumber () |
| Returns the number of times the current match has been replayed from the FMS. | |
| static std::optional< Alliance > | GetAlliance () |
| Get the current alliance from the FMS. | |
| static std::optional< int > | GetLocation () |
| Return the driver station location from the FMS. | |
| static wpi::units::second_t | GetMatchTime () |
| Return the approximate match time. | |
| static double | GetBatteryVoltage () |
| Read the battery voltage. | |
| static hal::ControlWord | GetControlWord () |
| Get the current control word. | |
| static void | RefreshData () |
| Copy data from the DS task for the user. | |
| static void | ProvideRefreshedDataEventHandle (WPI_EventHandle handle) |
| Registers the given handle for DS data refresh notifications. | |
| static void | RemoveRefreshedDataEventHandle (WPI_EventHandle handle) |
| Unregisters the given handle from DS data refresh notifications. | |
| static void | SilenceJoystickConnectionWarning (bool silence) |
| Allows the user to specify whether they want joystick connection warnings to be printed to the console. | |
| static bool | IsJoystickConnectionWarningSilenced () |
| Returns whether joystick connection warnings are silenced. | |
| static void | StartDataLog (wpi::log::DataLog &log, bool logJoysticks=true) |
| Starts logging DriverStation data to data log. | |
Static Public Attributes | |
| static constexpr int | kJoystickPorts = 6 |
| Number of Joystick ports. | |
Provide access to the network communication data to / from the Driver Station.
| enum wpi::DriverStation::POVDirection : uint8_t |
|
static |
Adds an operating mode option.
It's necessary to call PublishOpModes() to make the added modes visible to the driver station.
| mode | robot mode |
| name | name of the operating mode |
| group | group of the operating mode |
| description | description of the operating mode |
| textColor | text color |
| backgroundColor | background color |
|
static |
Adds an operating mode option.
It's necessary to call PublishOpModes() to make the added modes visible to the driver station.
| mode | robot mode |
| name | name of the operating mode |
| group | group of the operating mode |
| description | description of the operating mode |
|
static |
Clears all operating mode options and publishes an empty list to the driver station.
|
static |
Get the current alliance from the FMS.
If the FMS is not connected, it is set from the team alliance setting on the driver station.
|
inlinestaticconstexpr |
Gets the angle of a POVDirection.
| angle | The POVDirection to convert. |
|
static |
Read the battery voltage.
|
inlinestatic |
Get the current control word.
|
static |
Returns the name of the competition event provided by the FMS.
|
static |
Returns the game specific message provided by the FMS.
If the FMS is not connected, it is set from the game data setting on the driver station.
|
static |
Returns the type of joystick at a given port.
This maps to SDL_GamepadType
| stick | The joystick port number |
|
static |
Returns a boolean indicating if the controller is an xbox controller.
| stick | The joystick port number |
|
static |
Returns the name of the joystick at the given port.
| stick | The joystick port number |
|
static |
Returns the number of outputs supported by the joystick at the given port.
| stick | The joystick port number |
|
static |
Return the driver station location from the FMS.
If the FMS is not connected, it is set from the team alliance setting on the driver station.
This could return 1, 2, or 3.
|
static |
Returns the match number provided by the FMS.
|
static |
Return the approximate match time.
The FMS does not send an official match time to the robots, but does send an approximate match time. The value will count down the time remaining in the current period (auto or teleop). Warning: This is not an official time (so it cannot be used to dispute ref calls or guarantee that a function will trigger before the match ends).
When connected to the real field, this number only changes in full integer increments, and always counts down.
When the DS is in practice mode, this number is a floating point number, and counts down.
When the DS is in teleop or autonomous mode, this number returns -1.0.
Simulation matches DS behavior without an FMS connected.
|
static |
Returns the type of match being played provided by the FMS.
|
static |
Gets the operating mode selected on the driver station.
Note this does not mean the robot is enabled; use IsEnabled() for that. In a match, this will indicate the operating mode selected for auto before the match starts (i.e., while the robot is disabled in auto mode); after the auto period ends, this will change to reflect the operating mode selected for teleop.
|
inlinestatic |
Gets the operating mode selected on the driver station.
Note this does not mean the robot is enabled; use IsEnabled() for that. In a match, this will indicate the operating mode selected for auto before the match starts (i.e., while the robot is disabled in auto mode); after the auto period ends, this will change to reflect the operating mode selected for teleop.
|
static |
Returns the number of times the current match has been replayed from the FMS.
|
inlinestatic |
Gets the current robot mode.
Note that this does not indicate whether the robot is enabled or disabled.
|
static |
Returns the mask of available axes on a given joystick port.
| stick | The joystick port number |
|
static |
Returns the maximum axis index on a given joystick port.
| stick | The joystick port number |
|
static |
Get the value of the axis on a joystick.
This depends on the mapping of the joystick connected to the specified port.
| stick | The joystick to read. |
| axis | The analog axis value to read from the joystick. |
|
static |
Get the value of the axis on a joystick, if available.
This depends on the mapping of the joystick connected to the specified port.
| stick | The joystick to read. |
| axis | The analog axis value to read from the joystick. |
|
static |
The state of one joystick button.
Button indexes begin at 0.
| stick | The joystick to read. |
| button | The button index, beginning at 0. |
|
static |
The state of one joystick button, only if available.
Button indexes begin at 0.
| stick | The joystick to read. |
| button | The button index, beginning at 0. |
|
static |
Whether one joystick button was pressed since the last check.
Button indexes begin at 1.
| stick | The joystick to read. |
| button | The button index, beginning at 0. |
|
static |
Whether one joystick button was released since the last check.
Button indexes begin at 1.
| stick | The joystick to read. |
| button | The button index, beginning at 0. |
|
static |
The state of the buttons on the joystick.
| stick | The joystick to read. |
|
static |
Returns the mask of available buttons on a given joystick port.
| stick | The joystick port number |
|
static |
Returns the maximum button index on a given joystick port.
| stick | The joystick port number |
|
static |
Get the state of a POV on the joystick.
|
static |
Returns the mask of available POVs on a given joystick port.
| stick | The joystick port number |
|
static |
Returns the maximum POV index on a given joystick port.
| stick | The joystick port number |
|
static |
Get the finger data of a touchpad on a joystick, if available.
| stick | The joystick to read. |
| touchpad | The touchpad index to read from the joystick. |
| finger | The finger index to read from the touchpad. |
|
static |
Whether a finger on a touchpad is available.
| stick | The joystick to read. |
| touchpad | The touchpad index to read from the joystick. |
| finger | The finger index to read from the touchpad. |
|
inlinestatic |
Check if the DS is commanding autonomous mode.
|
inlinestatic |
Check if the DS is commanding autonomous mode and if it has enabled the robot.
|
inlinestatic |
Check if the robot is disabled.
|
inlinestatic |
Check if the DS is attached.
|
inlinestatic |
Check if the DS has enabled the robot.
|
inlinestatic |
Check if the robot is e-stopped.
|
inlinestatic |
Is the driver station attached to a Field Management System?
|
static |
Returns if a joystick is connected to the Driver Station.
This makes a best effort guess by looking at the reported number of axis, buttons, and POVs attached.
| stick | The joystick port number |
|
static |
Returns whether joystick connection warnings are silenced.
This will always return false when connected to the FMS.
|
inlinestatic |
Check to see if the selected operating mode is a particular value.
Note this does not mean the robot is enabled; use IsEnabled() for that.
| id | operating mode unique ID |
|
inlinestatic |
Check to see if the selected operating mode is a particular value.
Note this does not mean the robot is enabled; use IsEnabled() for that.
| mode | operating mode |
|
inlinestatic |
Check if the DS is commanding teleop mode.
|
inlinestatic |
Check if the DS is commanding teleop mode and if it has enabled the robot.
|
inlinestatic |
Check if the DS is commanding test mode.
|
inlinestatic |
Check if the DS is commanding Test mode and if it has enabled the robot.
|
static |
Registers the given handle for DS data refresh notifications.
| handle | The event handle. |
|
static |
Publishes the operating mode options to the driver station.
|
static |
Copy data from the DS task for the user.
If no new data exists, it will just be returned, otherwise the data will be copied from the DS polling loop.
|
static |
Removes an operating mode option.
It's necessary to call PublishOpModes() to make the removed mode no longer visible to the driver station.
| mode | robot mode |
| name | name of the operating mode |
|
static |
Unregisters the given handle from DS data refresh notifications.
| handle | The event handle. |
|
static |
Allows the user to specify whether they want joystick connection warnings to be printed to the console.
This setting is ignored when the FMS is connected – warnings will always be on in that scenario.
| silence | Whether warning messages should be silenced. |
|
static |
Starts logging DriverStation data to data log.
Repeated calls are ignored.
| log | data log |
| logJoysticks | if true, log joystick data |
|
staticconstexpr |
Number of Joystick ports.