WPILibC++ 2024.3.2
Driver Station Functions

Classes

struct  HAL_ControlWord
 
struct  HAL_JoystickAxes
 
struct  HAL_JoystickPOVs
 
struct  HAL_JoystickButtons
 
struct  HAL_JoystickDescriptor
 
struct  HAL_MatchInfo
 

Macros

#define HAL_IO_CONFIG_DATA_SIZE   32
 
#define HAL_SYS_STATUS_DATA_SIZE   44
 
#define HAL_USER_STATUS_DATA_SIZE    (984 - HAL_IO_CONFIG_DATA_SIZE - HAL_SYS_STATUS_DATA_SIZE)
 
#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input   17
 
#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output   18
 
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Header   19
 
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra1   20
 
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices1   21
 
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra2   22
 
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices2   23
 
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Joystick   24
 
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Custom   25
 
#define HAL_kMaxJoystickAxes   12
 
#define HAL_kMaxJoystickPOVs   12
 
#define HAL_kMaxJoysticks   6
 

Typedefs

typedef struct HAL_ControlWord HAL_ControlWord
 
typedef struct HAL_JoystickAxes HAL_JoystickAxes
 
typedef struct HAL_JoystickPOVs HAL_JoystickPOVs
 
typedef struct HAL_JoystickButtons HAL_JoystickButtons
 
typedef struct HAL_JoystickDescriptor HAL_JoystickDescriptor
 
typedef struct HAL_MatchInfo HAL_MatchInfo
 

Enumerations

enum  HAL_AllianceStationID : int32_t {
  HAL_AllianceStationID_kUnknown = 0 , HAL_AllianceStationID_kRed1 , HAL_AllianceStationID_kRed2 , HAL_AllianceStationID_kRed3 ,
  HAL_AllianceStationID_kBlue1 , HAL_AllianceStationID_kBlue2 , HAL_AllianceStationID_kBlue3
}
 
enum  HAL_MatchType : int32_t { HAL_kMatchType_none = 0 , HAL_kMatchType_practice , HAL_kMatchType_qualification , HAL_kMatchType_elimination }
 

Functions

int32_t HAL_SendError (HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode, const char *details, const char *location, const char *callStack, HAL_Bool printMsg)
 Sends an error to the driver station. More...
 
void HAL_SetPrintErrorImpl (void(*func)(const char *line, size_t size))
 Set the print function used by HAL_SendError. More...
 
int32_t HAL_SendConsoleLine (const char *line)
 Sends a line to the driver station console. More...
 
int32_t HAL_GetControlWord (HAL_ControlWord *controlWord)
 Gets the current control word of the driver station. More...
 
HAL_AllianceStationID HAL_GetAllianceStation (int32_t *status)
 Gets the current alliance station ID. More...
 
int32_t HAL_GetJoystickAxes (int32_t joystickNum, HAL_JoystickAxes *axes)
 Gets the axes of a specific joystick. More...
 
int32_t HAL_GetJoystickPOVs (int32_t joystickNum, HAL_JoystickPOVs *povs)
 Gets the POVs of a specific joystick. More...
 
int32_t HAL_GetJoystickButtons (int32_t joystickNum, HAL_JoystickButtons *buttons)
 Gets the buttons of a specific joystick. More...
 
void HAL_GetAllJoystickData (HAL_JoystickAxes *axes, HAL_JoystickPOVs *povs, HAL_JoystickButtons *buttons)
 
int32_t HAL_GetJoystickDescriptor (int32_t joystickNum, HAL_JoystickDescriptor *desc)
 Retrieves the Joystick Descriptor for particular slot. More...
 
HAL_Bool HAL_GetJoystickIsXbox (int32_t joystickNum)
 Gets whether a specific joystick is considered to be an XBox controller. More...
 
int32_t HAL_GetJoystickType (int32_t joystickNum)
 Gets the type of joystick connected. More...
 
char * HAL_GetJoystickName (int32_t joystickNum)
 Gets the name of a joystick. More...
 
