Skip to content

Commit

Permalink
stuff that james made eddie do
Browse files Browse the repository at this point in the history
  • Loading branch information
JJTech0130 committed Mar 7, 2024
1 parent 6e75d19 commit 846132f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package org.firstinspires.ftc.teamcode.opmode;

public class Configuration {
String park = "none";
boolean placePixel = false;
boolean fieldCentric = true;
// - place pixel?
// - use inner or outer paths?
// - park or drop on board?
//String park = "none";
boolean placePixel = true;
boolean doPark = true;
boolean innerPath = true; // ignored if doPark is false
boolean dropOnBoard = true; // ignored if doPark is false

boolean fieldCentric = true;
boolean tensorFlowInInit = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.qualcomm.robotcore.util.ReadWriteFile;

import org.firstinspires.ftc.robotcore.internal.system.AppUtil;
import org.firstinspires.ftc.teamcode.util.Debouncer;
import org.firstinspires.ftc.teamcode.util.Toggle;

import java.io.File;
Expand Down Expand Up @@ -55,32 +54,44 @@ private static void save(Configuration config, String filename) {
@Override
public void runOpMode() throws InterruptedException {
waitForStart();
//telemetry.addData("CONTROLS", "A: place pixel toggle \nB: inner park \nY: outer park \nX: board park \ndpad_down: no park \ndpad_up: field centric toggle");

Toggle purpleToggle = new Toggle();
Toggle placePixelToggle = new Toggle();
Toggle doParkToggle = new Toggle();
Toggle innerPathToggle = new Toggle();
Toggle dropOnBoardToggle = new Toggle();

Toggle fieldCentricToggle = new Toggle();
Toggle tensorflowToggle = new Toggle();
Debouncer innerPark = new Debouncer();
Debouncer outerPark = new Debouncer();
Debouncer placePixel = new Debouncer();


//String park = "none";

Configuration config = Configurator.load();

purpleToggle.state = config.placePixel;
placePixelToggle.state = config.placePixel;
doParkToggle.state = config.doPark;
innerPathToggle.state = config.innerPath;
dropOnBoardToggle.state = config.dropOnBoard;

fieldCentricToggle.state = config.fieldCentric;
tensorflowToggle.state = config.tensorFlowInInit;

// Toggle innerParkToggle = new Toggle();
// Toggle outerParkToggle = new Toggle();
// Toggle placePixelToggle = new Toggle();

while (!isStopRequested()) {
purpleToggle.update(gamepad1.a);
telemetry.addData("purple pixel (A)", purpleToggle.state);
config.placePixel = purpleToggle.state;
placePixelToggle.update(gamepad1.a);
telemetry.addData("place pixel (A)", placePixelToggle.state);
config.placePixel = placePixelToggle.state;

doParkToggle.update(gamepad1.dpad_right);
telemetry.addData("do park (dpad right)", doParkToggle.state);
config.doPark = doParkToggle.state;

if (config.doPark) {
innerPathToggle.update(gamepad1.y);
telemetry.addData("inner path (Y)", innerPathToggle.state);
config.innerPath = innerPathToggle.state;

dropOnBoardToggle.update(gamepad1.dpad_up);
telemetry.addData("drop on board (dpad up)", dropOnBoardToggle.state);
config.dropOnBoard = dropOnBoardToggle.state;
}



tensorflowToggle.update(gamepad1.b);
Expand All @@ -91,22 +102,22 @@ public void runOpMode() throws InterruptedException {
telemetry.addData("field centric (X)", fieldCentricToggle.state);
config.fieldCentric = fieldCentricToggle.state;

if (config.placePixel) {

if (innerPark.update(gamepad1.dpad_up)) {
config.park = "inner";
} else if (outerPark.update(gamepad1.dpad_down)) {
config.park = "outer";
} else if (placePixel.update(gamepad1.dpad_right)) {
config.park = "board";
} else if (gamepad1.dpad_left) {
config.park = "none";
}

telemetry.addData("park (dpad)", config.park);
} else {
config.park = "none";
}
// if (config.placePixel) {
//
// if (innerPark.update(gamepad1.dpad_up)) {
// config.park = "inner";
// } else if (outerPark.update(gamepad1.dpad_down)) {
// config.park = "outer";
// } else if (placePixel.update(gamepad1.dpad_right)) {
// config.park = "board";
// } else if (gamepad1.dpad_left) {
// config.park = "none";
// }
//
// telemetry.addData("park (dpad)", config.park);
// } else {
// config.park = "none";
// }

telemetry.update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@Autonomous
@Config
Expand Down Expand Up @@ -112,22 +111,29 @@ public void runOpMode() throws InterruptedException {
telemetry.log().add("Tensorflow detected: " + tensorPos);
}

// MARK: Components

List<Component> componentList = new ArrayList<>();

// Configuration values:
// - place pixel?
// - park at all?
// - use inner or outer paths?
// - park or drop on board?

if (config.placePixel) {
componentList.add(new PurplePixelComponent(robot, tensorPos, Objects.equals(config.park, "inner")));
componentList.add(new PurplePixelComponent(robot, tensorPos, config.innerPath && config.doPark));
}

switch (config.park) {
case "outer":
componentList.add(new ParkingOut(robot));
break;
case "inner":
if (config.doPark) {
if (config.innerPath) {
componentList.add(new ParkingIn(robot));
break;
case "board":
} else {
componentList.add(new ParkingOut(robot));
}
if (config.dropOnBoard) {
componentList.add(new GoToBoard(robot, tensorPos));
break;
}
}

for (Component component : componentList) {
Expand Down

0 comments on commit 846132f

Please sign in to comment.