WPILibC++  2018.4.1-20180728210220-1136-g75a6720
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
DriverStation.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2013-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <stdint.h>
11 
12 #include "hal/Types.h"
13 
14 #define HAL_IO_CONFIG_DATA_SIZE 32
15 #define HAL_SYS_STATUS_DATA_SIZE 44
16 #define HAL_USER_STATUS_DATA_SIZE \
17  (984 - HAL_IO_CONFIG_DATA_SIZE - HAL_SYS_STATUS_DATA_SIZE)
18 
19 #define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input 17
20 #define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output 18
21 #define HALFRC_NetworkCommunication_DynamicType_Kinect_Header 19
22 #define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra1 20
23 #define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices1 21
24 #define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra2 22
25 #define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices2 23
26 #define HALFRC_NetworkCommunication_DynamicType_Kinect_Joystick 24
27 #define HALFRC_NetworkCommunication_DynamicType_Kinect_Custom 25
28 
30  uint32_t enabled : 1;
31  uint32_t autonomous : 1;
32  uint32_t test : 1;
33  uint32_t eStop : 1;
34  uint32_t fmsAttached : 1;
35  uint32_t dsAttached : 1;
36  uint32_t control_reserved : 26;
37 };
38 typedef struct HAL_ControlWord HAL_ControlWord;
39 
40 // clang-format off
41 HAL_ENUM(HAL_AllianceStationID) {
42  HAL_AllianceStationID_kRed1,
43  HAL_AllianceStationID_kRed2,
44  HAL_AllianceStationID_kRed3,
45  HAL_AllianceStationID_kBlue1,
46  HAL_AllianceStationID_kBlue2,
47  HAL_AllianceStationID_kBlue3,
48 };
49 
50 HAL_ENUM(HAL_MatchType) {
51  HAL_kMatchType_none,
52  HAL_kMatchType_practice,
53  HAL_kMatchType_qualification,
54  HAL_kMatchType_elimination,
55 };
56 // clang-format on
57 
58 /* The maximum number of axes that will be stored in a single HALJoystickAxes
59  * struct. This is used for allocating buffers, not bounds checking, since
60  * there are usually less axes in practice.
61  */
62 #define HAL_kMaxJoystickAxes 12
63 #define HAL_kMaxJoystickPOVs 12
64 #define HAL_kMaxJoysticks 6
65 
67  int16_t count;
68  float axes[HAL_kMaxJoystickAxes];
69 };
70 typedef struct HAL_JoystickAxes HAL_JoystickAxes;
71 
73  int16_t count;
74  int16_t povs[HAL_kMaxJoystickPOVs];
75 };
76 typedef struct HAL_JoystickPOVs HAL_JoystickPOVs;
77 
79  uint32_t buttons;
80  uint8_t count;
81 };
83 
85  uint8_t isXbox;
86  uint8_t type;
87  char name[256];
88  uint8_t axisCount;
89  uint8_t axisTypes[HAL_kMaxJoystickAxes];
90  uint8_t buttonCount;
91  uint8_t povCount;
92 };
94 
95 struct HAL_MatchInfo {
96  char eventName[64];
97  HAL_MatchType matchType;
98  uint16_t matchNumber;
99  uint8_t replayNumber;
100  uint8_t gameSpecificMessage[64];
101  uint16_t gameSpecificMessageSize;
102 };
103 typedef struct HAL_MatchInfo HAL_MatchInfo;
104 
105 #ifdef __cplusplus
106 extern "C" {
107 #endif
108 
121 int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
122  const char* details, const char* location,
123  const char* callStack, HAL_Bool printMsg);
124 
133 int32_t HAL_GetControlWord(HAL_ControlWord* controlWord);
134 
141 HAL_AllianceStationID HAL_GetAllianceStation(int32_t* status);
142 
150 int32_t HAL_GetJoystickAxes(int32_t joystickNum, HAL_JoystickAxes* axes);
151 
159 int32_t HAL_GetJoystickPOVs(int32_t joystickNum, HAL_JoystickPOVs* povs);
160 
168 int32_t HAL_GetJoystickButtons(int32_t joystickNum,
169  HAL_JoystickButtons* buttons);
170 
183 int32_t HAL_GetJoystickDescriptor(int32_t joystickNum,
184  HAL_JoystickDescriptor* desc);
185 
192 HAL_Bool HAL_GetJoystickIsXbox(int32_t joystickNum);
193 
203 int32_t HAL_GetJoystickType(int32_t joystickNum);
204 
215 char* HAL_GetJoystickName(int32_t joystickNum);
216 
222 void HAL_FreeJoystickName(char* name);
223 
234 int32_t HAL_GetJoystickAxisType(int32_t joystickNum, int32_t axis);
235 
245 int32_t HAL_SetJoystickOutputs(int32_t joystickNum, int64_t outputs,
246  int32_t leftRumble, int32_t rightRumble);
247 
264 double HAL_GetMatchTime(int32_t* status);
265 
272 int32_t HAL_GetMatchInfo(HAL_MatchInfo* info);
273 
274 #ifndef HAL_USE_LABVIEW
275 
280 void HAL_ReleaseDSMutex(void);
281 
288 HAL_Bool HAL_IsNewControlData(void);
289 
293 void HAL_WaitForDSData(void);
294 
303 HAL_Bool HAL_WaitForDSDataTimeout(double timeout);
304 
310 void HAL_InitializeDriverStation(void);
311 
317 void HAL_ObserveUserProgramStarting(void);
318 
326 void HAL_ObserveUserProgramDisabled(void);
327 
335 void HAL_ObserveUserProgramAutonomous(void);
336 
344 void HAL_ObserveUserProgramTeleop(void);
345 
353 void HAL_ObserveUserProgramTest(void);
354 
355 #endif // HAL_USE_LABVIEW
356 
357 #ifdef __cplusplus
358 } // extern "C"
359 #endif
Definition: DriverStation.h:84
Definition: DriverStation.h:95
Definition: DriverStation.h:72
Definition: DriverStation.h:78
Definition: DriverStation.h:29
Definition: DriverStation.h:66