Class StabilityModule

  • All Implemented Interfaces:
    DriveModule

    public class StabilityModule
    extends java.lang.Object
    implements DriveModule
    A drivetrain module which will stabilize the drivetrain (rotation-wise) while attempting to drive straight
    • Constructor Summary

      Constructors 
      Constructor Description
      StabilityModule​(edu.wpi.first.wpilibj.interfaces.Gyro gyro, double strength, double settlingTime)
      Default constructor
    • Constructor Detail

      • StabilityModule

        public StabilityModule​(edu.wpi.first.wpilibj.interfaces.Gyro gyro,
                               double strength,
                               double settlingTime)
        Default constructor
        Parameters:
        gyro - the gyroscope which determines the robot's heading
        strength - the stabilizing strength (higher values may become unstable, recommended ~0.02. Values must be greater than or equal to 0)
        settlingTime - the amount of time to allow the drivetrain to settle after turn inputs stop before applying turn corrections
    • 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
      • setClock

        public void setClock​(Clock clock)
      • setGyro

        public void setGyro​(edu.wpi.first.wpilibj.interfaces.Gyro gyro)
      • setSettlingTime

        public void setSettlingTime​(double settlingTime)
      • setTurnThreshold

        public void setTurnThreshold​(double turnThreshold)
      • setStrength

        public void setStrength​(double strength)
      • reset

        public void reset()
        Resets the desired heading of the robot to match the gyro