Class SparkMaxPIDWrapper

java.lang.Object
frc.team_8840_lib.controllers.specifics.SparkMaxPIDWrapper

public class SparkMaxPIDWrapper extends Object
Another fix for potential issues with REV's api. This is a wrapper for the onboard PID controller.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SparkMaxPIDWrapper(com.revrobotics.CANSparkMax sparkMax)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    calculateFF(double setpoint)
     
    void
     
    void
    setFeedforward(double kS, double kV, double kA)
    Sets the kS, kV, and kA of the feedforward
    void
    setPID(double kP, double kI, double kD, double kFF, double kIZone)
    Sets the kP, kI, kD, kFF, and kIZone of the onboard PID controller
    void
    setPIDProfile(double kP, double kI, double kD, edu.wpi.first.math.trajectory.TrapezoidProfile.Constraints constraints)
    Sets the kP, kI, kD, and TrapezoidProfile.Constraints of the local PID controller
    void
    setReference(double setpoint, com.revrobotics.CANSparkBase.ControlType controlType)
    Sets the reference of the PID controller.
    void
    setReference(double setpoint, com.revrobotics.CANSparkBase.ControlType controlType, int pidSlot, double arbFeedforward)
    Sets the reference of the PID controller.
    void
    setUseManualPID(boolean useManualPID)
    Sets whether to use the onboard PID controller or the local PID controller
    void
    setWrapAround(double min, double max)
    Sets the max and min output of the PID controller

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SparkMaxPIDWrapper

      public SparkMaxPIDWrapper(com.revrobotics.CANSparkMax sparkMax)
  • Method Details

    • setFeedbackDevice

      public void setFeedbackDevice(SparkMaxEncoderWrapper wrapper)
    • setPID

      public void setPID(double kP, double kI, double kD, double kFF, double kIZone)
      Sets the kP, kI, kD, kFF, and kIZone of the onboard PID controller
      Parameters:
      kP - The proportional gain
      kI - The integral gain
      kD - The derivative gain
      kFF - The feedforward gain
      kIZone - The integral zone
    • setPIDProfile

      public void setPIDProfile(double kP, double kI, double kD, edu.wpi.first.math.trajectory.TrapezoidProfile.Constraints constraints)
      Sets the kP, kI, kD, and TrapezoidProfile.Constraints of the local PID controller
      Parameters:
      kP - The proportional gain
      kI - The integral gain
      kD - The derivative gain
      constraints - The constraints to use
    • setWrapAround

      public void setWrapAround(double min, double max)
      Sets the max and min output of the PID controller
      Parameters:
      min - The minimum output
      max - The maximum output
    • setFeedforward

      public void setFeedforward(double kS, double kV, double kA)
      Sets the kS, kV, and kA of the feedforward
      Parameters:
      kS - The static gain
      kV - The velocity gain
      kA - The acceleration gain
    • setUseManualPID

      public void setUseManualPID(boolean useManualPID)
      Sets whether to use the onboard PID controller or the local PID controller
      Parameters:
      useManualPID - True to use the local PID controller, false to use the onboard PID controller
    • setReference

      public void setReference(double setpoint, com.revrobotics.CANSparkBase.ControlType controlType)
      Sets the reference of the PID controller.
      Parameters:
      setpoint - The setpoint to set
      controlType - The control type to use
    • setReference

      public void setReference(double setpoint, com.revrobotics.CANSparkBase.ControlType controlType, int pidSlot, double arbFeedforward)
      Sets the reference of the PID controller.
      Parameters:
      setpoint - The setpoint to set
      controlType - The control type to use
      pidSlot - The PID slot to use
      arbFeedforward - The arbitrary feedforward to use
    • calculateFF

      public double calculateFF(double setpoint)