void HAL_FreeJoystickName (char *name)
 Frees a joystick name received with HAL_GetJoystickName. More...
 
int32_t HAL_GetJoystickAxisType (int32_t joystickNum, int32_t axis)
 Gets the type of a specific joystick axis. More...
 
int32_t HAL_SetJoystickOutputs (int32_t joystickNum, int64_t outputs, int32_t leftRumble, int32_t rightRumble)
 Set joystick outputs. More...
 
double HAL_GetMatchTime (int32_t *status)
 Return the approximate match time. More...
 
HAL_Bool HAL_GetOutputsEnabled (void)
 Gets if outputs are enabled by the control system. More...
 
int32_t HAL_GetMatchInfo (HAL_MatchInfo *info)
 Gets info about a specific match. More...
 
HAL_Bool HAL_RefreshDSData (void)
 Refresh the DS control word. More...
 
void HAL_ProvideNewDataEventHandle (WPI_EventHandle handle)
 
void HAL_RemoveNewDataEventHandle (WPI_EventHandle handle)
 
void HAL_ObserveUserProgramStarting (void)
 Sets the program starting flag in the DS. More...
 
void HAL_ObserveUserProgramDisabled (void)
 Sets the disabled flag in the DS. More...
 
void HAL_ObserveUserProgramAutonomous (void)
 Sets the autonomous enabled flag in the DS. More...
 
void HAL_ObserveUserProgramTeleop (void)
 Sets the teleoperated enabled flag in the DS. More...
 
void HAL_ObserveUserProgramTest (void)
 Sets the test mode flag in the DS. More...
 

Detailed Description

Macro Definition Documentation

◆ HAL_IO_CONFIG_DATA_SIZE

#define HAL_IO_CONFIG_DATA_SIZE   32

◆ HAL_kMaxJoystickAxes

#define HAL_kMaxJoystickAxes   12

◆ HAL_kMaxJoystickPOVs

#define HAL_kMaxJoystickPOVs   12

◆ HAL_kMaxJoysticks

#define HAL_kMaxJoysticks   6

◆ HAL_SYS_STATUS_DATA_SIZE

#define HAL_SYS_STATUS_DATA_SIZE   44

◆ HAL_USER_STATUS_DATA_SIZE

#define HAL_USER_STATUS_DATA_SIZE    (984 - HAL_IO_CONFIG_DATA_SIZE - HAL_SYS_STATUS_DATA_SIZE)

◆ HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input

#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input   17

◆ HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output

#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output   18

◆ HALFRC_NetworkCommunication_DynamicType_Kinect_Custom

#define HALFRC_NetworkCommunication_DynamicType_Kinect_Custom   25

◆ HALFRC_NetworkCommunication_DynamicType_Kinect_Extra1

#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra1   20

◆ HALFRC_NetworkCommunication_DynamicType_Kinect_Extra2

#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra2   22

◆ HALFRC_NetworkCommunication_DynamicType_Kinect_Header

#define HALFRC_NetworkCommunication_DynamicType_Kinect_Header   19

◆ HALFRC_NetworkCommunication_DynamicType_Kinect_Joystick

#define HALFRC_NetworkCommunication_DynamicType_Kinect_Joystick   24

◆ HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices1

#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices1   21

◆ HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices2

#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices2   23

Typedef Documentation

◆ HAL_ControlWord

◆ HAL_JoystickAxes

◆ HAL_JoystickButtons

◆ HAL_JoystickDescriptor

◆ HAL_JoystickPOVs

◆ HAL_MatchInfo

typedef struct HAL_MatchInfo HAL_MatchInfo

Enumeration Type Documentation

◆ HAL_AllianceStationID

enum HAL_AllianceStationID : int32_t
Enumerator
HAL_AllianceStationID_kUnknown 
HAL_AllianceStationID_kRed1 
HAL_AllianceStationID_kRed2 
HAL_AllianceStationID_kRed3 
HAL_AllianceStationID_kBlue1 
HAL_AllianceStationID_kBlue2 
HAL_AllianceStationID_kBlue3 

