WPILibC++ 2024.1.1-beta-4
RobotController.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9#include <string>
10
11#include <units/temperature.h>
12#include <units/voltage.h>
13
14namespace frc {
15
16struct CANStatus {
22};
23
25 public:
26 RobotController() = delete;
27
28 /**
29 * Return the FPGA Version number.
30 *
31 * For now, expect this to be competition year.
32 *
33 * @return FPGA Version number.
34 */
35 static int GetFPGAVersion();
36
37 /**
38 * Return the FPGA Revision number.
39 *
40 * The format of the revision is 3 numbers. The 12 most significant bits are
41 * the Major Revision. The next 8 bits are the Minor Revision. The 12 least
42 * significant bits are the Build Number.
43 *
44 * @return FPGA Revision number.
45 */
46 static int64_t GetFPGARevision();
47
48 /**
49 * Return the serial number of the roboRIO.
50 *
51 * @return The serial number of the roboRIO.
52 */
53 static std::string GetSerialNumber();
54
55 /**
56 * Return the comments from the roboRIO web interface.
57 *
58 * The comments string is cached after the first call to this function on the
59 * RoboRIO - restart the robot code to reload the comments string after
60 * changing it in the web interface.
61 *
62 * @return The comments from the roboRIO web interface.
63 */
64 static std::string GetComments();
65
66 /**
67 * Returns the team number configured for the robot controller.
68 *
69 * @return team number, or 0 if not found.
70 */
71 static int32_t GetTeamNumber();
72
73 /**
74 * Read the microsecond-resolution timer on the FPGA.
75 *
76 * @return The current time in microseconds according to the FPGA (since FPGA
77 * reset).
78 */
79 static uint64_t GetFPGATime();
80
81 /**
82 * Get the state of the "USER" button on the roboRIO.
83 *
84 * @return True if the button is currently pressed down
85 */
86 static bool GetUserButton();
87
88 /**
89 * Read the battery voltage.
90 *
91 * @return The battery voltage in Volts.
92 */
93 static units::volt_t GetBatteryVoltage();
94
95 /**
96 * Check if the FPGA outputs are enabled.
97 *
98 * The outputs may be disabled if the robot is disabled or e-stopped, the
99 * watchdog has expired, or if the roboRIO browns out.
100 *
101 * @return True if the FPGA outputs are enabled.
102 */
103 static bool IsSysActive();
104
105 /**
106 * Check if the system is browned out.
107 *
108 * @return True if the system is browned out
109 */
110 static bool IsBrownedOut();
111
112 /**
113 * Gets the current state of the Robot Signal Light (RSL)
114 * @return The current state of the RSL- true if on, false if off
115 */
116 static bool GetRSLState();
117
118 /**
119 * Gets if the system time is valid.
120 *
121 * @return True if the system time is valid, false otherwise
122 */
123 static bool IsSystemTimeValid();
124
125 /**
126 * Get the input voltage to the robot controller.
127 *
128 * @return The controller input voltage value in Volts
129 */
130 static double GetInputVoltage();
131
132 /**
133 * Get the input current to the robot controller.
134 *
135 * @return The controller input current value in Amps
136 */
137 static double GetInputCurrent();
138
139 /**
140 * Get the voltage of the 3.3V rail.
141 *
142 * @return The controller 3.3V rail voltage value in Volts
143 */
144 static double GetVoltage3V3();
145
146 /**
147 * Get the current output of the 3.3V rail.
148 *
149 * @return The controller 3.3V rail output current value in Amps
150 */
151 static double GetCurrent3V3();
152
153 /**
154 * Enables or disables the 3.3V rail.
155 *
156 * @param enabled whether to enable the 3.3V rail.
157 */
158 static void SetEnabled3V3(bool enabled);
159
160 /**
161 * Get the enabled state of the 3.3V rail. The rail may be disabled due to
162 * calling SetEnabled3V3(), a controller brownout, a short circuit on the
163 * rail, or controller over-voltage.
164 *
165 * @return The controller 3.3V rail enabled value. True for enabled.
166 */
167 static bool GetEnabled3V3();
168
169 /**
170 * Get the count of the total current faults on the 3.3V rail since the
171 * controller has booted.
172 *
173 * @return The number of faults
174 */
175 static int GetFaultCount3V3();
176
177 /**
178 * Get the voltage of the 5V rail.
179 *
180 * @return The controller 5V rail voltage value in Volts
181 */
182 static double GetVoltage5V();
183
184 /**
185 * Get the current output of the 5V rail.
186 *
187 * @return The controller 5V rail output current value in Amps
188 */
189 static double GetCurrent5V();
190
191 /**
192 * Enables or disables the 5V rail.
193 *
194 * @param enabled whether to enable the 5V rail.
195 */
196 static void SetEnabled5V(bool enabled);
197
198 /**
199 * Get the enabled state of the 5V rail. The rail may be disabled due to
200 * calling SetEnabled5V(), a controller brownout, a short circuit on the rail,
201 * or controller over-voltage.
202 *
203 * @return The controller 5V rail enabled value. True for enabled.
204 */
205 static bool GetEnabled5V();
206
207 /**
208 * Get the count of the total current faults on the 5V rail since the
209 * controller has booted.
210 *
211 * @return The number of faults
212 */
213 static int GetFaultCount5V();
214
215 /**
216 * Get the voltage of the 6V rail.
217 *
218 * @return The controller 6V rail voltage value in Volts
219 */
220 static double GetVoltage6V();
221
222 /**
223 * Get the current output of the 6V rail.
224 *
225 * @return The controller 6V rail output current value in Amps
226 */
227 static double GetCurrent6V();
228
229 /**
230 * Enables or disables the 6V rail.
231 *
232 * @param enabled whether to enable the 6V rail.
233 */
234 static void SetEnabled6V(bool enabled);
235
236 /**
237 * Get the enabled state of the 6V rail. The rail may be disabled due to
238 * calling SetEnabled6V(), a controller brownout, a short circuit on the rail,
239 * or controller over-voltage.
240 *
241 * @return The controller 6V rail enabled value. True for enabled.
242 */
243 static bool GetEnabled6V();
244
245 /**
246 * Get the count of the total current faults on the 6V rail since the
247 * controller has booted.
248 *
249 * @return The number of faults.
250 */
251 static int GetFaultCount6V();
252
253 /**
254 * Get the current brownout voltage setting.
255 *
256 * @return The brownout voltage
257 */
258 static units::volt_t GetBrownoutVoltage();
259
260 /**
261 * Set the voltage the roboRIO will brownout and disable all outputs.
262 *
263 * Note that this only does anything on the roboRIO 2.
264 * On the roboRIO it is a no-op.
265 *
266 * @param brownoutVoltage The brownout voltage
267 */
268 static void SetBrownoutVoltage(units::volt_t brownoutVoltage);
269
270 /**
271 * Get the current CPU temperature.
272 *
273 * @return current CPU temperature
274 */
275 static units::celsius_t GetCPUTemp();
276
277 /**
278 * Get the current status of the CAN bus.
279 *
280 * @return The status of the CAN bus
281 */
283};
284
285} // namespace frc
Definition: RobotController.h:24
static bool IsSysActive()
Check if the FPGA outputs are enabled.
static void SetBrownoutVoltage(units::volt_t brownoutVoltage)
Set the voltage the roboRIO will brownout and disable all outputs.
static int GetFaultCount3V3()
Get the count of the total current faults on the 3.3V rail since the controller has booted.
static std::string GetComments()
Return the comments from the roboRIO web interface.
static uint64_t GetFPGATime()
Read the microsecond-resolution timer on the FPGA.
static bool GetEnabled3V3()
Get the enabled state of the 3.3V rail.
static units::volt_t GetBatteryVoltage()
Read the battery voltage.
static double GetVoltage5V()
Get the voltage of the 5V rail.
static int GetFaultCount5V()
Get the count of the total current faults on the 5V rail since the controller has booted.
static CANStatus GetCANStatus()
Get the current status of the CAN bus.
static bool IsBrownedOut()
Check if the system is browned out.
static bool IsSystemTimeValid()
Gets if the system time is valid.
static int GetFPGAVersion()
Return the FPGA Version number.
static int64_t GetFPGARevision()
Return the FPGA Revision number.
static double GetVoltage3V3()
Get the voltage of the 3.3V rail.
static int GetFaultCount6V()
Get the count of the total current faults on the 6V rail since the controller has booted.
static units::volt_t GetBrownoutVoltage()
Get the current brownout voltage setting.
static void SetEnabled6V(bool enabled)
Enables or disables the 6V rail.
static std::string GetSerialNumber()
Return the serial number of the roboRIO.
static double GetInputVoltage()
Get the input voltage to the robot controller.
static double GetVoltage6V()
Get the voltage of the 6V rail.
static bool GetEnabled5V()
Get the enabled state of the 5V rail.
static void SetEnabled5V(bool enabled)
Enables or disables the 5V rail.
static double GetCurrent3V3()
Get the current output of the 3.3V rail.
static units::celsius_t GetCPUTemp()
Get the current CPU temperature.
static bool GetUserButton()
Get the state of the "USER" button on the roboRIO.
static int32_t GetTeamNumber()
Returns the team number configured for the robot controller.
static bool GetRSLState()
Gets the current state of the Robot Signal Light (RSL)
static bool GetEnabled6V()
Get the enabled state of the 6V rail.
static void SetEnabled3V3(bool enabled)
Enables or disables the 3.3V rail.
static double GetCurrent6V()
Get the current output of the 6V rail.
static double GetCurrent5V()
Get the current output of the 5V rail.
static double GetInputCurrent()
Get the input current to the robot controller.
Definition: AprilTagPoseEstimator.h:15
Definition: RobotController.h:16
int busOffCount
Definition: RobotController.h:18
int receiveErrorCount
Definition: RobotController.h:20
float percentBusUtilization
Definition: RobotController.h:17
int txFullCount
Definition: RobotController.h:19
int transmitErrorCount
Definition: RobotController.h:21