Class PIDDrivetrain

    • Field Detail

    • Constructor Detail

      • PIDDrivetrain

        public PIDDrivetrain​(edu.wpi.first.wpilibj.SpeedController leftDrive,
                             edu.wpi.first.wpilibj.SpeedController rightDrive,
                             PID<? extends edu.wpi.first.wpilibj.pidwrappers.PIDEncoder,​java.lang.Integer> leftEncoder,
                             PID<? extends edu.wpi.first.wpilibj.pidwrappers.PIDEncoder,​java.lang.Integer> rightEncoder,
                             PID<? extends edu.wpi.first.wpilibj.interfaces.Gyro,​java.lang.Float> turningPid,
                             PID<? extends edu.wpi.first.wpilibj.interfaces.Gyro,​java.lang.Float> bearingPid)
        Create a new PIDDrivetrain instance.
        Parameters:
        leftDrive - the left side drivetrain SpeedController
        rightDrive - the right side drivetrain SpeedController
        leftEncoder - the left side drivetrain Encoder
        rightEncoder - the right side drivetrain Encoder
        turningPid - an AnglePidSrc (eg Gyro) to maintain a straight heading
        bearingPid - an AnglePidSrc to orient to a vector while stationary
      • PIDDrivetrain

        public PIDDrivetrain​(PIDDrivetrain.Builder builder)
        Create a new PIDDrivetrain instance from a Builder.
        Parameters:
        builder - the PIDDrivetrain.Builder which contains all the parameters of this PIDDrivetrain.
    • Method Detail

      • turnByDegrees

        public void turnByDegrees​(float degrees)
        Turn in place. Positive degrees may be either clockwise or anticlockwise, depending on the setup of your particular AnglePidSrc
        Parameters:
        degrees - how many degrees to turn
      • setTicksTarget

        public void setTicksTarget​(int ticks)
        Drive forward a number of encoder ticks.
        Parameters:
        ticks - how many ticks to drive
      • reset

        public void reset()
        Reset the state of the drivetrain so that it can be cleanly reused.
      • task

        public void task()
        Iteratively PID loop.
        Specified by:
        task in interface Subsystem
      • stop

        public void stop()
        Stop all movement by setting all motor target values to 0 and disabling them.
        Specified by:
        stop in class AbstractDrivetrainBase
      • waitForTarget

        public void waitForTarget()
                           throws java.lang.InterruptedException
        Suspends the calling thread until the target is reached, at which point it will be awoken again.
        Throws:
        java.lang.InterruptedException - if the calling thread is interrupted while waiting
      • getComposedComponents

        public java.util.Collection<java.lang.Object> getComposedComponents()
        Get the composed components within this one.
        Specified by:
        getComposedComponents in interface ComposedComponent<java.lang.Object>
        Returns:
        the composed components.