Class 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
      boolean isFollowingPath()
      Determines if it is following a path
      boolean overridesUser()
      Determines if the module should override the user's input
      DriveSpeed run​(DriveSpeed currentSpeed, DriveSpeed desiredSpeed, double deltaTime)
      Run the drive module
      void setEncoders​(java.util.List<edu.wpi.first.wpilibj.Encoder> encoders)  
      void setForwardPID​(com.kylecorry.pid.PID forwardPID)  
      void setForwardTolerance​(double tolerance)  
      void setGyro​(edu.wpi.first.wpilibj.interfaces.Gyro gyro)  
      void setTurnPID​(com.kylecorry.pid.PID turnPID)  
      void setTurnTolerance​(double tolerance)  
      void startFollowingPath​(SimplePath path)
      Start following a path (note, drivetrain's tank or arcade methods must be called repeatedly with any value)
      void stopFollowingPath()
      Stops following a path - the drivetrain's arcade or tank method must be called to take effect!
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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: 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
      • overridesUser

        public boolean overridesUser()
        Description copied from interface: DriveModule
        Determines if the module should override the user's input
        Specified by:
        overridesUser in interface DriveModule
        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)