Package edu.wpi.first.wpilibj.simulation
Class BatterySim
java.lang.Object
edu.wpi.first.wpilibj.simulation.BatterySim
public final class BatterySim extends Object
A utility class to simulate the robot battery.
-
Method Summary
Modifier and Type Method Description static doublecalculateDefaultBatteryLoadedVoltage(double... currents)Calculate the loaded battery voltage.static doublecalculateLoadedBatteryVoltage(double nominalVoltage, double resistanceOhms, double... currents)Calculate the loaded battery voltage.
-
Method Details
-
calculateLoadedBatteryVoltage
public static double calculateLoadedBatteryVoltage(double nominalVoltage, double resistanceOhms, double... currents)Calculate the loaded battery voltage. Use this withRoboRioSim.setVInVoltage(double)to set the simulated battery voltage, which can then be retrieved with theRobotController.getBatteryVoltage()method.- Parameters:
nominalVoltage- The nominal battery voltage. Usually 12v.resistanceOhms- The forward resistance of the battery. Most batteries are at or below 20 milliohms.currents- The currents drawn from the battery.- Returns:
- The battery's voltage under load.
-
calculateDefaultBatteryLoadedVoltage
Calculate the loaded battery voltage. Use this withRoboRioSim.setVInVoltage(double)to set the simulated battery voltage, which can then be retrieved with theRobotController.getBatteryVoltage()method. This function assumes a nominal voltage of 12v and a resistance of 20 milliohms (0.020 ohms)- Parameters:
currents- The currents drawn from the battery.- Returns:
- The battery's voltage under load.
-