[hal, wpilib] Remove power rails that don't exist on systemcore (#7861)

This commit is contained in:
Thad House
2025-03-14 10:16:08 -07:00
committed by GitHub
parent d3cc185382
commit 52b353fe57
44 changed files with 27 additions and 3196 deletions

View File

@@ -112,7 +112,7 @@ public class AnalogEncoder implements Sendable, AutoCloseable {
}
double analog = m_analogInput.getVoltage();
double pos = analog / RobotController.getVoltage5V();
double pos = analog / RobotController.getVoltage3V3();
// Map sensor range if range isn't full
pos = mapSensorRange(pos);

View File

@@ -125,7 +125,7 @@ public class AnalogPotentiometer implements Sendable, AutoCloseable {
if (m_analogInput == null) {
return m_offset;
}
return (m_analogInput.getAverageVoltage() / RobotController.getVoltage5V()) * m_fullRange
return (m_analogInput.getAverageVoltage() / RobotController.getVoltage3V3()) * m_fullRange
+ m_offset;
}

View File

@@ -11,7 +11,6 @@ import static edu.wpi.first.units.Units.Volts;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.HALUtil;
import edu.wpi.first.hal.LEDJNI;
import edu.wpi.first.hal.PowerJNI;
import edu.wpi.first.hal.can.CANJNI;
import edu.wpi.first.hal.can.CANStatus;
@@ -129,19 +128,6 @@ public final class RobotController {
return Microseconds.of(HALUtil.getFPGATime());
}
/**
* Get the state of the "USER" button on the roboRIO.
*
* <p>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.
*
* @return true if the button is currently pressed down
*/
public static boolean getUserButton() {
return HALUtil.getFPGAButton();
}
/**
* Read the battery voltage.
*
@@ -225,24 +211,6 @@ public final class RobotController {
return Volts.of(PowerJNI.getVinVoltage());
}
/**
* Get the input current to the robot controller.
*
* @return The controller input current value in Amps
*/
public static double getInputCurrent() {
return PowerJNI.getVinCurrent();
}
/**
* Get the input current to the robot controller in a measure.
*
* @return The controller input current value in a measure.
*/
public static Current getMeasureInputCurrent() {
return Amps.of(PowerJNI.getVinCurrent());
}
/**
* Get the voltage of the 3.3V rail.
*
@@ -307,134 +275,6 @@ public final class RobotController {
return PowerJNI.getUserCurrentFaults3V3();
}
/**
* Get the voltage of the 5V rail.
*
* @return The controller 5V rail voltage value in Volts
*/
public static double getVoltage5V() {
return PowerJNI.getUserVoltage5V();
}
/**
* Get the voltage in a measure of the 5V rail.
*
* @return The controller 5V rail voltage value in a measure.
*/
public static Voltage getMeasureVoltage5V() {
return Volts.of(PowerJNI.getUserVoltage5V());
}
/**
* Get the current output of the 5V rail.
*
* @return The controller 5V rail output current value in Amps
*/
public static double getCurrent5V() {
return PowerJNI.getUserCurrent5V();
}
/**
* Get the current output in a measure of the 5V rail.
*
* @return The controller 5V rail output current value in a measure.
*/
public static Current getMeasureCurrent5V() {
return Amps.of(PowerJNI.getUserCurrent5V());
}
/**
* Enables or disables the 5V rail.
*
* @param enabled whether to enable the 5V rail.
*/
public static void setEnabled5V(boolean enabled) {
PowerJNI.setUserEnabled5V(enabled);
}
/**
* 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.
*
* @return The controller 5V rail enabled value
*/
public static boolean getEnabled5V() {
return PowerJNI.getUserActive5V();
}
/**
* Get the count of the total current faults on the 5V rail since the code started.
*
* @return The number of faults
*/
public static int getFaultCount5V() {
return PowerJNI.getUserCurrentFaults5V();
}
/**
* Get the voltage of the 6V rail.
*
* @return The controller 6V rail voltage value in Volts
*/
public static double getVoltage6V() {
return PowerJNI.getUserVoltage6V();
}
/**
* Get the voltage in a measure of the 6V rail.
*
* @return The controller 6V rail voltage value in a measure.
*/
public static Voltage getMeasureVoltage6V() {
return Volts.of(PowerJNI.getUserVoltage6V());
}
/**
* Get the current output of the 6V rail.
*
* @return The controller 6V rail output current value in Amps
*/
public static double getCurrent6V() {
return PowerJNI.getUserCurrent6V();
}
/**
* Get the current output in a measure of the 6V rail.
*
* @return The controller 6V rail output current value in a measure.
*/
public static Current getMeasureCurrent6V() {
return Amps.of(PowerJNI.getUserCurrent6V());
}
/**
* Enables or disables the 6V rail.
*
* @param enabled whether to enable the 6V rail.
*/
public static void setEnabled6V(boolean enabled) {
PowerJNI.setUserEnabled6V(enabled);
}
/**
* 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.
*
* @return The controller 6V rail enabled value
*/
public static boolean getEnabled6V() {
return PowerJNI.getUserActive6V();
}
/**
* Get the count of the total current faults on the 6V rail since the code started.
*
* @return The number of faults
*/
public static int getFaultCount6V() {
return PowerJNI.getUserCurrentFaults6V();
}
/** Reset the overcurrent fault counters for all user rails to 0. */
public static void resetRailFaultCounts() {
PowerJNI.resetUserCurrentFaults();
@@ -498,61 +338,6 @@ public final class RobotController {
return Celsius.of(PowerJNI.getCPUTemp());
}
/** State for the radio led. */
public enum RadioLEDState {
/** Off. */
kOff(LEDJNI.RADIO_LED_STATE_OFF),
/** Green. */
kGreen(LEDJNI.RADIO_LED_STATE_GREEN),
/** Red. */
kRed(LEDJNI.RADIO_LED_STATE_RED),
/** Orange. */
kOrange(LEDJNI.RADIO_LED_STATE_ORANGE);
/** The native value for this state. */
public final int value;
RadioLEDState(int value) {
this.value = value;
}
/**
* Gets a state from an int value.
*
* @param value int value
* @return state
*/
public static RadioLEDState fromValue(int value) {
return switch (value) {
case LEDJNI.RADIO_LED_STATE_OFF -> RadioLEDState.kOff;
case LEDJNI.RADIO_LED_STATE_GREEN -> RadioLEDState.kGreen;
case LEDJNI.RADIO_LED_STATE_RED -> RadioLEDState.kRed;
case LEDJNI.RADIO_LED_STATE_ORANGE -> RadioLEDState.kOrange;
default -> RadioLEDState.kOff;
};
}
}
/**
* 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.
*
* @param state The state to set the LED to.
*/
public static void setRadioLEDState(RadioLEDState state) {
LEDJNI.setRadioLEDState(state.value);
}
/**
* 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.
*
* @return The state of the LED.
*/
public static RadioLEDState getRadioLEDState() {
return RadioLEDState.fromValue(LEDJNI.getRadioLEDState());
}
/**
* Get the current status of the CAN bus.
*

View File

@@ -6,8 +6,6 @@ package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.NotifyCallback;
import edu.wpi.first.hal.simulation.RoboRioDataJNI;
import edu.wpi.first.wpilibj.RobotController;
import edu.wpi.first.wpilibj.RobotController.RadioLEDState;
/** A utility class to control a simulated RoboRIO. */
public final class RoboRioSim {
@@ -15,37 +13,6 @@ public final class RoboRioSim {
// Utility class
}
/**
* Register a callback to be run when the FPGA button state changes.
*
* @param callback the callback
* @param initialNotify whether to run the callback with the initial state
* @return the {@link CallbackStore} object associated with this callback.
*/
public static CallbackStore registerFPGAButtonCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerFPGAButtonCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelFPGAButtonCallback);
}
/**
* Query the state of the FPGA button.
*
* @return the FPGA button state
*/
public static boolean getFPGAButton() {
return RoboRioDataJNI.getFPGAButton();
}
/**
* Define the state of the FPGA button.
*
* @param fpgaButton the new state
*/
public static void setFPGAButton(boolean fpgaButton) {
RoboRioDataJNI.setFPGAButton(fpgaButton);
}
/**
* Register a callback to be run whenever the Vin voltage changes.
*
@@ -77,223 +44,6 @@ public final class RoboRioSim {
RoboRioDataJNI.setVInVoltage(vInVoltage);
}
/**
* Register a callback to be run whenever the Vin current changes.
*
* @param callback the callback
* @param initialNotify whether the callback should be called with the initial value
* @return the {@link CallbackStore} object associated with this callback.
*/
public static CallbackStore registerVInCurrentCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerVInCurrentCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelVInCurrentCallback);
}
/**
* Measure the Vin current.
*
* @return the Vin current
*/
public static double getVInCurrent() {
return RoboRioDataJNI.getVInCurrent();
}
/**
* Define the Vin current.
*
* @param vInCurrent the new current
*/
public static void setVInCurrent(double vInCurrent) {
RoboRioDataJNI.setVInCurrent(vInCurrent);
}
/**
* Register a callback to be run whenever the 6V rail voltage changes.
*
* @param callback the callback
* @param initialNotify whether the callback should be called with the initial value
* @return the {@link CallbackStore} object associated with this callback.
*/
public static CallbackStore registerUserVoltage6VCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserVoltage6VCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelUserVoltage6VCallback);
}
/**
* Measure the 6V rail voltage.
*
* @return the 6V rail voltage
*/
public static double getUserVoltage6V() {
return RoboRioDataJNI.getUserVoltage6V();
}
/**
* Define the 6V rail voltage.
*
* @param userVoltage6V the new voltage
*/
public static void setUserVoltage6V(double userVoltage6V) {
RoboRioDataJNI.setUserVoltage6V(userVoltage6V);
}
/**
* Register a callback to be run whenever the 6V rail current changes.
*
* @param callback the callback
* @param initialNotify whether the callback should be called with the initial value
* @return the {@link CallbackStore} object associated with this callback.
*/
public static CallbackStore registerUserCurrent6VCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserCurrent6VCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelUserCurrent6VCallback);
}
/**
* Measure the 6V rail current.
*
* @return the 6V rail current
*/
public static double getUserCurrent6V() {
return RoboRioDataJNI.getUserCurrent6V();
}
/**
* Define the 6V rail current.
*
* @param userCurrent6V the new current
*/
public static void setUserCurrent6V(double userCurrent6V) {
RoboRioDataJNI.setUserCurrent6V(userCurrent6V);
}
/**
* Register a callback to be run whenever the 6V rail active state changes.
*
* @param callback the callback
* @param initialNotify whether the callback should be called with the initial state
* @return the {@link CallbackStore} object associated with this callback.
*/
public static CallbackStore registerUserActive6VCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserActive6VCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelUserActive6VCallback);
}
/**
* Get the 6V rail active state.
*
* @return true if the 6V rail is active
*/
public static boolean getUserActive6V() {
return RoboRioDataJNI.getUserActive6V();
}
/**
* Set the 6V rail active state.
*
* @param userActive6V true to make rail active
*/
public static void setUserActive6V(boolean userActive6V) {
RoboRioDataJNI.setUserActive6V(userActive6V);
}
/**
* Register a callback to be run whenever the 5V rail voltage changes.
*
* @param callback the callback
* @param initialNotify whether the callback should be called with the initial value
* @return the {@link CallbackStore} object associated with this callback.
*/
public static CallbackStore registerUserVoltage5VCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserVoltage5VCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelUserVoltage5VCallback);
}
/**
* Measure the 5V rail voltage.
*
* @return the 5V rail voltage
*/
public static double getUserVoltage5V() {
return RoboRioDataJNI.getUserVoltage5V();
}
/**
* Define the 5V rail voltage.
*
* @param userVoltage5V the new voltage
*/
public static void setUserVoltage5V(double userVoltage5V) {
RoboRioDataJNI.setUserVoltage5V(userVoltage5V);
}
/**
* Register a callback to be run whenever the 5V rail current changes.
*
* @param callback the callback
* @param initialNotify whether the callback should be called with the initial value
* @return the {@link CallbackStore} object associated with this callback.
*/
public static CallbackStore registerUserCurrent5VCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserCurrent5VCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelUserCurrent5VCallback);
}
/**
* Measure the 5V rail current.
*
* @return the 5V rail current
*/
public static double getUserCurrent5V() {
return RoboRioDataJNI.getUserCurrent5V();
}
/**
* Define the 5V rail current.
*
* @param userCurrent5V the new current
*/
public static void setUserCurrent5V(double userCurrent5V) {
RoboRioDataJNI.setUserCurrent5V(userCurrent5V);
}
/**
* Register a callback to be run whenever the 5V rail active state changes.
*
* @param callback the callback
* @param initialNotify whether the callback should be called with the initial state
* @return the {@link CallbackStore} object associated with this callback.
*/
public static CallbackStore registerUserActive5VCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserActive5VCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelUserActive5VCallback);
}
/**
* Get the 5V rail active state.
*
* @return true if the 5V rail is active
*/
public static boolean getUserActive5V() {
return RoboRioDataJNI.getUserActive5V();
}
/**
* Set the 5V rail active state.
*
* @param userActive5V true to make rail active
*/
public static void setUserActive5V(boolean userActive5V) {
RoboRioDataJNI.setUserActive5V(userActive5V);
}
/**
* Register a callback to be run whenever the 3.3V rail voltage changes.
*
@@ -387,68 +137,6 @@ public final class RoboRioSim {
RoboRioDataJNI.setUserActive3V3(userActive3V3);
}
/**
* Register a callback to be run whenever the 6V rail number of faults changes.
*
* @param callback the callback
* @param initialNotify whether the callback should be called with the initial value
* @return the {@link CallbackStore} object associated with this callback.
*/
public static CallbackStore registerUserFaults6VCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserFaults6VCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelUserFaults6VCallback);
}
/**
* Get the 6V rail number of faults.
*
* @return number of faults
*/
public static int getUserFaults6V() {
return RoboRioDataJNI.getUserFaults6V();
}
/**
* Set the 6V rail number of faults.
*
* @param userFaults6V number of faults
*/
public static void setUserFaults6V(int userFaults6V) {
RoboRioDataJNI.setUserFaults6V(userFaults6V);
}
/**
* Register a callback to be run whenever the 5V rail number of faults changes.
*
* @param callback the callback
* @param initialNotify whether the callback should be called with the initial value
* @return the {@link CallbackStore} object associated with this callback.
*/
public static CallbackStore registerUserFaults5VCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserFaults5VCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelUserFaults5VCallback);
}
/**
* Get the 5V rail number of faults.
*
* @return number of faults
*/
public static int getUserFaults5V() {
return RoboRioDataJNI.getUserFaults5V();
}
/**
* Set the 5V rail number of faults.
*
* @param userFaults5V number of faults
*/
public static void setUserFaults5V(int userFaults5V) {
RoboRioDataJNI.setUserFaults5V(userFaults5V);
}
/**
* Register a callback to be run whenever the 3.3V rail number of faults changes.
*
@@ -609,37 +297,6 @@ public final class RoboRioSim {
RoboRioDataJNI.setComments(comments);
}
/**
* Register a callback to be run whenever the Radio led state changes.
*
* @param callback the callback
* @param initialNotify whether to call the callback with the initial state
* @return the {@link CallbackStore} object associated with this callback.
*/
public static CallbackStore registerRadioLEDStateCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerRadioLEDStateCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelRadioLEDStateCallback);
}
/**
* Get the state of the radio led.
*
* @return The state of the radio led.
*/
public static RadioLEDState getRadioLEDState() {
return RadioLEDState.fromValue(RoboRioDataJNI.getRadioLEDState());
}
/**
* Set the state of the radio led.
*
* @param state The state of the radio led.
*/
public static void setRadioLEDState(RobotController.RadioLEDState state) {
RoboRioDataJNI.setRadioLEDState(state.value);
}
/** Reset all simulation data. */
public static void resetData() {
RoboRioDataJNI.resetData();