Skip to content

Commit

Permalink
drive hopefully done
Browse files Browse the repository at this point in the history
  • Loading branch information
Merridew1 committed Nov 20, 2024
1 parent 15f60fe commit 55501fb
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public static final class DriveTrainMotors {
public static final int BRMOTOR = 2;
public static final int BLMOTOR = 3;
}
public static final class IntakeMotors {
public static final int LMOTOR = 4;
public static final int RMOTOR = 5;
}
}

/**
Expand Down
21 changes: 14 additions & 7 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package frc.robot;

import org.littletonrobotics.conduit.schema.Joystick;
import edu.wpi.first.wpilibj.GenericHID;
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 frc.robot.Robot.RobotRunType;
import frc.robot.commands.Drive;
import frc.robot.subsystems.drive.Drivetrain;
import frc.robot.subsystems.drive.DrivetrainIO;
import frc.robot.subsystems.drive.DrivetrainReal;
Expand All @@ -21,12 +20,12 @@
*/
public class RobotContainer {
/* Controllers */
Joystick driver = new Joystick();
XboxController driver = new XboxController(0);
// Initialize AutoChooser Sendable
private final SendableChooser<String> autoChooser = new SendableChooser<>();

/* Subsystems */
private Drivetrain drivetrain;
private Drivetrain driveTrain;


/**
Expand All @@ -37,13 +36,13 @@ public RobotContainer(RobotRunType runtimeType) {
autoChooser.setDefaultOption("Wait 1 Second", "wait");
switch (runtimeType) {
case kReal:
drivetrain = new Drivetrain(new DrivetrainReal());
driveTrain = new Drivetrain(new DrivetrainReal());
break;
case kSimulation:
// drivetrain = new Drivetrain(new DrivetrainSim() {});
break;
default:
drivetrain = new Drivetrain(new DrivetrainIO() {});
driveTrain = new Drivetrain(new DrivetrainIO() {});
}
// Configure the button bindings
configureButtonBindings();
Expand All @@ -55,7 +54,15 @@ public RobotContainer(RobotRunType runtimeType) {
* ({@link edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then passing it to a
* {@link edu.wpi.first.wpilibj2.command.button.JoystickButton}.
*/
private void configureButtonBindings() {}

;

private void configureButtonBindings() {

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


}

/**
* Gets the user's selected autonomous command.
Expand Down
Empty file.
32 changes: 32 additions & 0 deletions src/main/java/frc/robot/commands/Drive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package frc.robot.commands;

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

/**
* Drive.
*/

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

/**
* Drive again.
*/

public Drive(Drivetrain drive, XboxController controller) {
this.controller = controller;
this.drive = drive;
addRequirements(drive);
}

@Override
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);

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

public class intake {

Check warning on line 3 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:3:1: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)

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

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 Type name 'intake' must match pattern '^[A-Z][_a-zA-Z0-9]*$'. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intake.java:3:14: warning: Type name 'intake' must match pattern '^[A-Z][_a-zA-Z0-9]*$'. (com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck)

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

import org.littletonrobotics.junction.AutoLog;

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 🐶 Type name 'intakeIO' must match pattern '^[A-Z][_a-zA-Z0-9]*$'. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intakeIO.java:5:18: warning: Type name 'intakeIO' must match pattern '^[A-Z][_a-zA-Z0-9]*$'. (com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck)

@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 {

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

View workflow job for this annotation

GitHub Actions / Linting

[testtool] reported by reviewdog 🐶 Type name 'intakeIOInputs' must match pattern '^[A-Z][_a-zA-Z0-9]*$'. Raw Output: /github/workspace/./src/main/java/frc/robot/subsystems/intake/intakeIO.java:8:25: warning: Type name 'intakeIOInputs' must match pattern '^[A-Z][_a-zA-Z0-9]*$'. (com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck)
public double rightMotor;
public double leftMotor;
}

/** Updates the set of loggable inputs. */

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

}

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

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

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() {
rightIntake.setInverted(true);
}


public void intakeVoltage(double lvolts, double rvolts) {
leftIntake.set(lvolts);
rightIntake.set(rvolts);
}

}

0 comments on commit 55501fb

Please sign in to comment.