Skip to content

Commit

Permalink
Finished drivetrain and intake
Browse files Browse the repository at this point in the history
  • Loading branch information
Merridew1 committed Nov 21, 2024
1 parent 55501fb commit 35c74f2
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 30 deletions.
12 changes: 6 additions & 6 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public final class Constants {
*/
public static final class Motors {
public static final class DriveTrainMotors {
public static final int FRMOTOR = 0;
public static final int FLMOTOR = 1;
public static final int BRMOTOR = 2;
public static final int BLMOTOR = 3;
public static final int FRMOTOR = 5;
public static final int FLMOTOR = 6;
public static final int BRMOTOR = 4;
public static final int BLMOTOR = 7;
}
public static final class IntakeMotors {
public static final int LMOTOR = 4;
public static final int RMOTOR = 5;
public static final int LMOTOR = 1;
public static final int RMOTOR = 2;
}
}

Expand Down
12 changes: 9 additions & 3 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package frc.robot;

import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.WaitCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.Robot.RobotRunType;
import frc.robot.commands.Drive;
import frc.robot.commands.IntakeCommand;
import frc.robot.commands.OutTakeCommand;
import frc.robot.subsystems.Intake.Intake;
import frc.robot.subsystems.drive.Drivetrain;
import frc.robot.subsystems.drive.DrivetrainIO;
import frc.robot.subsystems.drive.DrivetrainReal;
Expand All @@ -20,12 +23,13 @@
*/
public class RobotContainer {
/* Controllers */
XboxController driver = new XboxController(0);
CommandXboxController driver = new CommandXboxController(0);
// Initialize AutoChooser Sendable
private final SendableChooser<String> autoChooser = new SendableChooser<>();

/* Subsystems */
private Drivetrain driveTrain;
private Intake intake;


/**
Expand All @@ -45,6 +49,7 @@ public RobotContainer(RobotRunType runtimeType) {
driveTrain = new Drivetrain(new DrivetrainIO() {});
}
// Configure the button bindings
driveTrain.setDefaultCommand(new Drive(driveTrain, driver));
configureButtonBindings();
}

Expand All @@ -58,8 +63,9 @@ public RobotContainer(RobotRunType runtimeType) {
;

private void configureButtonBindings() {
driver.rightTrigger().whileTrue(new OutTakeCommand(intake, driver));
driver.leftTrigger().whileTrue(new IntakeCommand(intake, driver));

driveTrain.setDefaultCommand(new Drive(driveTrain, driver));


}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/frc/robot/commands/Drive.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.subsystems.drive.Drivetrain;

/**
* Drive.
*/

public class Drive extends Command {
private XboxController controller;
private CommandXboxController controller;
private Drivetrain drive;

/**
* Drive again.
*/

public Drive(Drivetrain drive, XboxController controller) {
public Drive(Drivetrain drive, CommandXboxController controller) {
this.controller = controller;
this.drive = drive;
addRequirements(drive);
Expand All @@ -26,7 +26,7 @@ public Drive(Drivetrain drive, XboxController controller) {
public void execute() {
double leftY = (Math.abs(controller.getLeftY()) < .05) ? 0 : controller.getLeftY();
double rightY = (Math.abs(controller.getRightY()) < .05) ? 0 : controller.getRightY();
this.drive.setPower(leftY, rightY);
drive.setPower(leftY, rightY);

}
}
23 changes: 23 additions & 0 deletions src/main/java/frc/robot/commands/IntakeCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.subsystems.Intake.Intake;

public class IntakeCommand extends Command {
private CommandXboxController controller;
private Intake intake;

public IntakeCommand(Intake intake, CommandXboxController controller) {
this.controller = controller;
this.intake = intake;
addRequirements(intake);
}

@Override
public void execute() {
intake.setIntakeVoltage(1);
controller.leftTrigger().whileTrue(new InstantCommand(() -> intake.setIntakeVoltage(-1)));
}
}
24 changes: 24 additions & 0 deletions src/main/java/frc/robot/commands/OutTakeCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.subsystems.Intake.Intake;

public class OutTakeCommand extends Command {
private CommandXboxController controller;
private Intake intake;

public OutTakeCommand(Intake intake, CommandXboxController controller) {
this.controller = controller;
this.intake = intake;
addRequirements(intake);
}

@Override
public void execute() {
intake.setIntakeVoltage(-1);
controller.rightTrigger().whileTrue(new InstantCommand(() -> intake.setIntakeVoltage(1)));
controller.leftTrigger().whileTrue(new InstantCommand(() -> intake.setIntakeVoltage(-1)));
}
}
5 changes: 2 additions & 3 deletions src/main/java/frc/robot/subsystems/drive/DrivetrainReal.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public DrivetrainReal() {
FRMotor.addFollower(BRMotor);

FRMotor.setInverted(true);
BRMotor.setInverted(true);
}


Expand All @@ -35,8 +34,8 @@ public void updateInputs(DrivetrainIOInputs inputs) {
* Drive Voltage
*/
public void setDriveVoltage(double lvolts, double rvolts) {
FRMotor.setVoltage(lvolts);
FRMotor.setVoltage(rvolts);
FLMotor.set(lvolts);
FRMotor.set(rvolts);
}

}
21 changes: 19 additions & 2 deletions src/main/java/frc/robot/subsystems/intake/intake.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
package frc.robot.subsystems.intake;
package frc.robot.subsystems.Intake;

Check warning on line 1 in src/main/java/frc/robot/subsystems/intake/intake.java

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 Package name 'frc.robot.subsystems.Intake' must match pattern '^[_a-z]+(\.[_a-z][_a-z0-9]*)*$'. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intake.java:1:9: warning: Package name 'frc.robot.subsystems.Intake' must match pattern '^[_a-z]+(\.[_a-z][_a-z0-9]*)*$'. (com.puppycrawl.tools.checkstyle.checks.naming.PackageNameCheck)

public class intake {
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class Intake extends SubsystemBase {

Check warning on line 5 in src/main/java/frc/robot/subsystems/intake/intake.java

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intake.java:5:1: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)

Check warning on line 5 in src/main/java/frc/robot/subsystems/intake/intake.java

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 The name of the outer type and the file do not match. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intake.java:5:1: warning: The name of the outer type and the file do not match. (com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheck)
private IntakeIO io;
private IntakeIOInputsAutoLogged inputs = new IntakeIOInputsAutoLogged();

public Intake(IntakeIO io) {
this.io = io;
}

@Override
public void periodic() {
io.updateInputs(inputs);
}

public void setIntakeVoltage(int power) {
io.setIntakeVoltage(power);
}

}
9 changes: 5 additions & 4 deletions src/main/java/frc/robot/subsystems/intake/intakeIO.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package frc.robot.subsystems.intake;
package frc.robot.subsystems.Intake;

Check warning on line 1 in src/main/java/frc/robot/subsystems/intake/intakeIO.java

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 Package name 'frc.robot.subsystems.Intake' must match pattern '^[_a-z]+(\.[_a-z][_a-z0-9]*)*$'. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intakeIO.java:1:9: warning: Package name 'frc.robot.subsystems.Intake' must match pattern '^[_a-z]+(\.[_a-z][_a-z0-9]*)*$'. (com.puppycrawl.tools.checkstyle.checks.naming.PackageNameCheck)

import org.littletonrobotics.junction.AutoLog;

public interface intakeIO {
public interface IntakeIO {

Check warning on line 5 in src/main/java/frc/robot/subsystems/intake/intakeIO.java

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intakeIO.java:5:1: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)

Check warning on line 5 in src/main/java/frc/robot/subsystems/intake/intakeIO.java

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 The name of the outer type and the file do not match. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intakeIO.java:5:1: warning: The name of the outer type and the file do not match. (com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheck)

@AutoLog

Check warning on line 7 in src/main/java/frc/robot/subsystems/intake/intakeIO.java

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intakeIO.java:7:5: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)
public static class intakeIOInputs {
public static class IntakeIOInputs {
public double rightMotor;
public double leftMotor;
}

/** Updates the set of loggable inputs. */
public default void updateInputs(IntakeIOInputs inputs) {}

public default void intakePower(double lvolts, double rvolts) {}
public default void setIntakeVoltage(double power) {}

}

16 changes: 8 additions & 8 deletions src/main/java/frc/robot/subsystems/intake/intakeReal.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package frc.robot.subsystems.intake;
package frc.robot.subsystems.Intake;

Check warning on line 1 in src/main/java/frc/robot/subsystems/intake/intakeReal.java

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 Package name 'frc.robot.subsystems.Intake' must match pattern '^[_a-z]+(\.[_a-z][_a-z0-9]*)*$'. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intakeReal.java:1:9: warning: Package name 'frc.robot.subsystems.Intake' must match pattern '^[_a-z]+(\.[_a-z][_a-z0-9]*)*$'. (com.puppycrawl.tools.checkstyle.checks.naming.PackageNameCheck)

import edu.wpi.first.wpilibj.motorcontrol.VictorSP;

public class intakeReal implements intakeIO {
public class intakeReal implements IntakeIO {

Check warning on line 5 in src/main/java/frc/robot/subsystems/intake/intakeReal.java

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intakeReal.java:5:1: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)

Check warning on line 5 in src/main/java/frc/robot/subsystems/intake/intakeReal.java

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 Type name 'intakeReal' must match pattern '^[A-Z][_a-zA-Z0-9]*$'. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intakeReal.java:5:14: warning: Type name 'intakeReal' must match pattern '^[A-Z][_a-zA-Z0-9]*$'. (com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck)
VictorSP leftIntake = new VictorSP(frc.robot.Constants.Motors.IntakeMotors.LMOTOR);
VictorSP rightIntake = new VictorSP(frc.robot.Constants.Motors.IntakeMotors.RMOTOR);

public intakeReal() {

public void setIntakeVoltage(double volts) {
rightIntake.setInverted(true);
leftIntake.set(volts);
rightIntake.set(volts);
}


public void intakeVoltage(double lvolts, double rvolts) {
leftIntake.set(lvolts);
rightIntake.set(rvolts);
}
@Override
public void updateInputs(IntakeIOInputs inputs) {};

}

0 comments on commit 35c74f2

Please sign in to comment.