#include <DriverStation.h>
Public Types | |
enum | Alliance { kRed, kBlue, kInvalid } |
Public Member Functions | |
float | GetStickAxis (uint32_t stick, uint32_t axis) |
short | GetStickButtons (uint32_t stick) |
float | GetAnalogIn (uint32_t channel) |
bool | GetDigitalIn (uint32_t channel) |
void | SetDigitalOut (uint32_t channel, bool value) |
bool | GetDigitalOut (uint32_t channel) |
bool | IsEnabled () |
bool | IsDisabled () |
bool | IsAutonomous () |
bool | IsOperatorControl () |
bool | IsTest () |
bool | IsNewControlData () |
bool | IsFMSAttached () |
uint32_t | GetPacketNumber () |
Alliance | GetAlliance () |
uint32_t | GetLocation () |
void | WaitForData () |
double | GetMatchTime () |
float | GetBatteryVoltage () |
uint16_t | GetTeamNumber () |
Dashboard & | GetHighPriorityDashboardPacker () |
Dashboard & | GetLowPriorityDashboardPacker () |
DashboardBase * | GetHighPriorityDashboardPackerInUse () |
DashboardBase * | GetLowPriorityDashboardPackerInUse () |
void | SetHighPriorityDashboardPackerToUse (DashboardBase *db) |
void | SetLowPriorityDashboardPackerToUse (DashboardBase *db) |
DriverStationEnhancedIO & | GetEnhancedIO () |
void | IncrementUpdateNumber () |
SEM_ID | GetUserStatusDataSem () |
void | InDisabled (bool entering) |
void | InAutonomous (bool entering) |
void | InOperatorControl (bool entering) |
void | InTest (bool entering) |
Public Member Functions inherited from SensorBase | |
SensorBase () | |
virtual | ~SensorBase () |
Public Member Functions inherited from ErrorBase | |
virtual Error & | GetError () |
Retrieve the current error. Get the current error information associated with this sensor. | |
virtual const Error & | GetError () const |
virtual void | SetErrnoError (const char *contextMessage, const char *filename, const char *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, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const |
Set the current error information associated from the nivision Imaq API. More... | |
virtual void | SetError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | SetWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | CloneError (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 () |
Static Public Member Functions inherited from SensorBase | |
static void | DeleteSingletons () |
static uint32_t | GetDefaultAnalogModule () |
static uint32_t | GetDefaultDigitalModule () |
static uint32_t | GetDefaultSolenoidModule () |
static bool | CheckAnalogModule (uint8_t moduleNumber) |
static bool | CheckDigitalModule (uint8_t moduleNumber) |
static bool | CheckPWMModule (uint8_t moduleNumber) |
static bool | CheckRelayModule (uint8_t moduleNumber) |
static bool | CheckSolenoidModule (uint8_t moduleNumber) |
static bool | CheckDigitalChannel (uint32_t channel) |
static bool | CheckRelayChannel (uint32_t channel) |
static bool | CheckPWMChannel (uint32_t channel) |
static bool | CheckAnalogChannel (uint32_t channel) |
static bool | CheckSolenoidChannel (uint32_t channel) |
Static Public Member Functions inherited from ErrorBase | |
static void | SetGlobalError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) |
static void | SetGlobalWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) |
static Error & | GetGlobalError () |
Static Public Attributes | |
static const uint32_t | kBatteryModuleNumber = 1 |
static const uint32_t | kBatteryChannel = 8 |
static const uint32_t | kJoystickPorts = 4 |
static const uint32_t | kJoystickAxes = 6 |
Static Public Attributes inherited from SensorBase | |
static const uint32_t | kSystemClockTicksPerMicrosecond = 40 |
static const uint32_t | kDigitalChannels = 14 |
static const uint32_t | kAnalogChannels = 8 |
static const uint32_t | kAnalogModules = 2 |
static const uint32_t | kDigitalModules = 2 |
static const uint32_t | kSolenoidChannels = 8 |
static const uint32_t | kSolenoidModules = 2 |
static const uint32_t | kPwmChannels = 10 |
static const uint32_t | kRelayChannels = 8 |
static const uint32_t | kChassisSlots = 8 |
Protected Member Functions | |
DriverStation () | |
void | GetData () |
void | SetData () |
Protected Member Functions inherited from SensorBase | |
void | AddToSingletonList () |
Protected Member Functions inherited from ErrorBase | |
ErrorBase () | |
Initialize the instance status to 0 for now. | |
Additional Inherited Members | |
Protected Attributes inherited from ErrorBase | |
Error | m_error |
Static Protected Attributes inherited from ErrorBase | |
static SEM_ID | _globalErrorMutex = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE) |
static Error | _globalError |
Provide access to the network communication data to / from the Driver Station.
|
protected |
DriverStation contructor.
This is only called once the first time GetInstance() is called
DriverStation::Alliance DriverStation::GetAlliance | ( | ) |
Return the alliance that the driver station says it is on. This could return kRed or kBlue
float DriverStation::GetAnalogIn | ( | uint32_t | channel | ) |
Get an analog voltage from the Driver Station. The analog values are returned as voltage values for the Driver Station analog inputs. These inputs are typically used for advanced operator interfaces consisting of potentiometers or resistor networks representing values on a rotary switch.
channel | The analog input channel on the driver station to read from. Valid range is 1 - 4. |
float DriverStation::GetBatteryVoltage | ( | ) |
Read the battery voltage from the specified AnalogChannel.
This accessor assumes that the battery voltage is being measured through the voltage divider on an analog breakout.
|
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.
bool DriverStation::GetDigitalIn | ( | uint32_t | channel | ) |
Get values from the digital inputs on the Driver Station. Return digital values from the Drivers Station. These values are typically used for buttons and switches on advanced operator interfaces.
channel | The digital input to get. Valid range is 1 - 8. |
bool DriverStation::GetDigitalOut | ( | uint32_t | channel | ) |
Get a value that was set for the digital outputs on the Driver Station.
channel | The digital ouput to monitor. Valid range is 1 through 8. |
|
static |
Return a pointer to the singleton DriverStation.
uint32_t DriverStation::GetLocation | ( | ) |
Return the driver station location on the field This could return 1, 2, or 3
double DriverStation::GetMatchTime | ( | ) |
Return the approximate match time The FMS does not currently send the official match time to the robots This returns the time since the enable signal sent from the Driver Station At the beginning of autonomous, the time is reset to 0.0 seconds At the beginning of teleop, the time is reset to +15.0 seconds If the robot is disabled, this returns 0.0 seconds Warning: This is not an official time (so it cannot be used to argue with referees)
uint32_t DriverStation::GetPacketNumber | ( | ) |
Return the DS packet number. The packet number is the index of this set of data returned by the driver station. Each time new data is received, the packet number (included with the sent data) is returned.
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. |
short DriverStation::GetStickButtons | ( | uint32_t | stick | ) |
The state of the buttons on the joystick. 12 buttons (4 msb are unused) from the joystick.
stick | The joystick to read. |
uint16_t DriverStation::GetTeamNumber | ( | ) |
Return the team number that the Driver Station is configured for
|
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 DriverStation::IsFMSAttached | ( | ) |
Is the driver station attached to a Field Management System? Note: This does not work with the Blue DS.
bool DriverStation::IsNewControlData | ( | ) |
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 behavior
|
protected |
Copy status data from the DS task for the user.
void DriverStation::SetDigitalOut | ( | uint32_t | channel, |
bool | value | ||
) |
Set a value for the digital outputs on the Driver Station.
Control digital outputs on the Drivers Station. These values are typically used for giving feedback on a custom operator station such as LEDs.
channel | The digital output to set. Valid range is 1 - 8. |
value | The state to set the digital output. |
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