Class TrackFieldTargetCommand
java.lang.Object
edu.wpi.first.wpilibj2.command.Command
frc.robot.shared.commands.AbstractSubsystemCommand<TurretSubsystem>
frc.robot.subsystems.turret.commands.TrackFieldTargetCommand
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable
Continuously aims the turret at a field-relative target position with shoot-on-the-move compensation.
This command reads the fused robot pose each loop, runs the SOTM solver to compute where the turret should aim (accounting for robot velocity and ball flight time), and drives the turret using the set-and-seek profile. It does not finish on its own and should be interrupted when tracking is no longer required.
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj2.command.Command
edu.wpi.first.wpilibj2.command.Command.InterruptionBehavior -
Field Summary
Fields inherited from class frc.robot.shared.commands.AbstractSubsystemCommand
log, subsystem -
Constructor Summary
ConstructorsConstructorDescriptionTrackFieldTargetCommand(TurretSubsystem turretSubsystem, RobotPoseSubsystem robotPoseSubsystem, Supplier<edu.wpi.first.math.geometry.Translation2d> targetFieldPositionSupplier, Supplier<Double> robotYawRateRadiansPerSecondSupplier, Supplier<edu.wpi.first.math.kinematics.ChassisSpeeds> fieldVelocitySupplier, DoubleUnaryOperator tofLookup, ShootOnTheMoveCalculator sotmCalculator) Creates a command that tracks a field-relative target position with shoot-on-the-move compensation. -
Method Summary
Modifier and TypeMethodDescriptionvoidend(boolean interrupted) Notifies the turret that tracking was interrupted so it can reset its profile state.voidexecute()Recomputes the turret target and drives the profile toward it each cycle.doubleReturns the most recent compensated distance computed by the SOTM solver.booleanReturns false so the command tracks continuously until interrupted.protected voidSeeds the turret target with the current field-relative angle on first run.Methods inherited from class frc.robot.shared.commands.AbstractSubsystemCommand
initializeMethods inherited from class edu.wpi.first.wpilibj2.command.Command
addRequirements, addRequirements, alongWith, andThen, andThen, asProxy, beforeStarting, beforeStarting, cancel, deadlineFor, deadlineWith, finallyDo, finallyDo, getInterruptionBehavior, getName, getRequirements, getSubsystem, handleInterrupt, hasRequirement, ignoringDisable, initSendable, isScheduled, onlyIf, onlyWhile, raceWith, repeatedly, runsWhenDisabled, schedule, setName, setSubsystem, unless, until, withDeadline, withInterruptBehavior, withName, withTimeout, withTimeout
-
Constructor Details
-
Method Details
-
getCompensatedDistanceMeters
public double getCompensatedDistanceMeters()Returns the most recent compensated distance computed by the SOTM solver.Use this as the distance supplier for the shooter RPM lookup during fire-ready so the flywheel speed matches the effective shot distance rather than the raw straight-line distance.
- Returns:
- compensated distance in meters from the launcher to the virtual target
-
execute
public void execute()Recomputes the turret target and drives the profile toward it each cycle.- Overrides:
executein classedu.wpi.first.wpilibj2.command.Command
-
end
public void end(boolean interrupted) Notifies the turret that tracking was interrupted so it can reset its profile state.- Overrides:
endin classedu.wpi.first.wpilibj2.command.Command- Parameters:
interrupted- true when the command was interrupted rather than finishing normally
-
isFinished
public boolean isFinished()Returns false so the command tracks continuously until interrupted.- Overrides:
isFinishedin classedu.wpi.first.wpilibj2.command.Command- Returns:
- always
false
-
onInitialize
protected void onInitialize()Seeds the turret target with the current field-relative angle on first run.- Overrides:
onInitializein classAbstractSubsystemCommand<TurretSubsystem>
-