Skip to content

Commit

Permalink
Merge pull request #11 from Team1810Robotics/Trap
Browse files Browse the repository at this point in the history
added trap
  • Loading branch information
cgathright133 committed Feb 24, 2024
2 parents 35b471b + e1042ed commit b3b4b8e
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 655 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
distribution: 'zulu'
java-version: 17
- run: ./gradlew spotlessApply
- run: ./gradlew spotlessCheck
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
Expand Down
627 changes: 0 additions & 627 deletions .styles/BroncBotzStyle.xml

This file was deleted.

6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,9 @@ wpi.java.configureTestTasks(test)
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
}

tasks.register('updateGitHooks', Copy) {
from './scripts/pre-commit'
into './.git/hooks'
}
compileJava.dependsOn updateGitHooks
12 changes: 12 additions & 0 deletions scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
# Part 1
stagedFiles=$(git diff --staged --name-only)
# Part 2
echo "Running spotlessApply. Formatting code..."
./gradlew spotlessApply
# Part 3
for file in $stagedFiles; do
if test -f "$file"; then
git add $file
fi
done
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 @@ -99,4 +99,8 @@ public static final class IOConstants {

public static final double DEADBAND = 0.3;
}

public static final class TrapConstants {
public static final int VICTOR_MOTOR_PORT = 0;
}
}
36 changes: 12 additions & 24 deletions src/main/java/frc/robot/IO.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,20 @@ public final class IO {
public static final JoystickButton rightJoystick_button7 = new JoystickButton(leftJoystick, 7);
public static final JoystickButton rightJoystick_button8 = new JoystickButton(leftJoystick, 8);
public static final JoystickButton rightJoystick_button9 = new JoystickButton(leftJoystick, 9);
public static final JoystickButton rightJoystick_button10 =
new JoystickButton(leftJoystick, 10);
public static final JoystickButton rightJoystick_button11 =
new JoystickButton(leftJoystick, 11);
public static final JoystickButton rightJoystick_button10 = new JoystickButton(leftJoystick, 10);
public static final JoystickButton rightJoystick_button11 = new JoystickButton(leftJoystick, 11);

// Xbox buttons
public static final JoystickButton manipulatorXbox_A =
new JoystickButton(xboxController, XboxController.Button.kA.value);
public static final JoystickButton manipulatorXbox_B =
new JoystickButton(xboxController, XboxController.Button.kB.value);
public static final JoystickButton manipulatorXbox_X =
new JoystickButton(xboxController, XboxController.Button.kX.value);
public static final JoystickButton manipulatorXbox_Y =
new JoystickButton(xboxController, XboxController.Button.kY.value);
public static final JoystickButton manipulatorXbox_LB =
new JoystickButton(xboxController, XboxController.Button.kLeftBumper.value);
public static final JoystickButton manipulatorXbox_RB =
new JoystickButton(xboxController, XboxController.Button.kRightBumper.value);
public static final JoystickButton manipulatorXbox_Back =
new JoystickButton(xboxController, XboxController.Button.kBack.value);
public static final JoystickButton manipulatorXbox_Start =
new JoystickButton(xboxController, XboxController.Button.kStart.value);
public static final JoystickButton manipulatorXbox_LStick =
new JoystickButton(xboxController, XboxController.Button.kLeftStick.value);
public static final JoystickButton manipulatorXbox_RStick =
new JoystickButton(xboxController, XboxController.Button.kRightStick.value);
public static final JoystickButton manipulatorXbox_A = new JoystickButton(xboxController, XboxController.Button.kA.value);
public static final JoystickButton manipulatorXbox_B = new JoystickButton(xboxController, XboxController.Button.kB.value);
public static final JoystickButton manipulatorXbox_X = new JoystickButton(xboxController, XboxController.Button.kX.value);
public static final JoystickButton manipulatorXbox_Y = new JoystickButton(xboxController, XboxController.Button.kY.value);
public static final JoystickButton manipulatorXbox_LB = new JoystickButton(xboxController, XboxController.Button.kLeftBumper.value);
public static final JoystickButton manipulatorXbox_RB = new JoystickButton(xboxController, XboxController.Button.kRightBumper.value);
public static final JoystickButton manipulatorXbox_Back = new JoystickButton(xboxController, XboxController.Button.kBack.value);
public static final JoystickButton manipulatorXbox_Start = new JoystickButton(xboxController, XboxController.Button.kStart.value);
public static final JoystickButton manipulatorXbox_LStick = new JoystickButton(xboxController, XboxController.Button.kLeftStick.value);
public static final JoystickButton manipulatorXbox_RStick = new JoystickButton(xboxController, XboxController.Button.kRightStick.value);

private IO() {
/* what does sleep feel like */
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/frc/robot/commands/IntakeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ public IntakeCommand(IntakeSubsystem intakeSubsystem, double intakeSpeed) {
addRequirements(intakeSubsystem);
}

@Override
public void execute() {
intakeSubsystem.setSpeed(intakeSpeed);
boolean beam = intakeSubsystem.getBeamBreak();

if (beam = true) {
intakeSubsystem.setSpeed(0);
}
}

@Override
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/frc/robot/commands/TrapCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.TrapSubsystem;

public class TrapCommand extends Command {

TrapSubsystem trapsubsystem;

double trap;

public TrapCommand(TrapSubsystem trapSubsystem, double trap) {
this.trap = trap;
this.trapsubsystem = trapSubsystem;

addRequirements(trapSubsystem);
}

public void execute() {
trapsubsystem.motorOn(trap);
}

public void end() {
trapsubsystem.motorOff();
}
}
6 changes: 4 additions & 2 deletions src/main/java/frc/robot/subsystems/IntakeSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class IntakeSubsystem extends SubsystemBase {

CANSparkMax motor = new CANSparkMax(Constants.IntakeConstants.MOTOR_ID, MotorType.kBrushless);
DigitalInput input = new DigitalInput(Constants.IntakeConstants.BEAM_BREAK_PORT);
DigitalInput beam = new DigitalInput(Constants.IntakeConstants.BEAM_BREAK_PORT);

public void setSpeed(double motorSpeed) {
motor.set(motorSpeed);
Expand All @@ -20,6 +20,8 @@ public void stop() {
}

public boolean getBeamBreak() {
return input.get();
return beam.get();
}

public IntakeSubsystem() {}
}
18 changes: 18 additions & 0 deletions src/main/java/frc/robot/subsystems/TrapSubsystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package frc.robot.subsystems;

import edu.wpi.first.wpilibj.motorcontrol.VictorSP;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;

public class TrapSubsystem extends SubsystemBase {

VictorSP victor = new VictorSP(Constants.TrapConstants.VICTOR_MOTOR_PORT);

public void motorOn(double victorSpeed) {
victor.set(victorSpeed);
}

public void motorOff() {
victor.set(0);
}
}

0 comments on commit b3b4b8e

Please sign in to comment.