made driveTrain.java but no sensors

This commit is contained in:
2024-12-17 14:51:24 -05:00
parent 3f6a7c38c8
commit 25e22842ff
4 changed files with 583 additions and 0 deletions

View File

@@ -20,6 +20,25 @@ public class Drivetrain extends SubsystemBase{
private Drivetrain() {
leftFront = new CANSparkMax(DrivetrainConstants.kLeftFrontID, MotorType.kBrushless);
rightFront = new CANSparkMax(DrivetrainConstants.kRightFrontID, MotorType.kBrushless);
leftRear = new CANSparkMax(DrivetrainConstants.kLeftRearID, MotorType.kBrushless);
rightRear = new CANSparkMax(DrivetrainConstants.kRightRearID, MotorType.kBrushless);
((CANSparkMax)leftRear).follow((CANSparkMax)leftFront);
((CANSparkMax)rightRear).follow((CANSparkMax)rightFront);
rightFront.setInverted(true);
drive = new DifferentialDrive(leftFront, rightFront);
}
public Command driveArcade(DoubleSupplier xSpeed, DoubleSupplier zRotation) {
return run (() -> {
drive.arcadeDrive(xSpeed.getAsDouble(), zRotation.getAsDouble());
});
}
public Command driveTank(DoubleSupplier leftSpeed, DoubleSupplier rightSpeed) {
return run(() -> {
drive.tankDrive(leftSpeed.getAsDouble(), rightSpeed.getAsDouble());
});
}
}