◆ HAL_MatchType

enum HAL_MatchType : int32_t
Enumerator
HAL_kMatchType_none 
HAL_kMatchType_practice 
HAL_kMatchType_qualification 
HAL_kMatchType_elimination 

Function Documentation

◆ HAL_FreeJoystickName()

void HAL_FreeJoystickName ( char *  name)

Frees a joystick name received with HAL_GetJoystickName.

Parameters
namethe name storage

◆ HAL_GetAllianceStation()

HAL_AllianceStationID HAL_GetAllianceStation ( int32_t *  status)

Gets the current alliance station ID.

Parameters
[out]statusthe error code, or 0 for success
Returns
the alliance station ID

◆ HAL_GetAllJoystickData()

void HAL_GetAllJoystickData ( HAL_JoystickAxes axes,
HAL_JoystickPOVs povs,
HAL_JoystickButtons buttons 
)

◆ HAL_GetControlWord()

int32_t HAL_GetControlWord ( HAL_ControlWord controlWord)

Gets the current control word of the driver station.

The control word contains the robot state.

Parameters
controlWordthe control word (out)
Returns
the error code, or 0 for success

◆ HAL_GetJoystickAxes()

int32_t HAL_GetJoystickAxes ( int32_t  joystickNum,
HAL_JoystickAxes axes 
)

Gets the axes of a specific joystick.

Parameters
joystickNumthe joystick number
axesthe axes values (output)
Returns
the error code, or 0 for success

◆ HAL_GetJoystickAxisType()

int32_t HAL_GetJoystickAxisType ( int32_t  joystickNum,
int32_t  axis 
)

Gets the type of a specific joystick axis.

This is device specific, and different depending on what system input type the joystick uses.

Parameters
joystickNumthe joystick number
axisthe axis number
Returns
the enumerated axis type

◆ HAL_GetJoystickButtons()

int32_t HAL_GetJoystickButtons ( int32_t  joystickNum,
HAL_JoystickButtons buttons 
)

Gets the buttons of a specific joystick.

Parameters
joystickNumthe joystick number
buttonsthe button values (output)
Returns
the error code, or 0 for success

◆ HAL_GetJoystickDescriptor()

int32_t HAL_GetJoystickDescriptor ( int32_t  joystickNum,
HAL_JoystickDescriptor desc 
)

Retrieves the Joystick Descriptor for particular slot.

Parameters
joystickNumthe joystick number
[out]descdescriptor (data transfer object) to fill in. desc is filled in regardless of success. In other words, if descriptor is not available, desc is filled in with default values matching the init-values in Java and C++ Driver Station for when caller requests a too-large joystick index.
Returns
error code reported from Network Comm back-end. Zero is good, nonzero is bad.

◆ HAL_GetJoystickIsXbox()

HAL_Bool HAL_GetJoystickIsXbox ( int32_t  joystickNum)

Gets whether a specific joystick is considered to be an XBox controller.

Parameters
joystickNumthe joystick number
Returns
true if xbox, false otherwise

◆ HAL_GetJoystickName()

char * HAL_GetJoystickName ( int32_t  joystickNum)

Gets the name of a joystick.

The returned array must be freed with HAL_FreeJoystickName.

Will be null terminated.

Parameters
joystickNumthe joystick number
Returns
the joystick name

◆ HAL_GetJoystickPOVs()

int32_t HAL_GetJoystickPOVs ( int32_t  joystickNum,
HAL_JoystickPOVs povs 
)

Gets the POVs of a specific joystick.

Parameters
joystickNumthe joystick number
povsthe POV values (output)
Returns
the error code, or 0 for success

◆ HAL_GetJoystickType()

int32_t HAL_GetJoystickType ( int32_t  joystickNum)

Gets the type of joystick connected.

This is device specific, and different depending on what system input type the joystick uses.

Parameters
joystickNumthe joystick number
Returns
the enumerated joystick type

