Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.pedropathing.geometry.BezierLine;
import com.pedropathing.geometry.Pose;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.skeletonarmy.marrow.TimerEx;
import com.skeletonarmy.marrow.prompts.OptionPrompt;
import com.skeletonarmy.marrow.prompts.Prompter;

Expand All @@ -20,6 +21,7 @@
import org.firstinspires.ftc.teamcode.pedroPathing.Constants;

import dev.nextftc.core.commands.delays.Delay;
import dev.nextftc.core.commands.delays.WaitUntil;
import dev.nextftc.core.commands.groups.ParallelRaceGroup;
import dev.nextftc.core.commands.groups.SequentialGroup;
import dev.nextftc.core.commands.utility.InstantCommand;
Expand All @@ -29,6 +31,7 @@
@Autonomous(name = "Auto_Main_", group = "Main", preselectTeleOp="Teleop_Main_")
public class Auto_Main_ extends NextFTCOpMode {

TimerEx timer25Sec = new TimerEx(25);
// Variable to store the selected auto program
Auto selectedAuto = null;
// Create the prompter object for selecting Alliance and Auto
Expand Down Expand Up @@ -61,10 +64,14 @@ public void onInit() {
prompter.prompt("auto",
new OptionPrompt<>("Select Auto",
new MOE_365_FAR(),
new Near_15Ball(),
new Near_15Ball2(),
new Near_12Ball(),
new Near_9Ball(),
new Far_9Ball(),
new Far_6Ball()
new Far_6Ball(),
new Far_3Ball()
//new test()
));
prompter.onComplete(() -> {
selectedAlliance = prompter.get("alliance");
Expand Down Expand Up @@ -97,10 +104,11 @@ public void onWaitForStart() {

@Override
public void onStartButtonPressed() {
Robot.lights.setAllianceDisplay(selectedAlliance);
Robot.lights.setSolidAllianceDisplay(selectedAlliance);
// Schedule the proper auto
selectedAuto.runAuto();
turretOn = selectedAuto.getTurretEnabled();
timer25Sec.restart();

// Indicate that initialization is done
telemetry.addLine("Initialized");
Expand All @@ -113,11 +121,7 @@ public void onUpdate() {
telemetry.addData("Alliance", selectedAlliance);
Robot.turret.updateAimbot(turretOn, true, 0);
Robot.turret.updateFlywheel();

MecanumDrivetrainClass.robotPose = Robot.drivetrain.follower.getPose();

telemetry.addLine();
telemetry.addData("Mirror -90", Math.toDegrees(paths.autoMirror(new Pose(0,0,-90)).getHeading()));
telemetry.update();
}

Expand Down Expand Up @@ -151,7 +155,7 @@ abstract static class Auto{
public abstract String toString();
}

private class Far_6Ball extends Auto{
private class Far_9Ball extends Auto{
@Override
public Pose getStartPose(){
return paths.farStart;
Expand All @@ -171,16 +175,20 @@ public void runAuto(){
Commands.runPath(paths.farShoot_to_farPreload, true, 1),
Commands.runPath(paths.farPreload_to_farShoot, true, 1),
Commands.shootBalls(),
Commands.setFlywheelState(Turret.flywheelState.ON),
Commands.setIntakeMode(Intake.intakeMode.INTAKING),
Commands.runPath(paths.farShoot_to_hpPreload, true, 1),
Commands.runPath(paths.hpPreload_to_farShoot, true, 1),
Commands.shootBalls(),
Commands.runPath(paths.farShoot_to_farLeave, true, 1)
).schedule();
}

@NonNull
@Override
public String toString(){return "Far Zone 6 Ball";}
public String toString(){return "Far 9 Ball";}
}

private class Far_9Ball extends Auto{
private class Far_6Ball extends Auto{
@Override
public Pose getStartPose(){
return paths.farStart;
Expand All @@ -200,20 +208,44 @@ public void runAuto(){
Commands.runPath(paths.farShoot_to_farPreload, true, 1),
Commands.runPath(paths.farPreload_to_farShoot, true, 1),
Commands.shootBalls(),
Commands.setFlywheelState(Turret.flywheelState.ON),
Commands.setIntakeMode(Intake.intakeMode.INTAKING),
Commands.runPath(paths.farShoot_to_midPreload, true, 1),
Commands.runPath(paths.midPreload_to_farShoot, true, 1),
Commands.shootBalls(),
Commands.runPath(paths.farShoot_to_farLeave, true, 1)
).schedule();
}

@NonNull
@Override
public String toString(){return "Far Zone 9 Ball";}
public String toString(){return "Far 6 Ball";}
}
private class Far_3Ball extends Auto{

@Override
Pose getStartPose() {
return paths.farStart;
}

@Override
boolean getTurretEnabled() {
return true;
}

@Override
void runAuto() {
new SequentialGroup(
Commands.setFlywheelState(Turret.flywheelState.ON),
Commands.runPath(paths.farStart_to_farShoot, true, 1),
Commands.shootBalls(),
new WaitUntil(() -> timer25Sec.isDone()),
Commands.setIntakeMode(Intake.intakeMode.INTAKING),
Commands.runPath(paths.farShoot_to_hpPreload, true, 1)
).schedule();
}

@NonNull
@Override
public String toString() {
return "Far 3 Ball + HP Intake";
}
}
private class Near_9Ball extends Auto{
@Override
public Pose getStartPose(){
Expand Down Expand Up @@ -247,9 +279,8 @@ public void runAuto(){

@NonNull
@Override
public String toString(){return "Near Zone 9 Ball";}
public String toString(){return "Near 9 Ball";}
}

private class Near_12Ball extends Auto{
@Override
public Pose getStartPose(){
Expand Down Expand Up @@ -285,9 +316,100 @@ public void runAuto(){

@NonNull
@Override
public String toString(){return "Near Zone 12 Ball";}
public String toString(){return "Near 12 Ball";}
}
private class Near_15Ball extends Auto{

@Override
Pose getStartPose() {
return paths.nearStart;
}

@Override
boolean getTurretEnabled() {
return true;
}

@Override
void runAuto() {
new SequentialGroup(
Commands.setFlywheelState(Turret.flywheelState.ON),
Commands.runPath(paths.nearStart_to_midShoot, true, 1),
Commands.shootBalls(),
Commands.setIntakeMode(Intake.intakeMode.INTAKING),
Commands.runPath(paths.midShoot_to_midPreload, true, 1),
Commands.runPath(paths.midPreload_to_midShoot, true, 1),
Commands.shootBalls(),
Commands.setIntakeMode(Intake.intakeMode.INTAKING),
Commands.runPath(paths.midShoot_to_openGateIntake, true, 1),
Commands.waitForArtifacts(),
Commands.runPath(paths.openGateIntake_to_midShoot, true, 1),
Commands.shootBalls(),
Commands.setIntakeMode(Intake.intakeMode.INTAKING),
Commands.runPath(paths.midShoot_to_farPreload, true, 1),
Commands.setIntakeMode(Intake.intakeMode.OFF),
Commands.runPath(paths.farPreload_to_midShoot, true, 1),
Commands.shootBalls(),
Commands.setIntakeMode(Intake.intakeMode.INTAKING),
Commands.runPath(paths.midShoot_to_nearPreload, true, 1),
Commands.runPath(paths.nearPreload_to_midShoot, false, 1),
Commands.shootBalls(),
Commands.runPath(paths.midShoot_to_nearLeave, true, 1)
).schedule();
}

@NonNull
@Override
public String toString() {
return "Near 15 Ball (With Far Spike Mark)";
}
}
private class Near_15Ball2 extends Auto{

@Override
Pose getStartPose() {
return paths.nearStart;
}

@Override
boolean getTurretEnabled() {
return true;
}

@Override
void runAuto() {
new SequentialGroup(
Commands.setFlywheelState(Turret.flywheelState.ON),
Commands.runPath(paths.nearStart_to_midShoot, true, 1),
Commands.shootBalls(),
Commands.setIntakeMode(Intake.intakeMode.INTAKING),
Commands.runPath(paths.midShoot_to_midPreload, true, 1),
Commands.runPath(paths.midPreload_to_midShoot, true, 1),
Commands.shootBalls(),
Commands.setIntakeMode(Intake.intakeMode.INTAKING),
Commands.runPath(paths.midShoot_to_openGateIntake, true, 1),
Commands.waitForArtifacts(),
Commands.runPath(paths.openGateIntake_to_midShoot, true, 1),
Commands.shootBalls(),
Commands.setIntakeMode(Intake.intakeMode.INTAKING),
Commands.runPath(paths.midShoot_to_openGateIntake, true, 1),
Commands.waitForArtifacts(),
Commands.runPath(paths.openGateIntake_to_midShoot, true, 1),
Commands.shootBalls(),
Commands.setIntakeMode(Intake.intakeMode.INTAKING),
Commands.runPath(paths.midShoot_to_nearPreload, true, 1),
Commands.runPath(paths.nearPreload_to_midShoot, false, 1),
Commands.shootBalls(),
Commands.runPath(paths.midShoot_to_nearLeave, true, 1)
).schedule();
}

@NonNull
@Override
public String toString() {
return "Near 15 Ball (No Far Spike Mark)";
}
}
private class MOE_365_FAR extends Auto{
@Override
public Pose getStartPose(){
Expand Down Expand Up @@ -341,6 +463,6 @@ public void runAuto(){

@NonNull
@Override
public String toString(){return "MOE 365 Far Zone Auto";}
public String toString(){return "MOE 365 Far";}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
import org.firstinspires.ftc.robotcore.external.navigation.CurrentUnit;
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
import org.firstinspires.ftc.teamcode.LOADCode.Main_.Hardware_.LoadHardwareClass;
import org.firstinspires.ftc.teamcode.Prism.Color;
import org.firstinspires.ftc.teamcode.Prism.Direction;
import org.firstinspires.ftc.teamcode.Prism.GoBildaPrismDriver;
import org.firstinspires.ftc.teamcode.Prism.PrismAnimations;

import dev.nextftc.control.ControlSystem;
import dev.nextftc.control.KineticState;
Expand Down Expand Up @@ -364,40 +361,45 @@ public static class GoBildaPrismBarClass {
// Maximum length of 4 daisy chained strips is 36 (12 + 12 + 6 + 6)
// Scrimmage length of 2 daisy chained strips is 24 (12 + 12)

// Artboards current status:
GoBildaPrismDriver.Artboard solidRED = GoBildaPrismDriver.Artboard.ARTBOARD_0;
GoBildaPrismDriver.Artboard solidBLUE = GoBildaPrismDriver.Artboard.ARTBOARD_1;
GoBildaPrismDriver.Artboard blinkingRED = GoBildaPrismDriver.Artboard.ARTBOARD_2;
GoBildaPrismDriver.Artboard blinkingBLUE = GoBildaPrismDriver.Artboard.ARTBOARD_3;
GoBildaPrismDriver.Artboard rainbow = GoBildaPrismDriver.Artboard.ARTBOARD_4;

GoBildaPrismDriver prism;
int stripBrightness = 50;
int stripBrightness = 25;
public void init(@NonNull OpMode opmode, int stripLength){
prism = opmode.hardwareMap.get(GoBildaPrismDriver.class, "prism");
prism.setStripLength(stripLength);
prism.clearAllAnimations();
}

public void setStripSolidColor(Color color){
prism.insertAndUpdateAnimation(GoBildaPrismDriver.LayerHeight.LAYER_0, new PrismAnimations.Solid(color, stripBrightness));
public void setStripBrightness(int brightness){
stripBrightness = brightness;
}

public void setStripRainbow(){
PrismAnimations.AnimationBase colorA = new PrismAnimations.Rainbow(Direction.Backward);
colorA.setIndexes(0, 12);
PrismAnimations.AnimationBase colorB = new PrismAnimations.Rainbow(Direction.Forward);
colorB.setIndexes(13, 24);
prism.insertAndUpdateAnimation(GoBildaPrismDriver.LayerHeight.LAYER_1, colorA);
prism.insertAndUpdateAnimation(GoBildaPrismDriver.LayerHeight.LAYER_2, colorB);
public void setDisplayedArtboard(GoBildaPrismDriver.Artboard board){
prism.loadAnimationsFromArtboard(board);
}

public void clearStripAnimations(){
prism.clearAllAnimations();
public void setStripRainbow(){
setDisplayedArtboard(rainbow);
}

public void setStripBrightness(int brightness){
stripBrightness = brightness;
public void setSolidAllianceDisplay(LoadHardwareClass.Alliance alliance){
if (alliance == LoadHardwareClass.Alliance.RED){
setDisplayedArtboard(solidRED);
}else if (alliance == LoadHardwareClass.Alliance.BLUE){
setDisplayedArtboard(solidBLUE);
}
}

public void setAllianceDisplay(LoadHardwareClass.Alliance alliance){
clearStripAnimations();
public void setBlinkingAllianceDisplay(LoadHardwareClass.Alliance alliance){
if (alliance == LoadHardwareClass.Alliance.RED){
setStripSolidColor(Color.RED);
setDisplayedArtboard(blinkingRED);
}else if (alliance == LoadHardwareClass.Alliance.BLUE){
setStripSolidColor(Color.BLUE);
setDisplayedArtboard(blinkingBLUE);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum intakeMode {
SHOOTING,
NO_BELT,
REVERSING,
REVERSE_NOBELT,
OFF
}

Expand Down Expand Up @@ -74,14 +75,17 @@ public void setMode(intakeMode direction) {
intake.setPower(1);
belt.setPower(1);
}else if (direction == intakeMode.SHOOTING){
intake.setPower(0); //TODO change this to 0 if using servo powered intake belt
intake.setPower(0);
belt.setPower(1);
}else if (direction == intakeMode.REVERSING){
intake.setPower(-1);
belt.setPower(-1);
}else if (direction == intakeMode.NO_BELT){
intake.setPower(1);
belt.setPower(0);
}else if (direction == intakeMode.REVERSE_NOBELT){
intake.setPower(-1);
belt.setPower(0);
}else{
intake.setPower(0);
belt.setPower(0);
Expand Down Expand Up @@ -112,6 +116,8 @@ public intakeMode getMode(){
return intakeMode.NO_BELT;
}else if (intakePower == -1 && beltPower == -1){
return intakeMode.REVERSING;
}else if (intakePower == -1 && beltPower == 0){
return intakeMode.REVERSE_NOBELT;
}else{
return intakeMode.OFF;
}
Expand Down
Loading