Class SparkMaxPIDWrapper
java.lang.Object
frc.team_8840_lib.controllers.specifics.SparkMaxPIDWrapper
Another fix for potential issues with REV's api. This is a wrapper for the onboard PID controller.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublecalculateFF(double setpoint) voidsetFeedbackDevice(SparkMaxEncoderWrapper wrapper) voidsetFeedforward(double kS, double kV, double kA) Sets the kS, kV, and kA of the feedforwardvoidsetPID(double kP, double kI, double kD, double kFF, double kIZone) Sets the kP, kI, kD, kFF, and kIZone of the onboard PID controllervoidsetPIDProfile(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 controllervoidsetReference(double setpoint, com.revrobotics.CANSparkBase.ControlType controlType) Sets the reference of the PID controller.voidsetReference(double setpoint, com.revrobotics.CANSparkBase.ControlType controlType, int pidSlot, double arbFeedforward) Sets the reference of the PID controller.voidsetUseManualPID(boolean useManualPID) Sets whether to use the onboard PID controller or the local PID controllervoidsetWrapAround(double min, double max) Sets the max and min output of the PID controller
-
Constructor Details
-
SparkMaxPIDWrapper
public SparkMaxPIDWrapper(com.revrobotics.CANSparkMax sparkMax)
-
-
Method Details
-
setFeedbackDevice
-
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 gainkI- The integral gainkD- The derivative gainkFF- The feedforward gainkIZone- 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 gainkI- The integral gainkD- The derivative gainconstraints- 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 outputmax- 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 gainkV- The velocity gainkA- 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 setcontrolType- 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 setcontrolType- The control type to usepidSlot- The PID slot to usearbFeedforward- The arbitrary feedforward to use
-
calculateFF
public double calculateFF(double setpoint)
-