Class VoltageControlModule

  • All Implemented Interfaces:
    DriveModule

    public class VoltageControlModule
    extends java.lang.Object
    implements DriveModule
    Ensures that the drivetrain runs at a consistent voltage, compensating for battery voltage fluctuations
    • Constructor Detail

      • VoltageControlModule

        public VoltageControlModule​(double maxVoltage,
                                    VoltageSensor batteryVoltage)
        Parameters:
        maxVoltage - The maximum voltage of the drivetrain motors when the input speed is 1 (in volts)
        batteryVoltage - The battery voltage sensor
      • VoltageControlModule

        public VoltageControlModule​(double maxVoltage)
        Parameters:
        maxVoltage - The maximum voltage of the drivetrain motors when the input speed is 1 (in volts)
    • Method Detail

      • run

        public DriveSpeed run​(DriveSpeed currentSpeed,
                              DriveSpeed desiredSpeed,
                              double deltaTime)
        Description copied from interface: DriveModule
        Run the drive module
        Specified by:
        run in interface DriveModule
        Parameters:
        currentSpeed - the current speed of the drivetrain
        desiredSpeed - the desired speed of the drivetrain
        deltaTime - the delta time since the last call in seconds
        Returns:
        the speed the drivetrain should set
      • setMaxVoltage

        public void setMaxVoltage​(double maxVoltage)