Class TurretBase

  • All Implemented Interfaces:
    Sendable, Subsystem
    Direct Known Subclasses:
    ProfiledTurret

    public abstract class TurretBase
    extends SubsystemBase
    TurretBase is the base class for all turret templates. It contains common methods, and utilities
    • Constructor Detail

      • TurretBase

        public TurretBase​(Rotation2d minDeadzoneAngle,
                          Rotation2d maxDeadzoneAngle)
        Create a TurretBase with a deadzone
        Parameters:
        minDeadzoneAngle - Robot-relative angle where the turret deadzone starts
        maxDeadzoneAngle - Robot-relative angle where the turret deadzone ends
    • Method Detail

      • periodic

        public abstract void periodic()
      • lookAt

        public abstract void lookAt​(Rotation2d angle)
        Tell the turret to look at a robot-relative angle
        Parameters:
        angle - Robot-relative angle
      • lookAt

        public void lookAt​(Translation2d point)
        Tell the turret to look at a robot-relative point in space, where (1,1) is 45 degrees
        Parameters:
        point - Robot-relative point in space
      • isAligned

        public abstract boolean isAligned()
        Get if the turret is aligned with its goal
        Returns:
        Is the turret aligned?
      • stop

        public abstract void stop()
        Stop the turret
      • findDistanceFromAToB

        protected double findDistanceFromAToB​(Rotation2d a,
                                              Rotation2d b)
        Find the fastest and safest way to get from A to B. Treat this function as "if I am at A, and I want to go to B, I must turn X degrees to the right"
        Parameters:
        a - Current position
        b - Goal position
        Returns:
        Best offset to use