WPILibC++
2018.4.1-20180729223220-1149-g7bd3f9f
|
Provide access to the network communication data to / from the Driver Station. More...
#include <DriverStation.h>
Public Types | |
enum | Alliance { kRed, kBlue, kInvalid } |
enum | MatchType { kNone, kPractice, kQualification, kElimination } |
Public Member Functions | |
bool | GetStickButton (int stick, int button) |
The state of one joystick button. More... | |
bool | GetStickButtonPressed (int stick, int button) |
Whether one joystick button was pressed since the last check. More... | |
bool | GetStickButtonReleased (int stick, int button) |
Whether one joystick button was released since the last check. More... | |
double | GetStickAxis (int stick, int axis) |
Get the value of the axis on a joystick. More... | |
int | GetStickPOV (int stick, int pov) |
Get the state of a POV on the joystick. More... | |
int | GetStickButtons (int stick) const |
The state of the buttons on the joystick. More... | |
int | GetStickAxisCount (int stick) const |
Returns the number of axes on a given joystick port. More... | |
int | GetStickPOVCount (int stick) const |
Returns the number of POVs on a given joystick port. More... | |
int | GetStickButtonCount (int stick) const |
Returns the number of buttons on a given joystick port. More... | |
bool | GetJoystickIsXbox (int stick) const |
Returns a boolean indicating if the controller is an xbox controller. More... | |
int | GetJoystickType (int stick) const |
Returns the type of joystick at a given port. More... | |
std::string | GetJoystickName (int stick) const |
Returns the name of the joystick at the given port. More... | |
int | GetJoystickAxisType (int stick, int axis) const |
Returns the types of Axes on a given joystick port. More... | |
bool | IsEnabled () const |
Check if the DS has enabled the robot. More... | |
bool | IsDisabled () const |
Check if the robot is disabled. More... | |
bool | IsAutonomous () const |
Check if the DS is commanding autonomous mode. More... | |
bool | IsOperatorControl () const |
Check if the DS is commanding teleop mode. More... | |
bool | IsTest () const |
Check if the DS is commanding test mode. More... | |
bool | IsDSAttached () const |
Check if the DS is attached. More... | |
bool | IsNewControlData () const |
Has a new control packet from the driver station arrived since the last time this function was called? More... | |
bool | IsFMSAttached () const |
Is the driver station attached to a Field Management System? More... | |
bool | IsSysActive () const |
Check if the FPGA outputs are enabled. More... | |
bool | IsBrownedOut () const |
Check if the system is browned out. More... | |
std::string | GetGameSpecificMessage () const |
std::string | GetEventName () const |
MatchType | GetMatchType () const |
int | GetMatchNumber () const |
int | GetReplayNumber () const |
Alliance | GetAlliance () const |
Return the alliance that the driver station says it is on. More... | |
int | GetLocation () const |
Return the driver station location on the field. More... | |
void | WaitForData () |
Wait until a new packet comes from the driver station. More... | |
bool | WaitForData (double timeout) |
Wait until a new packet comes from the driver station, or wait for a timeout. More... | |
double | GetMatchTime () const |
Return the approximate match time. More... | |
double | GetBatteryVoltage () const |
Read the battery voltage. More... | |
void | InDisabled (bool entering) |
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only. More... | |
void | InAutonomous (bool entering) |
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only. More... | |
void | InOperatorControl (bool entering) |
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only. More... | |
void | InTest (bool entering) |
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only. More... | |
![]() | |
ErrorBase (const ErrorBase &)=delete | |
ErrorBase & | operator= (const ErrorBase &)=delete |
virtual Error & | GetError () |
Retrieve the current error. More... | |
virtual const Error & | GetError () const |
Retrieve the current error. More... | |
virtual void | ClearError () const |
Clear the current error information associated with this sensor. | |
virtual void | SetErrnoError (const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
Set error information associated with a C library call that set an error to the "errno" global variable. More... | |
virtual void | SetImaqError (int success, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
Set the current error information associated from the nivision Imaq API. More... | |
virtual void | SetError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | SetErrorRange (Error::Code code, int32_t minRange, int32_t maxRange, int32_t requestedValue, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | SetWPIError (const wpi::Twine &errorMessage, Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | CloneError (const ErrorBase &rhs) const |
virtual bool | StatusIsFatal () const |
Check if the current error code represents a fatal error. More... | |
Static Public Member Functions | |
static DriverStation & | GetInstance () |
Return a reference to the singleton DriverStation. More... | |
static void | ReportError (const wpi::Twine &error) |
Report an error to the DriverStation messages window. More... | |
static void | ReportWarning (const wpi::Twine &error) |
Report a warning to the DriverStation messages window. More... | |
static void | ReportError (bool isError, int code, const wpi::Twine &error, const wpi::Twine &location, const wpi::Twine &stack) |
Report an error to the DriverStation messages window. More... | |
![]() | |
static void | SetGlobalError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) |
static void | SetGlobalWPIError (const wpi::Twine &errorMessage, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) |
static const Error & | GetGlobalError () |
Retrieve the current global error. | |
Static Public Attributes | |
static constexpr int | kJoystickPorts = 6 |
Protected Member Functions | |
void | GetData () |
Copy data from the DS task for the user. More... | |
Additional Inherited Members | |
![]() | |
Error | m_error |
Provide access to the network communication data to / from the Driver Station.
Alliance frc::DriverStation::GetAlliance | ( | ) | const |
Return the alliance that the driver station says it is on.
This could return kRed or kBlue.
double frc::DriverStation::GetBatteryVoltage | ( | ) | const |
Read the battery voltage.
|
protected |
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 |
Return a reference to the singleton DriverStation.
int frc::DriverStation::GetJoystickAxisType | ( | int | stick, |
int | axis | ||
) | const |
Returns the types of Axes on a given joystick port.
stick | The joystick port number and the target axis |
bool frc::DriverStation::GetJoystickIsXbox | ( | int | stick | ) | const |
Returns a boolean indicating if the controller is an xbox controller.
stick | The joystick port number |
std::string frc::DriverStation::GetJoystickName | ( | int | stick | ) | const |
Returns the name of the joystick at the given port.
stick | The joystick port number |
int frc::DriverStation::GetJoystickType | ( | int | stick | ) | const |
Returns the type of joystick at a given port.
stick | The joystick port number |
int frc::DriverStation::GetLocation | ( | ) | const |
Return the driver station location on the field.
This could return 1, 2, or 3.
double frc::DriverStation::GetMatchTime | ( | ) | const |
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).
The Practice Match function of the DS approximates the behaviour seen on the field.
double frc::DriverStation::GetStickAxis | ( | int | stick, |
int | axis | ||
) |
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. |
int frc::DriverStation::GetStickAxisCount | ( | int | stick | ) | const |
Returns the number of axes on a given joystick port.
stick | The joystick port number |
bool frc::DriverStation::GetStickButton | ( | int | stick, |
int | button | ||
) |
The state of one joystick button.
Button indexes begin at 1.
stick | The joystick to read. |
button | The button index, beginning at 1. |
int frc::DriverStation::GetStickButtonCount | ( | int | stick | ) | const |
Returns the number of buttons on a given joystick port.
stick | The joystick port number |
bool frc::DriverStation::GetStickButtonPressed | ( | int | stick, |
int | button | ||
) |
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. |
bool frc::DriverStation::GetStickButtonReleased | ( | int | stick, |
int | button | ||
) |
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. |
int frc::DriverStation::GetStickButtons | ( | int | stick | ) | const |
The state of the buttons on the joystick.
stick | The joystick to read. |
int frc::DriverStation::GetStickPOV | ( | int | stick, |
int | pov | ||
) |
Get the state of a POV on the joystick.
int frc::DriverStation::GetStickPOVCount | ( | int | stick | ) | const |
Returns the number of POVs on a given joystick port.
stick | The joystick port number |
|
inline |
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
entering | If true, starting autonomous code; if false, leaving autonomous code. |
|
inline |
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
entering | If true, starting disabled code; if false, leaving disabled code. |
|
inline |
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
entering | If true, starting teleop code; if false, leaving teleop code. |
|
inline |
Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
entering | If true, starting test code; if false, leaving test code. |
bool frc::DriverStation::IsAutonomous | ( | ) | const |
Check if the DS is commanding autonomous mode.
bool frc::DriverStation::IsBrownedOut | ( | ) | const |
Check if the system is browned out.
bool frc::DriverStation::IsDisabled | ( | ) | const |
Check if the robot is disabled.
bool frc::DriverStation::IsDSAttached | ( | ) | const |
Check if the DS is attached.
bool frc::DriverStation::IsEnabled | ( | ) | const |
Check if the DS has enabled the robot.
bool frc::DriverStation::IsFMSAttached | ( | ) | const |
Is the driver station attached to a Field Management System?
bool frc::DriverStation::IsNewControlData | ( | ) | const |
Has a new control packet from the driver station arrived since the last time this function was called?
Warning: If you call this function from more than one place at the same time, you will not get the intended behavior.
bool frc::DriverStation::IsOperatorControl | ( | ) | const |
Check if the DS is commanding teleop mode.
bool frc::DriverStation::IsSysActive | ( | ) | const |
Check if the FPGA outputs are enabled.
The outputs may be disabled if the robot is disabled or e-stopped, the watchdog has expired, or if the roboRIO browns out.
bool frc::DriverStation::IsTest | ( | ) | const |
Check if the DS is commanding test mode.
|
static |
Report an error to the DriverStation messages window.
The error is also printed to the program console.
|
static |
Report an error to the DriverStation messages window.
The error is also printed to the program console.
|
static |
Report a warning to the DriverStation messages window.
The warning is also printed to the program console.
void frc::DriverStation::WaitForData | ( | ) |
Wait until a new packet comes from the driver station.
This blocks on a semaphore, so the waiting is efficient.
This is a good way to delay processing until there is new driver station data to act on.
bool frc::DriverStation::WaitForData | ( | double | timeout | ) |
Wait until a new packet comes from the driver station, or wait for a timeout.
If the timeout is less then or equal to 0, wait indefinitely.
Timeout is in milliseconds
This blocks on a semaphore, so the waiting is efficient.
This is a good way to delay processing until there is new driver station data to act on.
timeout | Timeout time in seconds |