Class TurretSubsystemCommandFactory


public class TurretSubsystemCommandFactory extends AbstractSetAndSeekCommandFactory<TurretSubsystem>
Generates commands that operate on the turret subsystem so RobotContainer can stay focused on wiring.
  • Constructor Details

    • TurretSubsystemCommandFactory

      public TurretSubsystemCommandFactory(TurretSubsystem subsystem)
      Creates a factory for commands that share the given turret subsystem instance.
      Parameters:
      subsystem - turret subsystem instance that commands created by this factory will control
  • Method Details

    • createMoveToAngleCommand

      public MoveTurretToAngleCommand createMoveToAngleCommand(Supplier<Double> targetDegreesSupplier)
      Builds a profiled move command that reads its target angle from a supplier.
      Parameters:
      targetDegreesSupplier - supplier providing the desired turret angle in degrees
      Returns:
      command that drives the turret toward the supplied target
    • createMoveToAngleCommand

      public MoveTurretToAngleCommand createMoveToAngleCommand(double targetDegrees)
      Builds a profiled move command that drives the turret to a fixed angle.
      Parameters:
      targetDegrees - desired turret angle in degrees
      Returns:
      command that drives the turret to the fixed target
    • setDefaultTrackFieldTargetCommand

      public edu.wpi.first.wpilibj2.command.Command setDefaultTrackFieldTargetCommand(RobotPoseSubsystem robotPoseSubsystem, Supplier<edu.wpi.first.math.geometry.Translation2d> targetFieldPositionSupplier, Supplier<Double> robotYawRateRadiansPerSecondSupplier, Supplier<edu.wpi.first.math.kinematics.ChassisSpeeds> fieldVelocitySupplier, DoubleUnaryOperator tofLookup)
      Builds and sets the default turret tracking command with shoot-on-the-move compensation.
      Parameters:
      robotPoseSubsystem - robot pose subsystem providing the fused pose estimate
      targetFieldPositionSupplier - supplier of the target position in field coordinates (meters)
      robotYawRateRadiansPerSecondSupplier - supplier of the robot's yaw rate in radians per second (positive is counter-clockwise)
      fieldVelocitySupplier - supplier of the robot's field-relative velocity for SOTM compensation
      tofLookup - function returning estimated time of flight given a distance in meters
      Returns:
      command that is also set as the turret default
    • getCompensatedDistanceMeters

      public double getCompensatedDistanceMeters()
      Returns the most recent SOTM-compensated distance from the active tracking command.

      Use this as the distance supplier for shooter RPM lookup so the flywheel speed matches the effective distance after accounting for robot motion. Falls back to 0.0 if no tracking command has been created yet.

      Returns:
      compensated distance in meters
    • createLockToZeroCommand

      public edu.wpi.first.wpilibj2.command.Command createLockToZeroCommand()
      Builds a non-finishing command that profiles the turret to 0 degrees and then holds it there indefinitely.

      Intended for use with toggleOnTrue so the operator can lock the turret when vision tracking is inaccurate or offline, then press the same button again to resume the default tracking command.

      Returns:
      non-finishing command that locks the turret at 0 degrees until cancelled