Class TurretSubsystemCommandFactory
java.lang.Object
frc.robot.shared.commands.AbstractSubsystemCommandFactory<TSubsystem>
frc.robot.shared.commands.AbstractSetAndSeekCommandFactory<TurretSubsystem>
frc.robot.subsystems.turret.commands.TurretSubsystemCommandFactory
public class TurretSubsystemCommandFactory
extends AbstractSetAndSeekCommandFactory<TurretSubsystem>
Generates commands that operate on the turret subsystem so RobotContainer can stay focused on wiring.
-
Field Summary
Fields inherited from class frc.robot.shared.commands.AbstractSubsystemCommandFactory
subsystem -
Constructor Summary
ConstructorsConstructorDescriptionTurretSubsystemCommandFactory(TurretSubsystem subsystem) Creates a factory for commands that share the given turret subsystem instance. -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.wpilibj2.command.CommandBuilds a non-finishing command that profiles the turret to 0 degrees and then holds it there indefinitely.createMoveToAngleCommand(double targetDegrees) Builds a profiled move command that drives the turret to a fixed angle.createMoveToAngleCommand(Supplier<Double> targetDegreesSupplier) Builds a profiled move command that reads its target angle from a supplier.doubleReturns the most recent SOTM-compensated distance from the active tracking command.edu.wpi.first.wpilibj2.command.CommandsetDefaultTrackFieldTargetCommand(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.Methods inherited from class frc.robot.shared.commands.AbstractSetAndSeekCommandFactory
createResetEncoderCommand, createSysIdDynamicCommand, createSysIdDynamicCommand, createSysIdDynamicCommandWithDefaultTimeout, createSysIdFullSweepCommand, createSysIdFullSweepCommand, createSysIdQuasistaticCommand, createSysIdQuasistaticCommand, createSysIdQuasistaticCommandWithDefaultTimeoutMethods inherited from class frc.robot.shared.commands.AbstractSubsystemCommandFactory
getSubsystem
-
Constructor Details
-
TurretSubsystemCommandFactory
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
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
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 estimatetargetFieldPositionSupplier- 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 compensationtofLookup- 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
toggleOnTrueso 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
-