Class StabilityModule
- java.lang.Object
-
- com.thegongoliers.output.drivetrain.GyroStabilityModule
-
- 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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
reset()
Resets the desired heading of the robot to match the gyroDriveSpeed
run(DriveSpeed currentSpeed, DriveSpeed desiredSpeed, double deltaTime)
Run the drive modulevoid
setClock(Clock clock)
void
setGyro(edu.wpi.first.wpilibj.interfaces.Gyro gyro)
void
setSettlingTime(double settlingTime)
void
setStrength(double strength)
void
setTurnThreshold(double turnThreshold)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.thegongoliers.output.drivetrain.DriveModule
overridesUser
-
-
-
-
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 headingstrength
- 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 interfaceDriveModule
- Parameters:
currentSpeed
- the current speed of the drivetraindesiredSpeed
- the desired speed of the drivetraindeltaTime
- 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
-
-