-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Alex Resnick <adr8292@gmail.com>
- Loading branch information
1 parent
e5421da
commit 372bdf9
Showing
10 changed files
with
320 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,3 +176,5 @@ logs/ | |
|
||
# Folder that has CTRE Phoenix Sim device config storage | ||
ctre_sim/ | ||
|
||
BuildConstants.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package frc.robot.subsystems.drive; | ||
|
||
import org.littletonrobotics.junction.Logger; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
/** | ||
* Drivetrain subsystem. | ||
*/ | ||
|
||
public class Drivetrain extends SubsystemBase { | ||
private DrivetrainIO io; | ||
private DrivetrainIOInputsAutoLogged inputs = new DrivetrainIOInputsAutoLogged(); | ||
|
||
/** | ||
* Create Wrist Intake Subsystem | ||
*/ | ||
public Drivetrain(DrivetrainIO io) { | ||
this.io = io; | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
io.updateInputs(inputs); | ||
Logger.processInputs("Drivetrain", inputs); | ||
} | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
src/main/java/frc/robot/subsystems/drive/DrivetrainIO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package frc.robot.subsystems.drive; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
|
||
/** | ||
* DrivetrainIO interface | ||
*/ | ||
public interface DrivetrainIO { | ||
/** | ||
* Drivetrain IO | ||
*/ | ||
@AutoLog | ||
public static class DrivetrainIOInputs { | ||
public Rotation2d gyroYaw = new Rotation2d(); | ||
} | ||
|
||
/** Updates the set of loggable inputs. */ | ||
public default void updateInputs(DrivetrainIOInputs inputs) {} | ||
|
||
/** Run the motor at the specified voltage. */ | ||
public default void setDriveVoltage(double lvolts, double rvolts) {} | ||
|
||
|
||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/frc/robot/subsystems/drive/DrivetrainVictorSP.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package frc.robot.subsystems.drive; | ||
|
||
import com.kauailabs.navx.frc.AHRS; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.wpilibj.SPI; | ||
import edu.wpi.first.wpilibj.motorcontrol.VictorSP; | ||
|
||
/** | ||
* Drivetrain VictorSP | ||
*/ | ||
public class DrivetrainVictorSP implements DrivetrainIO { | ||
private final VictorSP left1 = new VictorSP(4); | ||
private final VictorSP left2 = new VictorSP(5); | ||
|
||
private final VictorSP right1 = new VictorSP(6); | ||
private final VictorSP right2 = new VictorSP(7); | ||
|
||
private AHRS gyro = new AHRS(SPI.Port.kMXP); | ||
|
||
/** | ||
* Drivetrain VictorSP | ||
*/ | ||
public DrivetrainVictorSP() { | ||
left1.addFollower(left2); | ||
right1.addFollower(right2); | ||
right1.setInverted(true); | ||
right2.setInverted(true); | ||
} | ||
|
||
@Override | ||
public void updateInputs(DrivetrainIOInputs inputs) { | ||
inputs.gyroYaw = Rotation2d.fromDegrees(gyro.getYaw()); | ||
} | ||
|
||
/** | ||
* Drive Voltage | ||
*/ | ||
public void setDriveVoltage(double lvolts, double rvolts) { | ||
left1.set(lvolts); | ||
right1.set(rvolts); | ||
} | ||
|
||
} |
Oops, something went wrong.