Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bindings #22

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ dependencies {
// Junit testing
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.+'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.+'
testImplementation 'org.junit.platform:junit-platform-launcher:1.x.x'
z0nk9 marked this conversation as resolved.
Show resolved Hide resolved
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5+'

// Monologue
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/sciborgs1155/robot/Ports.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static final class LEDs {
}

public static final class Hopper {
public static final int MOTOR = -1;
public static final int BEAMBREAK = -1;
public static final int MOTOR = 3;
public static final int BEAMBREAK = 4;
}
}
31 changes: 23 additions & 8 deletions src/main/java/org/sciborgs1155/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import static edu.wpi.first.units.Units.Seconds;
import static edu.wpi.first.wpilibj2.command.button.RobotModeTriggers.*;
import static org.sciborgs1155.robot.Constants.*;
import static org.sciborgs1155.robot.Constants.DEADBAND;
import static org.sciborgs1155.robot.Constants.Field.*;
import static org.sciborgs1155.robot.Constants.PERIOD;
import static org.sciborgs1155.robot.drive.DriveConstants.*;

import edu.wpi.first.wpilibj.DataLogManager;
Expand All @@ -31,12 +29,16 @@
import org.sciborgs1155.lib.FaultLogger;
import org.sciborgs1155.lib.InputStream;
import org.sciborgs1155.lib.Test;
import org.sciborgs1155.robot.Constants.Field.Level;
import org.sciborgs1155.robot.Ports.OI;
import org.sciborgs1155.robot.arm.Arm;
import org.sciborgs1155.robot.commands.Autos;
import org.sciborgs1155.robot.commands.Corolling;
import org.sciborgs1155.robot.commands.Scoraling;
import org.sciborgs1155.robot.coroller.Coroller;
import org.sciborgs1155.robot.drive.Drive;
import org.sciborgs1155.robot.elevator.Elevator;
import org.sciborgs1155.robot.hopper.Hopper;
import org.sciborgs1155.robot.led.LEDStrip;
import org.sciborgs1155.robot.scoral.Scoral;
import org.sciborgs1155.robot.vision.Vision;
Expand All @@ -62,6 +64,9 @@ public class Robot extends CommandRobot implements Logged {
private final LEDStrip led = new LEDStrip();
private final Elevator elevator = Elevator.create();
private final Scoral scoral = Scoral.create();
private final Hopper hopper = Hopper.create();
private final Scoraling scoraling = new Scoraling(hopper, scoral, elevator);
z0nk9 marked this conversation as resolved.
Show resolved Hide resolved
private final Corolling corolling = new Corolling(arm, coroller);

// COMMANDS
@Log.NT private final SendableChooser<Command> autos = Autos.configureAutos(drive);
Expand Down Expand Up @@ -107,10 +112,15 @@ private void configureGameBehavior() {

/** Configures trigger -> command bindings. */
private void configureBindings() {
operator.a().onTrue(elevator.scoreLevel(Level.L1));
operator.b().onTrue(elevator.scoreLevel(Level.L2));
operator.x().onTrue(elevator.scoreLevel(Level.L3));
operator.y().onTrue(elevator.scoreLevel(Level.L4));
operator.povDown().onTrue(scoraling.scoral(Level.L1));
z0nk9 marked this conversation as resolved.
Show resolved Hide resolved
operator.povLeft().onTrue(scoraling.scoral(Level.L2));
operator.povRight().onTrue(scoraling.scoral(Level.L3));
operator.povUp().onTrue(scoraling.scoral(Level.L4));
operator.leftBumper().onTrue(arm.climbSetup());
operator.leftTrigger().onTrue(arm.climbExecute());
operator.rightBumper().onTrue(corolling.trough());
operator.rightTrigger().onTrue(corolling.intake());
operator.a().onTrue(corolling.processor());
z0nk9 marked this conversation as resolved.
Show resolved Hide resolved

// x and y are switched: we use joystick Y axis to control field x motion
InputStream x = InputStream.of(driver::getLeftY).negate();
Expand Down Expand Up @@ -159,8 +169,7 @@ private void configureBindings() {
.onTrue(Commands.runOnce(() -> speedMultiplier = Constants.SLOW_SPEED_MULTIPLIER))
.onFalse(Commands.runOnce(() -> speedMultiplier = Constants.FULL_SPEED_MULTIPLIER));

// TODO: Add any additional bindings.

driver.leftTrigger().onTrue(hopper.intake().alongWith(scoral.intake()));
z0nk9 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down Expand Up @@ -197,6 +206,12 @@ public void close() {
super.close();
try {
drive.close();
coroller.close();
led.close();
elevator.close();
scoral.close();
hopper.close();
arm.close();
} catch (Exception e) {
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/sciborgs1155/robot/RobotTest.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.sciborgs1155.robot;

import static org.sciborgs1155.lib.UnitTestingUtil.reset;
import static org.sciborgs1155.lib.UnitTestingUtil.setupTests;

import org.junit.jupiter.api.Test;

public class RobotTest {
@Test
void setup() throws Exception {
setupTests();
new Robot().close();
reset();
}
Expand Down