Class PathFollowerModule
- java.lang.Object
-
- com.thegongoliers.output.drivetrain.PathFollowerModule
-
- All Implemented Interfaces:
DriveModule
public class PathFollowerModule extends java.lang.Object implements DriveModule
A drivetrain module which will follow a path when activated
-
-
Constructor Summary
Constructors Constructor Description PathFollowerModule(edu.wpi.first.wpilibj.interfaces.Gyro gyro, java.util.List<edu.wpi.first.wpilibj.Encoder> encoders, double forwardStrength, double turnStrength)PathFollowerModule(edu.wpi.first.wpilibj.interfaces.Gyro gyro, java.util.List<edu.wpi.first.wpilibj.Encoder> encoders, com.kylecorry.pid.PID forwardPID, com.kylecorry.pid.PID turnPID)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisFollowingPath()Determines if it is following a pathbooleanoverridesUser()Determines if the module should override the user's inputDriveSpeedrun(DriveSpeed currentSpeed, DriveSpeed desiredSpeed, double deltaTime)Run the drive modulevoidsetEncoders(java.util.List<edu.wpi.first.wpilibj.Encoder> encoders)voidsetForwardPID(com.kylecorry.pid.PID forwardPID)voidsetForwardTolerance(double tolerance)voidsetGyro(edu.wpi.first.wpilibj.interfaces.Gyro gyro)voidsetTurnPID(com.kylecorry.pid.PID turnPID)voidsetTurnTolerance(double tolerance)voidstartFollowingPath(SimplePath path)Start following a path (note, drivetrain's tank or arcade methods must be called repeatedly with any value)voidstopFollowingPath()Stops following a path - the drivetrain's arcade or tank method must be called to take effect!
-
-
-
Constructor Detail
-
PathFollowerModule
public PathFollowerModule(edu.wpi.first.wpilibj.interfaces.Gyro gyro, java.util.List<edu.wpi.first.wpilibj.Encoder> encoders, double forwardStrength, double turnStrength)
-
PathFollowerModule
public PathFollowerModule(edu.wpi.first.wpilibj.interfaces.Gyro gyro, java.util.List<edu.wpi.first.wpilibj.Encoder> encoders, com.kylecorry.pid.PID forwardPID, com.kylecorry.pid.PID turnPID)
-
-
Method Detail
-
run
public DriveSpeed run(DriveSpeed currentSpeed, DriveSpeed desiredSpeed, double deltaTime)
Description copied from interface:DriveModuleRun the drive module- Specified by:
runin 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
-
overridesUser
public boolean overridesUser()
Description copied from interface:DriveModuleDetermines if the module should override the user's input- Specified by:
overridesUserin interfaceDriveModule- Returns:
- true if it overrides the user's input
-
startFollowingPath
public void startFollowingPath(SimplePath path)
Start following a path (note, drivetrain's tank or arcade methods must be called repeatedly with any value)- Parameters:
path- The path to follow
-
isFollowingPath
public boolean isFollowingPath()
Determines if it is following a path
-
stopFollowingPath
public void stopFollowingPath()
Stops following a path - the drivetrain's arcade or tank method must be called to take effect!
-
setEncoders
public void setEncoders(java.util.List<edu.wpi.first.wpilibj.Encoder> encoders)
-
setGyro
public void setGyro(edu.wpi.first.wpilibj.interfaces.Gyro gyro)
-
setForwardTolerance
public void setForwardTolerance(double tolerance)
-
setTurnTolerance
public void setTurnTolerance(double tolerance)
-
setForwardPID
public void setForwardPID(com.kylecorry.pid.PID forwardPID)
-
setTurnPID
public void setTurnPID(com.kylecorry.pid.PID turnPID)
-
-