◆ HAL_GetMatchInfo()

int32_t HAL_GetMatchInfo ( HAL_MatchInfo info)

Gets info about a specific match.

Parameters
[in]infothe match info (output)
Returns
the error code, or 0 for success

◆ HAL_GetMatchTime()

double HAL_GetMatchTime ( int32_t *  status)

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.

Parameters
[out]statusthe error code, or 0 for success
Returns
Time remaining in current match period (auto or teleop) in seconds

◆ HAL_GetOutputsEnabled()

HAL_Bool HAL_GetOutputsEnabled ( void  )

Gets if outputs are enabled by the control system.

Returns
true if outputs are enabled

◆ HAL_ObserveUserProgramAutonomous()

void HAL_ObserveUserProgramAutonomous ( void  )

Sets the autonomous enabled flag in the DS.

This is used for the DS to ensure the robot is properly responding to its state request. Ensure this gets called about every 50ms, or the robot will be disabled by the DS.

◆ HAL_ObserveUserProgramDisabled()

void HAL_ObserveUserProgramDisabled ( void  )

Sets the disabled flag in the DS.

This is used for the DS to ensure the robot is properly responding to its state request. Ensure this gets called about every 50ms, or the robot will be disabled by the DS.

◆ HAL_ObserveUserProgramStarting()

void HAL_ObserveUserProgramStarting ( void  )

Sets the program starting flag in the DS.

This is what changes the DS to showing robot code ready.

◆ HAL_ObserveUserProgramTeleop()

void HAL_ObserveUserProgramTeleop ( void  )

Sets the teleoperated enabled flag in the DS.

This is used for the DS to ensure the robot is properly responding to its state request. Ensure this gets called about every 50ms, or the robot will be disabled by the DS.

◆ HAL_ObserveUserProgramTest()

void HAL_ObserveUserProgramTest ( void  )

Sets the test mode flag in the DS.

This is used for the DS to ensure the robot is properly responding to its state request. Ensure this gets called about every 50ms, or the robot will be disabled by the DS.

◆ HAL_ProvideNewDataEventHandle()

void HAL_ProvideNewDataEventHandle ( WPI_EventHandle  handle)

◆ HAL_RefreshDSData()

HAL_Bool HAL_RefreshDSData ( void  )

Refresh the DS control word.

Returns
true if updated

◆ HAL_RemoveNewDataEventHandle()

void HAL_RemoveNewDataEventHandle ( WPI_EventHandle  handle)

◆ HAL_SendConsoleLine()

int32_t HAL_SendConsoleLine ( const char *  line)

Sends a line to the driver station console.

Parameters
linethe line to send (null terminated)
Returns
the error code, or 0 for success

◆ HAL_SendError()

int32_t HAL_SendError ( HAL_Bool  isError,
int32_t  errorCode,
HAL_Bool  isLVCode,
const char *  details,
const char *  location,
const char *  callStack,
HAL_Bool  printMsg 
)

Sends an error to the driver station.

Parameters
isErrortrue for error, false for warning
errorCodethe error code
isLVCodetrue for a LV error code, false for a standard error code
detailsthe details of the error
locationthe file location of the error
callStackthe callstack of the error
printMsgtrue to print the error message to stdout as well as to the DS
Returns
the error code, or 0 for success

◆ HAL_SetJoystickOutputs()

int32_t HAL_SetJoystickOutputs ( int32_t  joystickNum,
int64_t  outputs,
int32_t  leftRumble,
int32_t  rightRumble 
)

Set joystick outputs.

Parameters
joystickNumthe joystick number
outputsbitmask of outputs, 1 for on 0 for off
leftRumblethe left rumble value (0-FFFF)
rightRumblethe right rumble value (0-FFFF)
Returns
the error code, or 0 for success

◆ HAL_SetPrintErrorImpl()

void HAL_SetPrintErrorImpl ( void(*)(const char *line, size_t size)  func)

Set the print function used by HAL_SendError.

Parameters
funcFunction called by HAL_SendError when stderr is printed