WPILibC++ 2023.4.3-108-ge5452e3
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 * Gets the current state of the Robot Signal Light (RSL)
106 * @return The current state of the RSL- true if on, false if off
107 */
108 static bool GetRSLState();
109
110 /**
111 * Get the input voltage to the robot controller.
112 *
113 * @return The controller input voltage value in Volts
114 */
115 static double GetInputVoltage();
116
117 /**
118 * Get the input current to the robot controller.
119 *
120 * @return The controller input current value in Amps
121 */
122 static double GetInputCurrent();
123
124 /**
125 * Get the voltage of the 3.3V rail.
126 *
127 * @return The controller 3.3V rail voltage value in Volts
128 */
129 static double GetVoltage3V3();
130
131 /**
132 * Get the current output of the 3.3V rail.
133 *
134 * @return The controller 3.3V rail output current value in Amps
135 */
136 static double GetCurrent3V3();
137
138 /**
139 * Get the enabled state of the 3.3V rail. The rail may be disabled due to a
140 * controller brownout, a short circuit on the rail, or controller
141 * over-voltage.
142 *
143 * @return The controller 3.3V rail enabled value. True for enabled.
144 */
145 static bool GetEnabled3V3();
146
147 /**
148 * Get the count of the total current faults on the 3.3V rail since the
149 * controller has booted.
150 *
151 * @return The number of faults
152 */
153 static int GetFaultCount3V3();
154
155 /**
156 * Get the voltage of the 5V rail.
157 *
158 * @return The controller 5V rail voltage value in Volts
159 */
160 static double GetVoltage5V();
161
162 /**
163 * Get the current output of the 5V rail.
164 *
165 * @return The controller 5V rail output current value in Amps
166 */
167 static double GetCurrent5V();
168
169 /**
170 * Get the enabled state of the 5V rail. The rail may be disabled due to a
171 * controller brownout, a short circuit on the rail, or controller
172 * over-voltage.
173 *
174 * @return The controller 5V rail enabled value. True for enabled.
175 */
176 static bool GetEnabled5V();
177
178 /**
179 * Get the count of the total current faults on the 5V rail since the
180 * controller has booted.
181 *
182 * @return The number of faults
183 */
184 static int GetFaultCount5V();
185
186 /**
187 * Get the voltage of the 6V rail.
188 *
189 * @return The controller 6V rail voltage value in Volts
190 */
191 static double GetVoltage6V();
192
193 /**
194 * Get the current output of the 6V rail.
195 *
196 * @return The controller 6V rail output current value in Amps
197 */
198 static double GetCurrent6V();
199
200 /**
201 * Get the enabled state of the 6V rail. The rail may be disabled due to a
202 * controller brownout, a short circuit on the rail, or controller
203 * over-voltage.
204 *
205 * @return The controller 6V rail enabled value. True for enabled.
206 */
207 static bool GetEnabled6V();
208
209 /**
210 * Get the count of the total current faults on the 6V rail since the
211 * controller has booted.
212 *
213 * @return The number of faults.
214 */
215 static int GetFaultCount6V();
216
217 /**
218 * Get the current brownout voltage setting.
219 *
220 * @return The brownout voltage
221 */
222 static units::volt_t GetBrownoutVoltage();
223
224 /**
225 * Set the voltage the roboRIO will brownout and disable all outputs.
226 *
227 * Note that this only does anything on the roboRIO 2.
228 * On the roboRIO it is a no-op.
229 *
230 * @param brownoutVoltage The brownout voltage
231 */
232 static void SetBrownoutVoltage(units::volt_t brownoutVoltage);
233
234 /**
235 * Get the current status of the CAN bus.
236 *
237 * @return The status of the CAN bus
238 */
240};
241
242} // 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 GetRSLState()
Gets the current state of the Robot Signal Light (RSL)
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: AprilTagPoseEstimator.h:15
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