2023-10-17 19:55:17 -04:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
|
|
|
|
package frc.robot.subsystems;
|
|
|
|
|
2023-10-18 20:00:02 -04:00
|
|
|
import java.io.File;
|
2023-10-24 19:47:28 -04:00
|
|
|
import java.io.IOException;
|
2023-10-17 19:55:17 -04:00
|
|
|
|
2023-10-24 19:47:28 -04:00
|
|
|
import edu.wpi.first.math.geometry.Translation2d;
|
2023-10-18 20:00:02 -04:00
|
|
|
import edu.wpi.first.wpilibj.Filesystem;
|
|
|
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
2023-10-24 19:47:28 -04:00
|
|
|
import swervelib.SwerveDrive;
|
|
|
|
import swervelib.parser.SwerveParser;
|
|
|
|
|
2023-10-17 19:55:17 -04:00
|
|
|
public class Drive extends SubsystemBase {
|
2023-10-24 19:47:28 -04:00
|
|
|
SwerveDrive swerveDrive;
|
2023-10-18 20:00:02 -04:00
|
|
|
File swerveJsonDirectory = new File(Filesystem.getDeployDirectory(),"swerve");
|
2023-10-24 19:47:28 -04:00
|
|
|
|
|
|
|
public void drive(double x, double y, double zRotation){
|
|
|
|
swerveDrive.drive(new Translation2d(x, y), zRotation, true, true);
|
|
|
|
}
|
2023-10-18 20:00:02 -04:00
|
|
|
|
2023-10-24 19:47:28 -04:00
|
|
|
|
2023-10-17 19:55:17 -04:00
|
|
|
/** Creates a new Drive. */
|
2023-10-24 19:47:28 -04:00
|
|
|
public Drive() {
|
|
|
|
try {
|
|
|
|
this.swerveDrive = new SwerveParser(swerveJsonDirectory).createSwerveDrive();
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
2023-10-17 19:55:17 -04:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void periodic() {
|
|
|
|
// This method will be called once per scheduler run
|
2023-10-18 20:00:02 -04:00
|
|
|
|
2023-10-17 19:55:17 -04:00
|
|
|
}
|
|
|
|
}
|