Class MoveFieldManualWithHeadingCommand
java.lang.Object
edu.wpi.first.wpilibj2.command.Command
frc.robot.shared.commands.AbstractSubsystemCommand<DriveBaseSubsystem>
frc.robot.subsystems.drivebase.commands.MoveFieldManualWithHeadingCommand
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable
Drives the robot field-relative using driver-supplied translation while locking the heading to a PID-controlled target angle. The driver retains
full left-stick control over forward and strafe, but the rotation axis is overridden by the heading PID controller to drive toward the target.
This command runs until interrupted (designed for whileTrue bindings). When the button is released, the default manual drive command
resumes and the driver regains manual omega control.
-
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
ConstructorsConstructorDescriptionMoveFieldManualWithHeadingCommand(DriveBaseSubsystem driveBaseSubsystem, DoubleSupplier forwardMetersPerSecondSupplier, DoubleSupplier leftMetersPerSecondSupplier, DoubleSupplier targetHeadingRadiansSupplier) Creates a heading-locked manual drive command. -
Method Summary
Modifier and TypeMethodDescriptionvoidend(boolean interrupted) Stops and locks the drivebase once the heading lock ends or is interrupted.voidexecute()Drives field-relative with PID-controlled heading each cycle.protected voidResets the heading PID controller so stale integral error does not produce a large initial output.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, isFinished, isScheduled, onlyIf, onlyWhile, raceWith, repeatedly, runsWhenDisabled, schedule, setName, setSubsystem, unless, until, withDeadline, withInterruptBehavior, withName, withTimeout, withTimeout
-
Constructor Details
-
MoveFieldManualWithHeadingCommand
public MoveFieldManualWithHeadingCommand(DriveBaseSubsystem driveBaseSubsystem, DoubleSupplier forwardMetersPerSecondSupplier, DoubleSupplier leftMetersPerSecondSupplier, DoubleSupplier targetHeadingRadiansSupplier) Creates a heading-locked manual drive command.- Parameters:
driveBaseSubsystem- drive base subsystem to commandforwardMetersPerSecondSupplier- supplier providing forward (positive X) velocity in meters per secondleftMetersPerSecondSupplier- supplier providing leftward (positive Y) velocity in meters per secondtargetHeadingRadiansSupplier- supplier providing the desired heading in radians (counter-clockwise positive)
-
-
Method Details
-
execute
public void execute()Drives field-relative with PID-controlled heading each cycle.- Overrides:
executein classedu.wpi.first.wpilibj2.command.Command
-
end
public void end(boolean interrupted) Stops and locks the drivebase once the heading lock ends or is interrupted.- Overrides:
endin classedu.wpi.first.wpilibj2.command.Command- Parameters:
interrupted- true when the command was cancelled before normal completion
-
onInitialize
protected void onInitialize()Resets the heading PID controller so stale integral error does not produce a large initial output.- Overrides:
onInitializein classAbstractSubsystemCommand<DriveBaseSubsystem>
-