WPILibC++ 2023.4.3
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/voltage.h>
12
13namespace frc {
14
15struct CANStatus {
21};
22
24 public:
25 RobotController() = delete;
26
27 /**
28 * Return the FPGA Version number.
29 *
30 * For now, expect this to be competition year.
31 *
32 * @return FPGA Version number.
33 */
34 static int GetFPGAVersion();
35
36 /**
37 * Return the FPGA Revision number.
38 *
39 * The format of the revision is 3 numbers. The 12 most significant bits are
40 * the Major Revision. The next 8 bits are the Minor Revision. The 12 least
41 * significant bits are the Build Number.
42 *
43 * @return FPGA Revision number.
44 */
46
47 /**
48 * Return the serial number of the roboRIO.
49 *
50 * @return The serial number of the roboRIO.
51 */
52 static std::string GetSerialNumber();
53
54 /**
55 * Return the comments from the roboRIO web interface.
56 *
57 * The comments string is cached after the first call to this function on the
58 * RoboRIO - restart the robot code to reload the comments string after
59 * changing it in the web interface.
60 *
61 * @return The comments from the roboRIO web interface.
62 */
63 static std::string GetComments();
64
65 /**
66 * Read the microsecond-resolution timer on the FPGA.
67 *
68 * @return The current time in microseconds according to the FPGA (since FPGA
69 * reset).
70 */
72
73 /**
74 * Get the state of the "USER" button on the roboRIO.
75 *
76 * @return True if the button is currently pressed down
77 */
78 static bool GetUserButton();
79
80 /**
81 * Read the battery voltage.
82 *
83 * @return The battery voltage in Volts.
84 */
85 static units::volt_t GetBatteryVoltage();
86
87 /**
88 * Check if the FPGA outputs are enabled.
89 *
90 * The outputs may be disabled if the robot is disabled or e-stopped, the
91 * watchdog has expired, or if the roboRIO browns out.
92 *
93 * @return True if the FPGA outputs are enabled.
94 */
95 static bool IsSysActive();
96
97 /**
98 * Check if the system is browned out.
99 *
100 * @return True if the system is browned out
101 */
102 static bool IsBrownedOut();
103
104 /**
105 * Get the input voltage to the robot controller.
106 *
107 * @return The controller input voltage value in Volts
108 */
109 static double GetInputVoltage();
110
111 /**
112 * Get the input current to the robot controller.
113 *
114 * @return The controller input current value in Amps
115 */
116 static double GetInputCurrent();
117
118 /**
119 * Get the voltage of the 3.3V rail.
120 *
121 * @return The controller 3.3V rail voltage value in Volts
122 */
123 static double GetVoltage3V3();
124
125 /**
126 * Get the current output of the 3.3V rail.
127 *
128 * @return The controller 3.3V rail output current value in Amps
129 */
130 static double GetCurrent3V3();
131
132 /**
133 * Get the enabled state of the 3.3V rail. The rail may be disabled due to a
134 * controller brownout, a short circuit on the rail, or controller
135 * over-voltage.
136 *
137 * @return The controller 3.3V rail enabled value. True for enabled.
138 */
139 static bool GetEnabled3V3();
140
141 /**
142 * Get the count of the total current faults on the 3.3V rail since the
143 * controller has booted.
144 *
145 * @return The number of faults
146 */
147 static int GetFaultCount3V3();
148
149 /**
150 * Get the voltage of the 5V rail.
151 *
152 * @return The controller 5V rail voltage value in Volts
153 */
154 static double GetVoltage5V();
155
156 /**
157 * Get the current output of the 5V rail.
158 *
159 * @return The controller 5V rail output current value in Amps
160 */
161 static double GetCurrent5V();
162
163 /**
164 * Get the enabled state of the 5V rail. The rail may be disabled due to a
165 * controller brownout, a short circuit on the rail, or controller
166 * over-voltage.
167 *
168 * @return The controller 5V rail enabled value. True for enabled.
169 */
170 static bool GetEnabled5V();
171
172 /**
173 * Get the count of the total current faults on the 5V rail since the
174 * controller has booted.
175 *
176 * @return The number of faults
177 */
178 static int GetFaultCount5V();
179
180 /**
181 * Get the voltage of the 6V rail.
182 *
183 * @return The controller 6V rail voltage value in Volts
184 */
185 static double GetVoltage6V();
186
187 /**
188 * Get the current output of the 6V rail.
189 *
190 * @return The controller 6V rail output current value in Amps
191 */
192 static double GetCurrent6V();
193
194 /**
195 * Get the enabled state of the 6V rail. The rail may be disabled due to a
196 * controller brownout, a short circuit on the rail, or controller
197 * over-voltage.
198 *
199 * @return The controller 6V rail enabled value. True for enabled.
200 */
201 static bool GetEnabled6V();
202
203 /**
204 * Get the count of the total current faults on the 6V rail since the
205 * controller has booted.
206 *
207 * @return The number of faults.
208 */
209 static int GetFaultCount6V();
210
211 /**
212 * Get the current brownout voltage setting.
213 *
214 * @return The brownout voltage
215 */
216 static units::volt_t GetBrownoutVoltage();
217
218 /**
219 * Set the voltage the roboRIO will brownout and disable all outputs.
220 *
221 * Note that this only does anything on the roboRIO 2.
222 * On the roboRIO it is a no-op.
223 *
224 * @param brownoutVoltage The brownout voltage
225 */
226 static void SetBrownoutVoltage(units::volt_t brownoutVoltage);
227
228 /**
229 * Get the current status of the CAN bus.
230 *
231 * @return The status of the CAN bus
232 */
234};
235
236} // namespace frc
Definition: RobotController.h:23
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 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 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 double GetCurrent3V3()
Get the current output of the 3.3V rail.
static bool GetUserButton()
Get the state of the "USER" button on the roboRIO.
static bool GetEnabled6V()
Get the enabled state of the 6V 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.
::uint64_t uint64_t
Definition: Meta.h:58
::int64_t int64_t
Definition: Meta.h:59
Definition: AprilTagFieldLayout.h:22
Definition: RobotController.h:15
int busOffCount
Definition: RobotController.h:17
int receiveErrorCount
Definition: RobotController.h:19
float percentBusUtilization
Definition: RobotController.h:16
int txFullCount
Definition: RobotController.h:18
int transmitErrorCount
Definition: RobotController.h:20