Reconfigure motor sensor between auto and teleop

This commit is contained in:
Aarav Shah
2020-02-13 17:34:59 -07:00
parent a280554054
commit a5bdb28d37
3 changed files with 19 additions and 2 deletions
@@ -162,8 +162,7 @@ public class Drive extends SubsystemBase {
m_rightFrontMotor.configSensorTerm(SensorTerm.Diff0, FeedbackDevice.IntegratedSensor, DriveConstants.DRIVE_TIMEOUT_MS);
/* Configure Sum [Sum of both QuadEncoders] to be used for Primary PID Index */
m_rightFrontMotor.configSelectedFeedbackSensor( FeedbackDevice.SensorDifference, DriveConstants.PID_PRIMARY,
DriveConstants.DRIVE_TIMEOUT_MS);
configMotorSensor(FeedbackDevice.SensorDifference);
/* Don't scale the Feedback Sensor (use 1 for 1:1 ratio) */
m_rightFrontMotor.configSelectedFeedbackCoefficient( 1, // Coefficient
@@ -389,6 +388,15 @@ public class Drive extends SubsystemBase {
runDriveStraightVelocityPID(moveVel, targetGyro);
}
/**
* Selects the feedback device for the motors.
* @param feedbackDevice The feedback device to set it to, usually SensorDifference or
*/
public void configMotorSensor(FeedbackDevice type) {
m_rightFrontMotor.configSelectedFeedbackSensor( type, DriveConstants.PID_PRIMARY,
DriveConstants.DRIVE_TIMEOUT_MS);
}
/**
* Returns the current yaw of the pigeon
*/