Modify Turning PID

- Uses a modified Velocity PID to keep robot still while rotating
- Could also use a Position PID to keep robot still but should be looked into further
This commit is contained in:
Keenan D. Buckley
2020-01-30 21:46:56 -07:00
parent ae5fc4cb00
commit 5cb458082a
2 changed files with 7 additions and 5 deletions
@@ -329,12 +329,13 @@ public class Drive extends SubsystemBase {
talon.set(TalonFXControlMode.MotionMagic, targetPos);
}
/**
* Runs a Turning PID to rotate a to a target angle
* @param targetAngle target angle in degrees
*/
public void runTurningPID(double targetAngle){
//m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_VELOCITY, DriveConstants.PID_PRIMARY);
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_TURNING, DriveConstants.PID_TURN);
m_rightFrontMotor.set(TalonFXControlMode.Velocity, 0, DemandType.AuxPID, targetAngle);
//m_leftFrontMotor.follow(m_rightFrontMotor, FollowerType.AuxOutput1);
//m_rightFrontMotor.set(DemandType.AuxPID, 0);
double targetGyro = (targetAngle/360)*DriveConstants.TICKS_PER_GYRO_REV;
runVelocityPID(0, targetGyro);
}
public double getGyroYaw() {