Package edu.wpi.first.wpilibj
Class RobotController
java.lang.Object
edu.wpi.first.wpilibj.RobotController
Contains functions for roboRIO functionality.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
State for the radio led. -
Method Summary
Modifier and TypeMethodDescriptionstatic double
Read the battery voltage.static double
Get the current brownout voltage setting.static CANStatus
Get the current status of the CAN bus.static String
Return the comments from the roboRIO web interface.static int
Gets the number of times the system has been disabled due to communication errors with the Driver Station.static double
Get the current CPU temperature in degrees Celsius.static double
Get the current output of the 3.3V rail.static double
Get the current output of the 5V rail.static double
Get the current output of the 6V rail.static boolean
Get the enabled state of the 3.3V rail.static boolean
Get the enabled state of the 5V rail.static boolean
Get the enabled state of the 6V rail.static int
Get the count of the total current faults on the 3.3V rail since the code started.static int
Get the count of the total current faults on the 5V rail since the code started.static int
Get the count of the total current faults on the 6V rail since the code started.static long
Return the FPGA Revision number.static long
Read the microsecond timer from the FPGA.static int
Return the FPGA Version number.static double
Get the input current to the robot controller.static double
Get the input voltage to the robot controller.static Voltage
Read the battery voltage in a measure.static Voltage
Get the current brownout voltage setting in a measure.static Temperature
Get the current CPU temperature in a measure.static Current
Get the current output in a measure of the 3.3V rail.static Current
Get the current output in a measure of the 5V rail.static Current
Get the current output in a measure of the 6V rail.static Time
Read the microsecond timer in a measure from the FPGA.static Current
Get the input current to the robot controller in a measure.static Voltage
Get the input voltage to the robot controller in a measure.static Time
Read the microsecond timestamp.static Voltage
Get the voltage in a measure of the 3.3V rail.static Voltage
Get the voltage in a measure of the 5V rail.static Voltage
Get the voltage in a measure of the 6V rail.Get the state of the "Radio" LED.static boolean
Gets the current state of the Robot Signal Light (RSL).static String
Return the serial number of the roboRIO.static int
Returns the team number configured for the robot controller.static long
getTime()
Read the microsecond timestamp.static boolean
Get the state of the "USER" button on the roboRIO.static double
Get the voltage of the 3.3V rail.static double
Get the voltage of the 5V rail.static double
Get the voltage of the 6V rail.static boolean
Check if the system is browned out.static boolean
Gets a value indicating whether the FPGA outputs are enabled.static boolean
Gets if the system time is valid.static void
Reset the overcurrent fault counters for all user rails to 0.static void
setBrownoutVoltage
(double brownoutVoltage) Set the voltage the roboRIO will brownout and disable all outputs.static void
setBrownoutVoltage
(Voltage brownoutVoltage) Set the voltage in a measure the roboRIO will brownout and disable all outputs.static void
setEnabled3V3
(boolean enabled) Enables or disables the 3.3V rail.static void
setEnabled5V
(boolean enabled) Enables or disables the 5V rail.static void
setEnabled6V
(boolean enabled) Enables or disables the 6V rail.static void
Set the state of the "Radio" LED.static void
setTimeSource
(LongSupplier supplier) Sets a new source to provide the clock time in microseconds.
-
Method Details
-
getFPGAVersion
Return the FPGA Version number. For now, expect this to be the current year.- Returns:
- FPGA Version number.
-
getFPGARevision
Return the FPGA Revision number. The format of the revision is 3 numbers. The 12 most significant bits are the Major Revision. the next 8 bits are the Minor Revision. The 12 least significant bits are the Build Number.- Returns:
- FPGA Revision number.
-
getSerialNumber
Return the serial number of the roboRIO.- Returns:
- The serial number of the roboRIO.
-
getComments
Return the comments from the roboRIO web interface.The comments string is cached after the first call to this function on the RoboRIO - restart the robot code to reload the comments string after changing it in the web interface.
- Returns:
- the comments from the roboRIO web interface.
-
getTeamNumber
Returns the team number configured for the robot controller.- Returns:
- team number, or 0 if not found.
-
setTimeSource
Sets a new source to provide the clock time in microseconds. Changing this affects the return value ofgetTime
in Java.- Parameters:
supplier
- Function to return the time in microseconds.
-
getTime
Read the microsecond timestamp. By default, the time is based on the FPGA hardware clock in microseconds since the FPGA started. However, the return value of this method may be modified to use any time base, including non-monotonic and non-continuous time bases.- Returns:
- The current time in microseconds.
-
getMeasureTime
Read the microsecond timestamp. By default, the time is based on the FPGA hardware clock in microseconds since the FPGA started. However, the return value of this method may be modified to use any time base, including non-monotonic and non-continuous time bases.- Returns:
- The current time in a measure.
-
getFPGATime
Read the microsecond timer from the FPGA.- Returns:
- The current time in microseconds according to the FPGA.
-
getMeasureFPGATime
Read the microsecond timer in a measure from the FPGA.- Returns:
- The current time according to the FPGA in a measure.
-
getUserButton
Get the state of the "USER" button on the roboRIO.Warning: the User Button is used to stop user programs from automatically loading if it is held for more then 5 seconds. Because of this, it's not recommended to be used by teams for any other purpose.
- Returns:
- true if the button is currently pressed down
-
getBatteryVoltage
Read the battery voltage.- Returns:
- The battery voltage in Volts.
-
getMeasureBatteryVoltage
Read the battery voltage in a measure.- Returns:
- The battery voltage in a measure.
-
isSysActive
Gets a value indicating whether the FPGA outputs are enabled. The outputs may be disabled if the robot is disabled or e-stopped, the watchdog has expired, or if the roboRIO browns out.- Returns:
- True if the FPGA outputs are enabled.
-
isBrownedOut
Check if the system is browned out.- Returns:
- True if the system is browned out
-
getCommsDisableCount
Gets the number of times the system has been disabled due to communication errors with the Driver Station.- Returns:
- number of disables due to communication errors.
-
getRSLState
Gets the current state of the Robot Signal Light (RSL).- Returns:
- The current state of the RSL- true if on, false if off
-
isSystemTimeValid
Gets if the system time is valid.- Returns:
- True if the system time is valid, false otherwise
-
getInputVoltage
Get the input voltage to the robot controller.- Returns:
- The controller input voltage value in Volts
-
getMeasureInputVoltage
Get the input voltage to the robot controller in a measure.- Returns:
- The controller input voltage value in a measure.
-
getInputCurrent
Get the input current to the robot controller.- Returns:
- The controller input current value in Amps
-
getMeasureInputCurrent
Get the input current to the robot controller in a measure.- Returns:
- The controller input current value in a measure.
-
getVoltage3V3
Get the voltage of the 3.3V rail.- Returns:
- The controller 3.3V rail voltage value in Volts
-
getMeasureVoltage3V3
Get the voltage in a measure of the 3.3V rail.- Returns:
- The controller 3.3V rail voltage value in a measure.
-
getCurrent3V3
Get the current output of the 3.3V rail.- Returns:
- The controller 3.3V rail output current value in Amps
-
getMeasureCurrent3V3
Get the current output in a measure of the 3.3V rail.- Returns:
- The controller 3.3V rail output current value in a measure.
-
setEnabled3V3
Enables or disables the 3.3V rail.- Parameters:
enabled
- whether to enable the 3.3V rail.
-
getEnabled3V3
Get the enabled state of the 3.3V rail. The rail may be disabled due to a controller brownout, a short circuit on the rail, or controller over-voltage.- Returns:
- The controller 3.3V rail enabled value
-
getFaultCount3V3
Get the count of the total current faults on the 3.3V rail since the code started.- Returns:
- The number of faults
-
getVoltage5V
Get the voltage of the 5V rail.- Returns:
- The controller 5V rail voltage value in Volts
-
getMeasureVoltage5V
Get the voltage in a measure of the 5V rail.- Returns:
- The controller 5V rail voltage value in a measure.
-
getCurrent5V
Get the current output of the 5V rail.- Returns:
- The controller 5V rail output current value in Amps
-
getMeasureCurrent5V
Get the current output in a measure of the 5V rail.- Returns:
- The controller 5V rail output current value in a measure.
-
setEnabled5V
Enables or disables the 5V rail.- Parameters:
enabled
- whether to enable the 5V rail.
-
getEnabled5V
Get the enabled state of the 5V rail. The rail may be disabled due to a controller brownout, a short circuit on the rail, or controller over-voltage.- Returns:
- The controller 5V rail enabled value
-
getFaultCount5V
Get the count of the total current faults on the 5V rail since the code started.- Returns:
- The number of faults
-
getVoltage6V
Get the voltage of the 6V rail.- Returns:
- The controller 6V rail voltage value in Volts
-
getMeasureVoltage6V
Get the voltage in a measure of the 6V rail.- Returns:
- The controller 6V rail voltage value in a measure.
-
getCurrent6V
Get the current output of the 6V rail.- Returns:
- The controller 6V rail output current value in Amps
-
getMeasureCurrent6V
Get the current output in a measure of the 6V rail.- Returns:
- The controller 6V rail output current value in a measure.
-
setEnabled6V
Enables or disables the 6V rail.- Parameters:
enabled
- whether to enable the 6V rail.
-
getEnabled6V
Get the enabled state of the 6V rail. The rail may be disabled due to a controller brownout, a short circuit on the rail, or controller over-voltage.- Returns:
- The controller 6V rail enabled value
-
getFaultCount6V
Get the count of the total current faults on the 6V rail since the code started.- Returns:
- The number of faults
-
resetRailFaultCounts
Reset the overcurrent fault counters for all user rails to 0. -
getBrownoutVoltage
Get the current brownout voltage setting.- Returns:
- The brownout voltage
-
getMeasureBrownoutVoltage
Get the current brownout voltage setting in a measure.- Returns:
- The brownout voltage in a measure.
-
setBrownoutVoltage
Set the voltage the roboRIO will brownout and disable all outputs.Note that this only does anything on the roboRIO 2. On the roboRIO it is a no-op.
- Parameters:
brownoutVoltage
- The brownout voltage
-
setBrownoutVoltage
Set the voltage in a measure the roboRIO will brownout and disable all outputs.Note that this only does anything on the roboRIO 2. On the roboRIO it is a no-op.
- Parameters:
brownoutVoltage
- The brownout voltage in a measure
-
getCPUTemp
Get the current CPU temperature in degrees Celsius.- Returns:
- current CPU temperature in degrees Celsius
-
getMeasureCPUTemp
Get the current CPU temperature in a measure.- Returns:
- current CPU temperature in a measure.
-
setRadioLEDState
Set the state of the "Radio" LED. On the RoboRIO, this writes to sysfs, so this function should not be called multiple times per loop cycle to avoid overruns.- Parameters:
state
- The state to set the LED to.
-
getRadioLEDState
Get the state of the "Radio" LED. On the RoboRIO, this reads from sysfs, so this function should not be called multiple times per loop cycle to avoid overruns.- Returns:
- The state of the LED.
-
getCANStatus
Get the current status of the CAN bus.- Returns:
- The status of the CAN bus
-