Package trclib.sensor
Class TrcRobotBattery
java.lang.Object
trclib.sensor.TrcRobotBattery
- Direct Known Subclasses:
FrcRobotBattery
This class monitors the robot battery level and provides methods to get the current battery voltage as well as
the lowest voltage it has ever seen during the monitoring session.
-
Constructor Summary
ConstructorsConstructorDescriptionTrcRobotBattery
(boolean voltageSupported, boolean currentSupported, boolean powerSupported) Constructor: create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionabstract double
This method returns the robot battery current.double
This method returns the highest current it has ever seen during the monitoring session.double
This method returns the highest power it has ever seen during the monitoring session.double
This method returns the highest voltage it has ever seen during the monitoring session.double
This method returns the lowest current it has ever seen during the monitoring session.double
This method returns the lowest power it has ever seen during the monitoring session.double
This method returns the lowest voltage it has ever seen during the monitoring session.abstract double
getPower()
This method returns the robot battery power.double
This method returns the total energy consumed since the task was enabled.abstract double
This method returns the robot battery voltage.void
setEnabled
(boolean enabled) This method enables/disables the battery monitoring task.toString()
This method returns the state of the battery in a string.
-
Constructor Details
-
TrcRobotBattery
public TrcRobotBattery(boolean voltageSupported, boolean currentSupported, boolean powerSupported) Constructor: create an instance of the object.- Parameters:
voltageSupported
- specifies true if getVoltage is supported, false otherwise.currentSupported
- specifies true if getCurrent is supported, false otherwise.powerSupported
- specifies true if getPower is supported, false otherwise.
-
-
Method Details
-
getVoltage
public abstract double getVoltage()This method returns the robot battery voltage.- Returns:
- robot battery voltage in volts.
-
getCurrent
public abstract double getCurrent()This method returns the robot battery current.- Returns:
- robot battery current in amps.
-
getPower
public abstract double getPower()This method returns the robot battery power.- Returns:
- robot battery power in watts.
-
toString
This method returns the state of the battery in a string. -
setEnabled
public void setEnabled(boolean enabled) This method enables/disables the battery monitoring task. When the task is enabled, it also clears the lowest voltage.- Parameters:
enabled
- specifies true to enable the task, false to disable.
-
getLowestVoltage
public double getLowestVoltage()This method returns the lowest voltage it has ever seen during the monitoring session.- Returns:
- lowest battery voltage.
- Throws:
UnsupportedOperationException
- if voltage is not supported by the system.
-
getHighestVoltage
public double getHighestVoltage()This method returns the highest voltage it has ever seen during the monitoring session.- Returns:
- highest battery voltage.
- Throws:
UnsupportedOperationException
- if voltage is not supported by the system.
-
getLowestCurrent
public double getLowestCurrent()This method returns the lowest current it has ever seen during the monitoring session.- Returns:
- lowest battery current.
- Throws:
UnsupportedOperationException
- if current is not supported by the system.
-
getHighestCurrent
public double getHighestCurrent()This method returns the highest current it has ever seen during the monitoring session.- Returns:
- highest battery current.
- Throws:
UnsupportedOperationException
- if current is not supported by the system.
-
getLowestPower
public double getLowestPower()This method returns the lowest power it has ever seen during the monitoring session.- Returns:
- lowest battery power.
- Throws:
UnsupportedOperationException
- if power is not supported by the system.
-
getHighestPower
public double getHighestPower()This method returns the highest power it has ever seen during the monitoring session.- Returns:
- highest battery power.
- Throws:
UnsupportedOperationException
- if power is not supported by the system.
-
getTotalEnergy
public double getTotalEnergy()This method returns the total energy consumed since the task was enabled.- Returns:
- total energy consumed in WH (Watt-Hour).
-