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

public class MoveFieldManualWithHeadingCommand extends AbstractSubsystemCommand<DriveBaseSubsystem>
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

    Constructors
    Constructor
    Description
    MoveFieldManualWithHeadingCommand(DriveBaseSubsystem driveBaseSubsystem, DoubleSupplier forwardMetersPerSecondSupplier, DoubleSupplier leftMetersPerSecondSupplier, DoubleSupplier targetHeadingRadiansSupplier)
    Creates a heading-locked manual drive command.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    end(boolean interrupted)
    Stops and locks the drivebase once the heading lock ends or is interrupted.
    void
    Drives field-relative with PID-controlled heading each cycle.
    protected void
    Resets the heading PID controller so stale integral error does not produce a large initial output.

    Methods inherited from class frc.robot.shared.commands.AbstractSubsystemCommand

    initialize

    Methods 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 command
      forwardMetersPerSecondSupplier - supplier providing forward (positive X) velocity in meters per second
      leftMetersPerSecondSupplier - supplier providing leftward (positive Y) velocity in meters per second
      targetHeadingRadiansSupplier - 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:
      execute in class edu.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:
      end in class edu.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:
      onInitialize in class AbstractSubsystemCommand<DriveBaseSubsystem>