Changed Tank Drive Velocity Method

This commit is contained in:
Aarav Shah
2020-02-13 17:46:15 -07:00
parent a5bdb28d37
commit 0cf6f8f370
2 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ public final class Constants {
/* Trajectory Constants */
public static final double kMaxSpeedMetersPerSecond = 3;
public static final double kMaxAccelerationMetersPerSecondSquared = 3;
public static final double kTrackwidthMeters = 0.69; ///TODO: SET THIS SOON!
public static final double kTrackwidthMeters = 0.648; ///TODO: SET THIS SOON!
public static final DifferentialDriveKinematics kDriveKinematics = new DifferentialDriveKinematics(kTrackwidthMeters);
/* Remote Sensors */
@@ -372,7 +372,7 @@ public class Drive extends SubsystemBase {
* @param rightSpeed the commanded right output
*/
public void tankDriveVelocity(double leftSpeed, double rightSpeed) {
DifferentialDriveWheelSpeeds wheelSpeeds = new DifferentialDriveWheelSpeeds(leftSpeed, rightSpeed);
/*DifferentialDriveWheelSpeeds wheelSpeeds = new DifferentialDriveWheelSpeeds(leftSpeed, rightSpeed);
ChassisSpeeds chassisSpeeds = DriveConstants.kDriveKinematics.toChassisSpeeds(wheelSpeeds);
double moveVelMPS = chassisSpeeds.vxMetersPerSecond;
double angleVelRad = chassisSpeeds.omegaRadiansPerSecond;
@@ -382,10 +382,14 @@ public class Drive extends SubsystemBase {
m_kinematicsTargetAngle = MathUtil.clamp( m_kinematicsTargetAngle,
m_currentAngleYaw-(360),
m_currentAngleYaw+(360));
double targetGyro = (m_kinematicsTargetAngle / 360) * DriveConstants.TICKS_PER_GYRO_REV;
double moveVel = inchesToMeters(metersToInches(moveVelMPS))/DriveConstants.SECONDS_TO_TICK_TIME;
double targetGyro = (m_kinematicsTargetAngle / 360) * DriveConstants.TICKS_PER_GYRO_REV;*/
double moveVelLeft = inchesToMeters(metersToInches(leftSpeed))/DriveConstants.SECONDS_TO_TICK_TIME;
double moveVelRight = inchesToMeters(metersToInches(rightSpeed))/DriveConstants.SECONDS_TO_TICK_TIME;
runDriveStraightVelocityPID(moveVel, targetGyro);
//runDriveStraightVelocityPID(moveVel, targetGyro);
m_rightFrontMotor.set(TalonFXControlMode.Velocity, moveVelRight);
m_leftFrontMotor.set(TalonFXControlMode.Velocity, moveVelLeft);
}
/**