|
WPILibC++
unspecified
|
Provide access to the network communication data to / from the Driver Station. More...
#include <DriverStation.h>
Public Types | |
| enum | Alliance { kRed, kBlue, kInvalid } |
Public Member Functions | |
| float | GetStickAxis (uint32_t stick, uint32_t axis) |
| Get the value of the axis on a joystick. More... | |
| int | GetStickPOV (uint32_t stick, uint32_t pov) |
| Get the state of a POV on the joystick. More... | |
| uint32_t | GetStickButtons (uint32_t stick) const |
| The state of the buttons on the joystick. More... | |
| bool | GetStickButton (uint32_t stick, uint8_t button) |
| The state of one joystick button. More... | |
| int | GetStickAxisCount (uint32_t stick) const |
| Returns the number of axes on a given joystick port. More... | |
| int | GetStickPOVCount (uint32_t stick) const |
| Returns the number of POVs on a given joystick port. More... | |
| int | GetStickButtonCount (uint32_t stick) const |
| Returns the number of buttons on a given joystick port. More... | |
| bool | GetJoystickIsXbox (uint32_t stick) const |
| Returns a boolean indicating if the controller is an xbox controller. More... | |
| int | GetJoystickType (uint32_t stick) const |
| Returns the type of joystick at a given port. More... | |
| std::string | GetJoystickName (uint32_t stick) const |
| Returns the name of the joystick at the given port. More... | |
| int | GetJoystickAxisType (uint32_t stick, uint8_t axis) const |
| Returns the types of Axes on a given joystick port. More... | |
| bool | IsEnabled () const override |
| Check if the DS has enabled the robot. More... | |
| bool | IsDisabled () const override |
| Check if the robot is disabled. More... | |
| bool | IsAutonomous () const override |
| Check if the DS is commanding autonomous mode. More... | |
| bool | IsOperatorControl () const override |
| Check if the DS is commanding teleop mode. More... | |
| bool | IsTest () const override |
| 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? Warning: If you call this function from more than one place at the same time, you will not get the get the intended behaviour. 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 | IsSysBrownedOut () const |
| Check if the system is browned out. More... | |
| Alliance | GetAlliance () const |
| Return the alliance that the driver station says it is on. More... | |
| uint32_t | GetLocation () const |
| Return the driver station location on the field This could return 1, 2, or 3. More... | |
| void | WaitForData () |
| Wait until a new packet comes from the driver station This blocks on a semaphore, so the waiting is efficient. More... | |
| double | 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. More... | |
| float | 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... | |
Public Member Functions inherited from SensorBase | |
| SensorBase () | |
| Creates an instance of the sensor base and gets an FPGA handle. | |
| SensorBase (const SensorBase &)=delete | |
| SensorBase & | operator= (const SensorBase &)=delete |
Public Member Functions inherited from ErrorBase | |
| ErrorBase (const ErrorBase &)=delete | |
| ErrorBase & | operator= (const ErrorBase &)=delete |
| virtual Error & | GetError () |
| Retrieve the current error. More... | |
| virtual const Error & | GetError () const |
| virtual void | SetErrnoError (llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t 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, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber) const |
| Set the current error information associated from the nivision Imaq API. More... | |
| virtual void | SetError (Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber) const |
| Set the current error information associated with this sensor. More... | |
| virtual void | SetWPIError (llvm::StringRef errorMessage, Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber) const |
| Set the current error information associated with this sensor. More... | |
| virtual void | CloneError (const ErrorBase &rhs) const |
| virtual void | ClearError () const |
| Clear the current error information associated with this sensor. | |
| virtual bool | StatusIsFatal () const |
| Check if the current error code represents a fatal error. More... | |
Static Public Member Functions | |
| static DriverStation & | GetInstance () |
| Return a pointer to the singleton DriverStation. More... | |
| static void | ReportError (std::string error) |
| Report an error to the DriverStation messages window. More... | |
| static void | ReportWarning (std::string error) |
| Report a warning to the DriverStation messages window. More... | |
| static void | ReportError (bool is_error, int32_t code, const std::string &error, const std::string &location, const std::string &stack) |
| Report an error to the DriverStation messages window. More... | |
Static Public Member Functions inherited from SensorBase | |
| static void | DeleteSingletons () |
| Delete all the singleton classes on the list. More... | |
| static uint32_t | GetDefaultSolenoidModule () |
| static bool | CheckSolenoidModule (uint8_t moduleNumber) |
| Check that the solenoid module number is valid. More... | |
| static bool | CheckDigitalChannel (uint32_t channel) |
| Check that the digital channel number is valid. More... | |
| static bool | CheckRelayChannel (uint32_t channel) |
| Check that the digital channel number is valid. More... | |
| static bool | CheckPWMChannel (uint32_t channel) |
| Check that the digital channel number is valid. More... | |
| static bool | CheckAnalogInput (uint32_t channel) |
| Check that the analog input number is value. More... | |
| static bool | CheckAnalogOutput (uint32_t channel) |
| Check that the analog output number is valid. More... | |
| static bool | CheckSolenoidChannel (uint32_t channel) |
| Verify that the solenoid channel number is within limits. More... | |
| static bool | CheckPDPChannel (uint32_t channel) |
| Verify that the power distribution channel number is within limits. More... | |
Static Public Member Functions inherited from ErrorBase | |
| static void | SetGlobalError (Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber) |
| static void | SetGlobalWPIError (llvm::StringRef errorMessage, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber) |
| static Error & | GetGlobalError () |
| Retrieve the current global error. | |
Static Public Attributes | |
| static const uint32_t | kJoystickPorts = 6 |
Static Public Attributes inherited from SensorBase | |
| static const uint32_t | kDigitalChannels = 26 |
| static const uint32_t | kAnalogInputs = 8 |
| static const uint32_t | kAnalogOutputs = 2 |
| static const uint32_t | kSolenoidChannels = 8 |
| static const uint32_t | kSolenoidModules = 2 |
| static const uint32_t | kPwmChannels = 20 |
| static const uint32_t | kRelayChannels = 8 |
| static const uint32_t | kPDPChannels = 16 |
| static const uint32_t | kChassisSlots = 8 |
Protected Member Functions | |
| DriverStation () | |
| DriverStation constructor. More... | |
| void | GetData () |
| Copy data from the DS task for the user. More... | |
Protected Member Functions inherited from SensorBase | |
| void | AddToSingletonList () |
| Add sensor to the singleton list. More... | |
Additional Inherited Members | |
Protected Attributes inherited from ErrorBase | |
| Error | m_error |
Static Protected Attributes inherited from SensorBase | |
| static void * | m_digital_ports [kDigitalChannels] |
| static void * | m_relay_ports [kRelayChannels] |
| static void * | m_pwm_ports [kPwmChannels] |
Static Protected Attributes inherited from ErrorBase | |
| static priority_mutex | _globalErrorMutex |
| static Error | _globalError |
Provide access to the network communication data to / from the Driver Station.
|
protected |
DriverStation constructor.
This is only called once the first time GetInstance() is called
| DriverStation::Alliance DriverStation::GetAlliance | ( | ) | const |
Return the alliance that the driver station says it is on.
This could return kRed or kBlue
| float 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 pointer to the singleton DriverStation.
| int DriverStation::GetJoystickAxisType | ( | uint32_t | stick, |
| uint8_t | axis | ||
| ) | const |
Returns the types of Axes on a given joystick port.
| stick | The joystick port number and the target axis |
| bool DriverStation::GetJoystickIsXbox | ( | uint32_t | stick | ) | const |
Returns a boolean indicating if the controller is an xbox controller.
| stick | The joystick port number |
| std::string DriverStation::GetJoystickName | ( | uint32_t | stick | ) | const |
Returns the name of the joystick at the given port.
| stick | The joystick port number |
| int DriverStation::GetJoystickType | ( | uint32_t | stick | ) | const |
Returns the type of joystick at a given port.
| stick | The joystick port number |
| uint32_t DriverStation::GetLocation | ( | ) | const |
Return the driver station location on the field This could return 1, 2, or 3.
| double 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.
| float DriverStation::GetStickAxis | ( | uint32_t | stick, |
| uint32_t | 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 DriverStation::GetStickAxisCount | ( | uint32_t | stick | ) | const |
Returns the number of axes on a given joystick port.
| stick | The joystick port number |
| bool DriverStation::GetStickButton | ( | uint32_t | stick, |
| uint8_t | 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 DriverStation::GetStickButtonCount | ( | uint32_t | stick | ) | const |
Returns the number of buttons on a given joystick port.
| stick | The joystick port number |
| uint32_t DriverStation::GetStickButtons | ( | uint32_t | stick | ) | const |
The state of the buttons on the joystick.
| stick | The joystick to read. |
| int DriverStation::GetStickPOV | ( | uint32_t | stick, |
| uint32_t | pov | ||
| ) |
Get the state of a POV on the joystick.
| int DriverStation::GetStickPOVCount | ( | uint32_t | 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 |
|
overridevirtual |
Check if the DS is commanding autonomous mode.
Implements RobotStateInterface.
|
overridevirtual |
Check if the robot is disabled.
Implements RobotStateInterface.
| bool DriverStation::IsDSAttached | ( | ) | const |
Check if the DS is attached.
|
overridevirtual |
Check if the DS has enabled the robot.
Implements RobotStateInterface.
| bool DriverStation::IsFMSAttached | ( | ) | const |
Is the driver station attached to a Field Management System?
| bool 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 get the intended behaviour.
|
overridevirtual |
Check if the DS is commanding teleop mode.
Implements RobotStateInterface.
| bool 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 DriverStation::IsSysBrownedOut | ( | ) | const |
Check if the system is browned out.
|
overridevirtual |
Check if the DS is commanding test mode.
Implements RobotStateInterface.
|
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 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