WPILibC++ 2024.3.2
|
Provide access to the network communication data to / from the Driver Station. More...
#include <frc/DriverStation.h>
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... | |
Static Public Member Functions | |
static bool | GetStickButton (int stick, int button) |
The state of one joystick button. More... | |
static bool | GetStickButtonPressed (int stick, int button) |
Whether one joystick button was pressed since the last check. More... | |
static bool | GetStickButtonReleased (int stick, int button) |
Whether one joystick button was released since the last check. More... | |
static double | GetStickAxis (int stick, int axis) |
Get the value of the axis on a joystick. More... | |
static int | GetStickPOV (int stick, int pov) |
Get the state of a POV on the joystick. More... | |
static int | GetStickButtons (int stick) |
The state of the buttons on the joystick. More... | |
static int | GetStickAxisCount (int stick) |
Returns the number of axes on a given joystick port. More... | |
static int | GetStickPOVCount (int stick) |
Returns the number of POVs on a given joystick port. More... | |
static int | GetStickButtonCount (int stick) |
Returns the number of buttons on a given joystick port. More... | |
static bool | GetJoystickIsXbox (int stick) |
Returns a boolean indicating if the controller is an xbox controller. More... | |
static int | GetJoystickType (int stick) |
Returns the type of joystick at a given port. More... | |
static std::string | GetJoystickName (int stick) |
Returns the name of the joystick at the given port. More... | |
static int | GetJoystickAxisType (int stick, int axis) |
Returns the types of Axes on a given joystick port. More... | |
static bool | IsJoystickConnected (int stick) |
Returns if a joystick is connected to the Driver Station. More... | |
static bool | IsEnabled () |
Check if the DS has enabled the robot. More... | |
static bool | IsDisabled () |
Check if the robot is disabled. More... | |
static bool | IsEStopped () |
Check if the robot is e-stopped. More... | |
static bool | IsAutonomous () |
Check if the DS is commanding autonomous mode. More... | |
static bool | IsAutonomousEnabled () |
Check if the DS is commanding autonomous mode and if it has enabled the robot. More... | |
static bool | IsTeleop () |
Check if the DS is commanding teleop mode. More... | |
static bool | IsTeleopEnabled () |
Check if the DS is commanding teleop mode and if it has enabled the robot. More... | |
static bool | IsTest () |
Check if the DS is commanding test mode. More... | |
static bool | IsTestEnabled () |
Check if the DS is commanding Test mode and if it has enabled the robot. More... | |
static bool | IsDSAttached () |
Check if the DS is attached. More... | |
static bool | IsFMSAttached () |
Is the driver station attached to a Field Management System? More... | |
static std::string | GetGameSpecificMessage () |
Returns the game specific message provided by the FMS. More... | |
static std::string | GetEventName () |
Returns the name of the competition event provided by the FMS. More... | |
static MatchType | GetMatchType () |
Returns the type of match being played provided by the FMS. More... | |
static int | GetMatchNumber () |
Returns the match number provided by the FMS. More... | |
static int | GetReplayNumber () |
Returns the number of times the current match has been replayed from the FMS. More... | |
static std::optional< Alliance > | GetAlliance () |
Get the current alliance from the FMS. More... | |
static std::optional< int > | GetLocation () |
Return the driver station location from the FMS. More... | |
static bool | WaitForDsConnection (units::second_t timeout) |
Wait for a DS connection. More... | |
static units::second_t | GetMatchTime () |
Return the approximate match time. More... | |
static double | GetBatteryVoltage () |
Read the battery voltage. More... | |
static void | RefreshData () |
Copy data from the DS task for the user. More... | |
static void | ProvideRefreshedDataEventHandle (WPI_EventHandle handle) |
Registers the given handle for DS data refresh notifications. More... | |
static void | RemoveRefreshedDataEventHandle (WPI_EventHandle handle) |
Unregisters the given handle from DS data refresh notifications. More... | |
static void | SilenceJoystickConnectionWarning (bool silence) |
Allows the user to specify whether they want joystick connection warnings to be printed to the console. More... | |
static bool | IsJoystickConnectionWarningSilenced () |
Returns whether joystick connection warnings are silenced. More... | |
static void | StartDataLog (wpi::log::DataLog &log, bool logJoysticks=true) |
Starts logging DriverStation data to data log. More... | |
Static Public Attributes | |
static constexpr int | kJoystickPorts = 6 |
Number of Joystick ports. More... | |
Provide access to the network communication data to / from 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.
|
static |
Read the battery voltage.
|
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 types of Axes on a given joystick port.
stick | The joystick port number and the target axis |
axis | The analog axis value to read from the joystick. |
|
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 type of joystick at a 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 is a floating point number, and counts up.
Simulation matches DS behavior without an FMS connected.
|
static |
Returns the type of match being played provided by the FMS.
|
static |
Returns the number of times the current match has been replayed from the FMS.
|
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 |
Returns the number of axes on a given joystick port.
stick | The joystick port number |
|
static |
The state of one joystick button.
Button indexes begin at 1.
stick | The joystick to read. |
button | The button index, beginning at 1. |
|
static |
Returns the number of buttons on a given joystick port.
stick | The joystick port number |
|
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 1. |
|
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 1. |
|
static |
The state of the buttons on the joystick.
stick | The joystick to read. |
|
static |
Get the state of a POV on the joystick.
|
static |
Returns the number of POVs on a given joystick port.
stick | The joystick port number |
|
static |
Check if the DS is commanding autonomous mode.
|
static |
Check if the DS is commanding autonomous mode and if it has enabled the robot.
|
static |
Check if the robot is disabled.
|
static |
Check if the DS is attached.
|
static |
Check if the DS has enabled the robot.
|
static |
Check if the robot is e-stopped.
|
static |
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.
|
static |
Check if the DS is commanding teleop mode.
|
static |
Check if the DS is commanding teleop mode and if it has enabled the robot.
|
static |
Check if the DS is commanding test mode.
|
static |
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 |
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 |
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 |
|
static |
Wait for a DS connection.
timeout | timeout in seconds. 0 for infinite. |
|
staticconstexpr |
Number of Joystick ports.