Class HarvesterSubsystem

All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable, edu.wpi.first.wpilibj2.command.Subsystem

public class HarvesterSubsystem extends AbstractSetAndSeekSubsystem<HarvesterSubsystemConfig>
Harvester subsystem that swings the intake arm between a stowed (upright) position and a deployed (lowered) position using a profiled motor. The superclass handles motion profiling, limits, and logging while this class adds gravity-compensating arm feedforward and exposes convenience methods for the two named positions.

A trapezoidal motion profile is a control technique that limits both the velocity and acceleration of the motor, producing smooth, predictable movements instead of abrupt starts and stops.

Because the arm swings against gravity, this subsystem replaces the parent's simple feedforward with an ArmFeedforward. The arm feedforward adds a gravity term (kG) that is multiplied by the cosine of the arm's angle from horizontal, automatically varying the compensation voltage as the arm moves.

  • Constructor Details

    • HarvesterSubsystem

      public HarvesterSubsystem(HarvesterSubsystemConfig config)
      Builds the harvester subsystem with a single profiled motor for arm positioning.
      Parameters:
      config - harvester configuration bundle loaded from JSON; angles are expressed in degrees
  • Method Details

    • deployArm

      public void deployArm()
      Commands the arm to deploy to the lowered Fuel-collection position.

      The motion profile ramps the arm smoothly from its current position to the configured deployed angle. The arm will stay at the target until a new target is set or the command is interrupted.

    • stowArm

      public void stowArm()
      Commands the arm to stow in the upright match-start position.

      The motion profile ramps the arm smoothly from its current position to the configured stowed angle. This is the default position at the start of a match and keeps the intake inside the robot perimeter.

    • sweepArm

      public void sweepArm()
      Commands the arm to the sweep position to push Fuel from the back of the hopper toward the shooting array.

      The motion profile ramps the arm smoothly from its current position to the configured sweep angle. This is used during extended firing sequences when the front of the hopper is empty and remaining Fuel needs to be pushed forward.

    • isInDeployedMode

      public boolean isInDeployedMode()
      Reports whether the arm's current goal is the deployed position. The hold command uses this to decide whether to monitor for drift or idle passively.
      Returns:
      true when the profile goal is within one degree of the configured deployed angle
    • calculateFeedforward

      protected double calculateFeedforward(double previousSetpointVelocity, edu.wpi.first.math.trajectory.TrapezoidProfile.State currentSetpoint)
      Computes the arm feedforward voltage including gravity compensation for the current profile step.

      The arm angle from horizontal is computed by adding the configured horizontal offset to the current setpoint position. The gravity term (kG × cos(angle)) varies automatically as the arm moves, producing more voltage when the arm is near horizontal and less when it is vertical.

      Overrides:
      calculateFeedforward in class AbstractSetAndSeekSubsystem<HarvesterSubsystemConfig>
      Parameters:
      previousSetpointVelocity - velocity setpoint from the previous cycle in radians per second
      currentSetpoint - the setpoint state the profile wants us to follow this cycle
      Returns:
      feedforward voltage in volts, including gravity compensation
    • refreshFeedforward

      protected void refreshFeedforward()
      Re-reads arm feedforward gains from config so live tuning updates affect voltage estimates immediately.
      Overrides:
      refreshFeedforward in class AbstractMotorSubsystem<HarvesterSubsystemConfig>