Compare commits
5 Commits
add-sorted
...
9d29e0b56c
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d29e0b56c | |||
| e25b372eca | |||
| 3ab905af0c | |||
| 58c11f5241 | |||
| 3afab333ef |
@@ -337,6 +337,8 @@ public class Auto12BallPedroPathing extends LinearOpMode {
|
|||||||
initializePoses();
|
initializePoses();
|
||||||
follower.setPose(startPose);
|
follower.setPose(startPose);
|
||||||
buildPaths();
|
buildPaths();
|
||||||
|
// turret.switchPipeline(Turret.PipelineMode.OBELISK);
|
||||||
|
robot.limelight.start();
|
||||||
sleep(2000);
|
sleep(2000);
|
||||||
|
|
||||||
// turret.setTurret(turrDefault);
|
// turret.setTurret(turrDefault);
|
||||||
|
|||||||
@@ -326,6 +326,8 @@ public class Auto12Ball_Back_Sorted extends LinearOpMode {
|
|||||||
initializePoses();
|
initializePoses();
|
||||||
follower.setPose(startPose);
|
follower.setPose(startPose);
|
||||||
buildPaths();
|
buildPaths();
|
||||||
|
// turret.switchPipeline(Turret.PipelineMode.OBELISK);
|
||||||
|
robot.limelight.start();
|
||||||
sleep(2000);
|
sleep(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ import org.firstinspires.ftc.teamcode.utils.Spindexer;
|
|||||||
import org.firstinspires.ftc.teamcode.utils.Targeting;
|
import org.firstinspires.ftc.teamcode.utils.Targeting;
|
||||||
import org.firstinspires.ftc.teamcode.utils.Turret;
|
import org.firstinspires.ftc.teamcode.utils.Turret;
|
||||||
|
|
||||||
@Config
|
|
||||||
@Autonomous(preselectTeleOp = "TeleopV3")
|
|
||||||
public class Auto_LT_Close extends LinearOpMode {
|
public class Auto_LT_Close extends LinearOpMode {
|
||||||
public static double shoot0Vel = 2300, shoot0Hood = 0.93;
|
public static double shoot0Vel = 2300, shoot0Hood = 0.93;
|
||||||
public static double velGate0Start = 2700, hoodGate0Start = 0.6;
|
public static double velGate0Start = 2700, hoodGate0Start = 0.6;
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ import org.firstinspires.ftc.teamcode.utils.Spindexer;
|
|||||||
import org.firstinspires.ftc.teamcode.utils.Targeting;
|
import org.firstinspires.ftc.teamcode.utils.Targeting;
|
||||||
import org.firstinspires.ftc.teamcode.utils.Turret;
|
import org.firstinspires.ftc.teamcode.utils.Turret;
|
||||||
|
|
||||||
@Config
|
|
||||||
@Autonomous(preselectTeleOp = "TeleopV3")
|
|
||||||
public class Auto_LT_Far extends LinearOpMode {
|
public class Auto_LT_Far extends LinearOpMode {
|
||||||
public static double shoot0Vel = 3300, shoot0Hood = 0.48;
|
public static double shoot0Vel = 3300, shoot0Hood = 0.48;
|
||||||
double xLeave, yLeave, hLeave;
|
double xLeave, yLeave, hLeave;
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import org.firstinspires.ftc.teamcode.utils.Turret;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Config
|
|
||||||
public class AutoActions {
|
public class AutoActions {
|
||||||
Robot robot;
|
Robot robot;
|
||||||
MultipleTelemetry TELE;
|
MultipleTelemetry TELE;
|
||||||
|
|||||||
@@ -85,9 +85,7 @@ import org.firstinspires.ftc.teamcode.utils.Spindexer;
|
|||||||
import org.firstinspires.ftc.teamcode.utils.Targeting;
|
import org.firstinspires.ftc.teamcode.utils.Targeting;
|
||||||
import org.firstinspires.ftc.teamcode.utils.Turret;
|
import org.firstinspires.ftc.teamcode.utils.Turret;
|
||||||
|
|
||||||
@Disabled
|
|
||||||
@Config
|
|
||||||
@Autonomous(preselectTeleOp = "TeleopV3")
|
|
||||||
public class Auto_LT_Close_12Ball extends LinearOpMode {
|
public class Auto_LT_Close_12Ball extends LinearOpMode {
|
||||||
public static double shoot0Vel = 2300, shoot0Hood = 0.93;
|
public static double shoot0Vel = 2300, shoot0Hood = 0.93;
|
||||||
public static double autoSpinStartPos = 0.2;
|
public static double autoSpinStartPos = 0.2;
|
||||||
|
|||||||
@@ -93,9 +93,7 @@ import org.firstinspires.ftc.teamcode.utils.Turret;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Disabled
|
|
||||||
@Config
|
|
||||||
@Autonomous(preselectTeleOp = "TeleopV3")
|
|
||||||
public class Auto_LT_Close_GateOpen extends LinearOpMode {
|
public class Auto_LT_Close_GateOpen extends LinearOpMode {
|
||||||
public static double shoot0Vel = 2300, shoot0Hood = 0.93;
|
public static double shoot0Vel = 2300, shoot0Hood = 0.93;
|
||||||
public static double autoSpinStartPos = 0.2;
|
public static double autoSpinStartPos = 0.2;
|
||||||
|
|||||||
@@ -82,9 +82,7 @@ import org.firstinspires.ftc.teamcode.utils.Robot;
|
|||||||
import org.firstinspires.ftc.teamcode.utils.Servos;
|
import org.firstinspires.ftc.teamcode.utils.Servos;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@Disabled
|
|
||||||
@Config
|
|
||||||
@Autonomous(preselectTeleOp = "TeleopV3")
|
|
||||||
public class ProtoAutoClose_V3 extends LinearOpMode {
|
public class ProtoAutoClose_V3 extends LinearOpMode {
|
||||||
public static double intake1Time = 2.7;
|
public static double intake1Time = 2.7;
|
||||||
public static double intake2Time = 3.0;
|
public static double intake2Time = 3.0;
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import org.firstinspires.ftc.teamcode.constants.Color;
|
|||||||
import org.firstinspires.ftc.teamcode.pedroPathing.Constants;
|
import org.firstinspires.ftc.teamcode.pedroPathing.Constants;
|
||||||
import org.firstinspires.ftc.teamcode.utilsv2.*;
|
import org.firstinspires.ftc.teamcode.utilsv2.*;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.utilsv2.Turret.limelightUsed;
|
||||||
|
|
||||||
@TeleOp
|
@TeleOp
|
||||||
@Config
|
@Config
|
||||||
public class TeleopV4 extends LinearOpMode {
|
public class TeleopV4 extends LinearOpMode {
|
||||||
@@ -28,9 +30,10 @@ public class TeleopV4 extends LinearOpMode {
|
|||||||
Turret turret;
|
Turret turret;
|
||||||
Flywheel flywheel;
|
Flywheel flywheel;
|
||||||
VelocityCommander commander;
|
VelocityCommander commander;
|
||||||
|
|
||||||
ParkTilter parkTilter;
|
ParkTilter parkTilter;
|
||||||
|
|
||||||
|
public static Pose relocalizePose = new Pose(128, 83, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runOpMode() throws InterruptedException {
|
public void runOpMode() throws InterruptedException {
|
||||||
|
|
||||||
@@ -52,6 +55,7 @@ public class TeleopV4 extends LinearOpMode {
|
|||||||
turret = new Turret(robot);
|
turret = new Turret(robot);
|
||||||
|
|
||||||
parkTilter = new ParkTilter(robot);
|
parkTilter = new ParkTilter(robot);
|
||||||
|
parkTilter.unpark();
|
||||||
|
|
||||||
shooter = new Shooter(robot, TELE, follower, Color.redAlliance, turret, flywheel, commander);
|
shooter = new Shooter(robot, TELE, follower, Color.redAlliance, turret, flywheel, commander);
|
||||||
shooter.setState(Shooter.ShooterState.TRACK_GOAL);
|
shooter.setState(Shooter.ShooterState.TRACK_GOAL);
|
||||||
@@ -59,6 +63,10 @@ public class TeleopV4 extends LinearOpMode {
|
|||||||
spindexerTransferIntake = new SpindexerTransferIntake(robot, TELE, commander);
|
spindexerTransferIntake = new SpindexerTransferIntake(robot, TELE, commander);
|
||||||
spindexerTransferIntake.setSpindexerMode(SpindexerTransferIntake.SpindexerMode.RAPID);
|
spindexerTransferIntake.setSpindexerMode(SpindexerTransferIntake.SpindexerMode.RAPID);
|
||||||
|
|
||||||
|
turret.switchPipeline(Turret.PipelineMode.TRACKING);
|
||||||
|
robot.limelight.start();
|
||||||
|
|
||||||
|
limelightUsed = true;
|
||||||
|
|
||||||
waitForStart();
|
waitForStart();
|
||||||
|
|
||||||
@@ -72,8 +80,26 @@ public class TeleopV4 extends LinearOpMode {
|
|||||||
gamepad1.left_stick_x
|
gamepad1.left_stick_x
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (gamepad1.crossWasPressed()){
|
||||||
|
follower.setPose(relocalizePose);
|
||||||
|
gamepad1.rumble(100);
|
||||||
|
}
|
||||||
|
|
||||||
follower.update();
|
follower.update();
|
||||||
|
|
||||||
|
if (gamepad1.dpadLeftWasPressed()){
|
||||||
|
shooter.setState(Shooter.ShooterState.MANUAL_FLYWHEEL_TRACK_TURR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gamepad1.dpadRightWasPressed()){
|
||||||
|
shooter.setState(Shooter.ShooterState.TRACK_GOAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shooter.getState() == Shooter.ShooterState.MANUAL_FLYWHEEL_TRACK_TURR || shooter.getState() == Shooter.ShooterState.MANUAL){
|
||||||
|
shooter.setFlywheelVelocity(2500);
|
||||||
|
robot.setHoodPos(0.6);
|
||||||
|
robot.setTransferPower(-0.8);
|
||||||
|
}
|
||||||
|
|
||||||
shooter.update(robot.voltage.getVoltage());
|
shooter.update(robot.voltage.getVoltage());
|
||||||
spindexerTransferIntake.update();
|
spindexerTransferIntake.update();
|
||||||
@@ -99,12 +125,15 @@ public class TeleopV4 extends LinearOpMode {
|
|||||||
SpindexerTransferIntake.RapidMode.HOLD_BALLS
|
SpindexerTransferIntake.RapidMode.HOLD_BALLS
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (gamepad1.rightBumperWasPressed()
|
|
||||||
&& state == SpindexerTransferIntake.RapidMode.HOLD_BALLS) {
|
|
||||||
|
|
||||||
spindexerTransferIntake.setRapidMode(
|
if (gamepad1.right_bumper && state != SpindexerTransferIntake.RapidMode.OPEN_GATE && state != SpindexerTransferIntake.RapidMode.SHOOT) {
|
||||||
SpindexerTransferIntake.RapidMode.INTAKE
|
robot.setIntakePower(1);
|
||||||
);
|
}
|
||||||
|
|
||||||
|
if (gamepad2.leftBumperWasPressed()){
|
||||||
|
limelightUsed = false;
|
||||||
|
} else if (gamepad2.rightBumperWasPressed()){
|
||||||
|
limelightUsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamepad1.dpad_down){
|
if (gamepad1.dpad_down){
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
|||||||
import org.firstinspires.ftc.teamcode.utils.AprilTagWebcam;
|
import org.firstinspires.ftc.teamcode.utils.AprilTagWebcam;
|
||||||
import org.firstinspires.ftc.teamcode.utils.Robot;
|
import org.firstinspires.ftc.teamcode.utils.Robot;
|
||||||
|
|
||||||
@Config
|
|
||||||
@TeleOp
|
|
||||||
public class AprilTagWebcamExample extends OpMode {
|
public class AprilTagWebcamExample extends OpMode {
|
||||||
|
|
||||||
MultipleTelemetry TELE;
|
MultipleTelemetry TELE;
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ import com.qualcomm.robotcore.hardware.NormalizedRGBA;
|
|||||||
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
|
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
|
||||||
import org.firstinspires.ftc.teamcode.utils.Robot;
|
import org.firstinspires.ftc.teamcode.utils.Robot;
|
||||||
|
|
||||||
@Config
|
|
||||||
@TeleOp
|
|
||||||
public class ColorTest extends LinearOpMode {
|
public class ColorTest extends LinearOpMode {
|
||||||
Robot robot;
|
Robot robot;
|
||||||
MultipleTelemetry TELE;
|
MultipleTelemetry TELE;
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
|||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.utils.Robot;
|
import org.firstinspires.ftc.teamcode.utils.Robot;
|
||||||
|
|
||||||
@Config
|
|
||||||
@TeleOp
|
|
||||||
public class MotorDirectionDebugger extends LinearOpMode {
|
public class MotorDirectionDebugger extends LinearOpMode {
|
||||||
|
|
||||||
public static double flPower = 0.0;
|
public static double flPower = 0.0;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.firstinspires.ftc.teamcode.tests;
|
|||||||
import static org.firstinspires.ftc.teamcode.constants.Front_Poses.teleStartPoseH;
|
import static org.firstinspires.ftc.teamcode.constants.Front_Poses.teleStartPoseH;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.Front_Poses.teleStartPoseX;
|
import static org.firstinspires.ftc.teamcode.constants.Front_Poses.teleStartPoseX;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.Front_Poses.teleStartPoseY;
|
import static org.firstinspires.ftc.teamcode.constants.Front_Poses.teleStartPoseY;
|
||||||
|
import static org.firstinspires.ftc.teamcode.utilsv2.Turret.limelightUsed;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
@@ -14,6 +15,7 @@ import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
|||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.constants.Color;
|
import org.firstinspires.ftc.teamcode.constants.Color;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.Constants;
|
import org.firstinspires.ftc.teamcode.pedroPathing.Constants;
|
||||||
|
import org.firstinspires.ftc.teamcode.teleop.TeleopV4;
|
||||||
import org.firstinspires.ftc.teamcode.utilsv2.*;
|
import org.firstinspires.ftc.teamcode.utilsv2.*;
|
||||||
|
|
||||||
@TeleOp
|
@TeleOp
|
||||||
@@ -56,6 +58,7 @@ public class NewShooterTest extends LinearOpMode {
|
|||||||
turret = new Turret(robot);
|
turret = new Turret(robot);
|
||||||
|
|
||||||
parkTilter = new ParkTilter(robot);
|
parkTilter = new ParkTilter(robot);
|
||||||
|
parkTilter.unpark();
|
||||||
|
|
||||||
shooter = new Shooter(robot, TELE, follower, Color.redAlliance, turret, flywheel, commander);
|
shooter = new Shooter(robot, TELE, follower, Color.redAlliance, turret, flywheel, commander);
|
||||||
shooter.setState(Shooter.ShooterState.MANUAL_FLYWHEEL_TRACK_TURR);
|
shooter.setState(Shooter.ShooterState.MANUAL_FLYWHEEL_TRACK_TURR);
|
||||||
@@ -63,6 +66,11 @@ public class NewShooterTest extends LinearOpMode {
|
|||||||
spindexerTransferIntake = new SpindexerTransferIntake(robot, TELE, commander);
|
spindexerTransferIntake = new SpindexerTransferIntake(robot, TELE, commander);
|
||||||
spindexerTransferIntake.setSpindexerMode(SpindexerTransferIntake.SpindexerMode.RAPID);
|
spindexerTransferIntake.setSpindexerMode(SpindexerTransferIntake.SpindexerMode.RAPID);
|
||||||
|
|
||||||
|
turret.switchPipeline(Turret.PipelineMode.TRACKING);
|
||||||
|
robot.limelight.start();
|
||||||
|
|
||||||
|
limelightUsed = true;
|
||||||
|
|
||||||
waitForStart();
|
waitForStart();
|
||||||
|
|
||||||
if (isStopRequested()) return;
|
if (isStopRequested()) return;
|
||||||
@@ -75,14 +83,38 @@ public class NewShooterTest extends LinearOpMode {
|
|||||||
gamepad1.left_stick_x
|
gamepad1.left_stick_x
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (gamepad1.crossWasPressed()){
|
||||||
|
follower.setPose(TeleopV4.relocalizePose);
|
||||||
|
gamepad1.rumble(100);
|
||||||
|
}
|
||||||
|
|
||||||
follower.update();
|
follower.update();
|
||||||
|
|
||||||
shooter.setFlywheelVelocity(flywheelVelo);
|
if (gamepad1.dpadLeftWasPressed()){
|
||||||
robot.setHoodPos(hoodPos);
|
shooter.setState(Shooter.ShooterState.MANUAL_FLYWHEEL_TRACK_TURR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gamepad1.dpadRightWasPressed()){
|
||||||
|
shooter.setState(Shooter.ShooterState.TRACK_GOAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shooter.getState() == Shooter.ShooterState.MANUAL_FLYWHEEL_TRACK_TURR || shooter.getState() == Shooter.ShooterState.MANUAL){
|
||||||
|
shooter.setFlywheelVelocity(flywheelVelo);
|
||||||
|
robot.setHoodPos(hoodPos);
|
||||||
|
robot.setTransferPower(transferPower);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// shooter.setTurretPosition(turretPos);
|
// shooter.setTurretPosition(turretPos);
|
||||||
shooter.update(robot.voltage.getVoltage());
|
shooter.update(robot.voltage.getVoltage());
|
||||||
spindexerTransferIntake.update();
|
spindexerTransferIntake.update();
|
||||||
|
|
||||||
|
if (gamepad2.leftBumperWasPressed()){
|
||||||
|
limelightUsed = false;
|
||||||
|
} else if (gamepad2.rightBumperWasPressed()){
|
||||||
|
limelightUsed = true;
|
||||||
|
}
|
||||||
|
|
||||||
SpindexerTransferIntake.RapidMode state = spindexerTransferIntake.getRapidState();
|
SpindexerTransferIntake.RapidMode state = spindexerTransferIntake.getRapidState();
|
||||||
|
|
||||||
if (gamepad1.leftBumperWasPressed() &&
|
if (gamepad1.leftBumperWasPressed() &&
|
||||||
@@ -104,12 +136,8 @@ public class NewShooterTest extends LinearOpMode {
|
|||||||
SpindexerTransferIntake.RapidMode.HOLD_BALLS
|
SpindexerTransferIntake.RapidMode.HOLD_BALLS
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (gamepad1.rightBumperWasPressed()
|
if (gamepad1.right_bumper && state != SpindexerTransferIntake.RapidMode.OPEN_GATE && state != SpindexerTransferIntake.RapidMode.SHOOT) {
|
||||||
&& state == SpindexerTransferIntake.RapidMode.HOLD_BALLS) {
|
robot.setIntakePower(1);
|
||||||
|
|
||||||
spindexerTransferIntake.setRapidMode(
|
|
||||||
SpindexerTransferIntake.RapidMode.INTAKE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamepad1.dpad_down){
|
if (gamepad1.dpad_down){
|
||||||
@@ -123,6 +151,7 @@ public class NewShooterTest extends LinearOpMode {
|
|||||||
TELE.addData("Transfer Power", commander.getTransferPow());
|
TELE.addData("Transfer Power", commander.getTransferPow());
|
||||||
TELE.addData("Theoretical Velocity RPM", commander.getPredictedRPM());
|
TELE.addData("Theoretical Velocity RPM", commander.getPredictedRPM());
|
||||||
TELE.addData("Actual Velocity RPM", flywheel.getAverageVelocity());
|
TELE.addData("Actual Velocity RPM", flywheel.getAverageVelocity());
|
||||||
|
TELE.addData("TX:", turret.getTX());
|
||||||
|
|
||||||
TELE.update();
|
TELE.update();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import org.firstinspires.ftc.teamcode.utils.Spindexer;
|
|||||||
import org.firstinspires.ftc.teamcode.utils.Targeting;
|
import org.firstinspires.ftc.teamcode.utils.Targeting;
|
||||||
import org.firstinspires.ftc.teamcode.utils.Turret;
|
import org.firstinspires.ftc.teamcode.utils.Turret;
|
||||||
|
|
||||||
@Config
|
|
||||||
@TeleOp
|
|
||||||
public class ShooterTest extends LinearOpMode {
|
public class ShooterTest extends LinearOpMode {
|
||||||
public static int mode = 1;
|
public static int mode = 1;
|
||||||
public static double parameter = 0.0;
|
public static double parameter = 0.0;
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ import org.firstinspires.ftc.teamcode.utils.Spindexer;
|
|||||||
import org.firstinspires.ftc.teamcode.utils.Targeting;
|
import org.firstinspires.ftc.teamcode.utils.Targeting;
|
||||||
import org.firstinspires.ftc.teamcode.utils.Turret;
|
import org.firstinspires.ftc.teamcode.utils.Turret;
|
||||||
|
|
||||||
@Config
|
|
||||||
@TeleOp
|
|
||||||
public class SortingTest extends LinearOpMode {
|
public class SortingTest extends LinearOpMode {
|
||||||
Robot robot;
|
Robot robot;
|
||||||
MultipleTelemetry TELE;
|
MultipleTelemetry TELE;
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ import org.firstinspires.ftc.teamcode.pedroPathing.Constants;
|
|||||||
import org.firstinspires.ftc.teamcode.utils.Robot;
|
import org.firstinspires.ftc.teamcode.utils.Robot;
|
||||||
import org.firstinspires.ftc.teamcode.utils.Turret;
|
import org.firstinspires.ftc.teamcode.utils.Turret;
|
||||||
|
|
||||||
@TeleOp
|
|
||||||
@Config
|
|
||||||
public class TurretTest extends LinearOpMode {
|
public class TurretTest extends LinearOpMode {
|
||||||
public static boolean zeroTurr = false;
|
public static boolean zeroTurr = false;
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import org.firstinspires.ftc.teamcode.constants.Color;
|
|||||||
import org.firstinspires.ftc.teamcode.constants.StateEnums.LightState;
|
import org.firstinspires.ftc.teamcode.constants.StateEnums.LightState;
|
||||||
|
|
||||||
|
|
||||||
@Config
|
|
||||||
public final class Light {
|
public final class Light {
|
||||||
|
|
||||||
private static Light instance;
|
private static Light instance;
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
|||||||
|
|
||||||
import org.firstinspires.ftc.vision.apriltag.AprilTagDetection;
|
import org.firstinspires.ftc.vision.apriltag.AprilTagDetection;
|
||||||
|
|
||||||
@TeleOp
|
|
||||||
@Config
|
|
||||||
public class PositionalServoProgrammer extends LinearOpMode {
|
public class PositionalServoProgrammer extends LinearOpMode {
|
||||||
Robot robot;
|
Robot robot;
|
||||||
MultipleTelemetry TELE;
|
MultipleTelemetry TELE;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import com.qualcomm.robotcore.hardware.VoltageSensor;
|
|||||||
import org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName;
|
import org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName;
|
||||||
import org.firstinspires.ftc.vision.apriltag.AprilTagProcessor;
|
import org.firstinspires.ftc.vision.apriltag.AprilTagProcessor;
|
||||||
|
|
||||||
@Config
|
|
||||||
public class Robot {
|
public class Robot {
|
||||||
|
|
||||||
//Initialize Public Components
|
//Initialize Public Components
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.acmerobotics.dashboard.config.Config;
|
|||||||
import com.arcrobotics.ftclib.controller.PIDFController;
|
import com.arcrobotics.ftclib.controller.PIDFController;
|
||||||
import com.qualcomm.robotcore.hardware.HardwareMap;
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
|
||||||
@Config
|
|
||||||
public class Servos {
|
public class Servos {
|
||||||
//PID constants
|
//PID constants
|
||||||
// TODO: get PIDF constants
|
// TODO: get PIDF constants
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import org.firstinspires.ftc.teamcode.teleop.TeleopV3;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Config
|
|
||||||
|
|
||||||
public class Turret {
|
public class Turret {
|
||||||
|
|
||||||
|
|||||||
@@ -43,13 +43,13 @@ public class Shooter {
|
|||||||
|
|
||||||
if (this.red) {
|
if (this.red) {
|
||||||
goalX = 144;
|
goalX = 144;
|
||||||
turretGoalX = 136;
|
turretGoalX = 140;
|
||||||
} else {
|
} else {
|
||||||
goalX = 0;
|
goalX = 0;
|
||||||
turretGoalX = 8;
|
turretGoalX = 8;
|
||||||
}
|
}
|
||||||
goalY = 144;
|
goalY = 144;
|
||||||
turretGoalY = 136;
|
turretGoalY = 132;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double flywheelVelocity = 0.0;
|
private double flywheelVelocity = 0.0;
|
||||||
@@ -71,6 +71,10 @@ public class Shooter {
|
|||||||
this.state = shooterState;
|
this.state = shooterState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ShooterState getState(){
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTurretPosition(double input) {
|
public void setTurretPosition(double input) {
|
||||||
this.turretPosition = input;
|
this.turretPosition = input;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,6 +261,8 @@ public class SpindexerTransferIntake {
|
|||||||
return System.currentTimeMillis() - sortedStateStartTime;
|
return System.currentTimeMillis() - sortedStateStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int greenTicks = 0;
|
||||||
|
private int ballTicks = 0;
|
||||||
public void update() {
|
public void update() {
|
||||||
|
|
||||||
TELE.addData("Sorted State", sortedIntakeStates);
|
TELE.addData("Sorted State", sortedIntakeStates);
|
||||||
@@ -431,15 +433,22 @@ public class SpindexerTransferIntake {
|
|||||||
robot.setIntakePower(1);
|
robot.setIntakePower(1);
|
||||||
robot.setTransferPower(-1);
|
robot.setTransferPower(-1);
|
||||||
if (robot.insideBeam.isPressed() && robot.revSensor.getDistance(DistanceUnit.CM) < sensorDistanceThreshold) {
|
if (robot.insideBeam.isPressed() && robot.revSensor.getDistance(DistanceUnit.CM) < sensorDistanceThreshold) {
|
||||||
//TODO: ADD DELAY OR AVERGE @ DANIEL
|
|
||||||
NormalizedRGBA revColor = robot.revSensor.getNormalizedColors();
|
NormalizedRGBA revColor = robot.revSensor.getNormalizedColors();
|
||||||
if ((revColor.green / (revColor.red + revColor.blue + revColor.green)) > greenThresh) {
|
if ((revColor.green / (revColor.red + revColor.blue + revColor.green)) > greenThresh) {
|
||||||
ballColors[0] = BallStates.GREEN;
|
greenTicks++;
|
||||||
} else {
|
}
|
||||||
ballColors[0] = BallStates.PURPLE;
|
ballTicks++;
|
||||||
|
if (ballTicks > 15) {
|
||||||
|
if (greenTicks > 10){
|
||||||
|
ballColors[0] = BallStates.GREEN;
|
||||||
|
} else {
|
||||||
|
ballColors[0] = BallStates.PURPLE;
|
||||||
|
}
|
||||||
|
robot.setSpinPos(ServoPositions.spindexer_A2);
|
||||||
|
setSortedIntakeMode(SortedIntakeStates.DELAY_1);
|
||||||
|
ballTicks = 0;
|
||||||
|
greenTicks = 0;
|
||||||
}
|
}
|
||||||
robot.setSpinPos(ServoPositions.spindexer_A2);
|
|
||||||
setSortedIntakeMode(SortedIntakeStates.DELAY_1);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DELAY_1:
|
case DELAY_1:
|
||||||
@@ -449,17 +458,27 @@ public class SpindexerTransferIntake {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INTAKE_2:
|
case INTAKE_2:
|
||||||
|
robot.setIntakePower(1);
|
||||||
|
robot.setTransferPower(-1);
|
||||||
robot.setIntakePower(1);
|
robot.setIntakePower(1);
|
||||||
robot.setTransferPower(-1);
|
robot.setTransferPower(-1);
|
||||||
if (robot.insideBeam.isPressed() && robot.revSensor.getDistance(DistanceUnit.CM) < sensorDistanceThreshold) {
|
if (robot.insideBeam.isPressed() && robot.revSensor.getDistance(DistanceUnit.CM) < sensorDistanceThreshold) {
|
||||||
NormalizedRGBA revColor = robot.revSensor.getNormalizedColors();
|
NormalizedRGBA revColor = robot.revSensor.getNormalizedColors();
|
||||||
if ((revColor.green / (revColor.red + revColor.blue + revColor.green)) > greenThresh) {
|
if ((revColor.green / (revColor.red + revColor.blue + revColor.green)) > greenThresh) {
|
||||||
ballColors[1] = BallStates.GREEN;
|
greenTicks++;
|
||||||
} else {
|
}
|
||||||
ballColors[1] = BallStates.PURPLE;
|
ballTicks++;
|
||||||
|
if (ballTicks > 15) {
|
||||||
|
if (greenTicks > 10){
|
||||||
|
ballColors[0] = BallStates.GREEN;
|
||||||
|
} else {
|
||||||
|
ballColors[0] = BallStates.PURPLE;
|
||||||
|
}
|
||||||
|
robot.setSpinPos(ServoPositions.spindexer_A3);
|
||||||
|
setSortedIntakeMode(SortedIntakeStates.DELAY_2);
|
||||||
|
ballTicks = 0;
|
||||||
|
greenTicks = 0;
|
||||||
}
|
}
|
||||||
robot.setSpinPos(ServoPositions.spindexer_A3);
|
|
||||||
setSortedIntakeMode(SortedIntakeStates.DELAY_2);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DELAY_2:
|
case DELAY_2:
|
||||||
@@ -481,17 +500,25 @@ public class SpindexerTransferIntake {
|
|||||||
if (robot.insideBeam.isPressed() && robot.revSensor.getDistance(DistanceUnit.CM) < sensorDistanceThreshold) {
|
if (robot.insideBeam.isPressed() && robot.revSensor.getDistance(DistanceUnit.CM) < sensorDistanceThreshold) {
|
||||||
NormalizedRGBA revColor = robot.revSensor.getNormalizedColors();
|
NormalizedRGBA revColor = robot.revSensor.getNormalizedColors();
|
||||||
if ((revColor.green / (revColor.red + revColor.blue + revColor.green)) > greenThresh) {
|
if ((revColor.green / (revColor.red + revColor.blue + revColor.green)) > greenThresh) {
|
||||||
ballColors[2] = BallStates.GREEN;
|
greenTicks++;
|
||||||
} else {
|
}
|
||||||
ballColors[2] = BallStates.PURPLE;
|
ballTicks++;
|
||||||
|
if (ballTicks > 15) {
|
||||||
|
if (greenTicks > 10){
|
||||||
|
ballColors[0] = BallStates.GREEN;
|
||||||
|
} else {
|
||||||
|
ballColors[0] = BallStates.PURPLE;
|
||||||
|
}
|
||||||
|
setSortedIntakeMode(SortedIntakeStates.REVERSE);
|
||||||
|
ballTicks = 0;
|
||||||
|
greenTicks = 0;
|
||||||
}
|
}
|
||||||
setSortedIntakeMode(SortedIntakeStates.REVERSE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REVERSE:
|
case REVERSE:
|
||||||
robot.setTransferPower(-0.3);
|
robot.setTransferPower(-0.3);
|
||||||
robot.setIntakePower(-0.1);
|
robot.setIntakePower(-0.1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package org.firstinspires.ftc.teamcode.utilsv2;
|
package org.firstinspires.ftc.teamcode.utilsv2;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
|
import com.arcrobotics.ftclib.controller.PIDController;
|
||||||
import com.qualcomm.hardware.limelightvision.LLResult;
|
import com.qualcomm.hardware.limelightvision.LLResult;
|
||||||
import com.qualcomm.hardware.limelightvision.LLResultTypes;
|
import com.qualcomm.hardware.limelightvision.LLResultTypes;
|
||||||
import com.qualcomm.robotcore.util.Range;
|
import com.qualcomm.robotcore.util.Range;
|
||||||
|
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.constants.Color;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Config
|
@Config
|
||||||
@@ -16,6 +20,19 @@ public class Turret {
|
|||||||
private final double neutralPosition = 0.51;
|
private final double neutralPosition = 0.51;
|
||||||
private final double turretMin = 0.05;
|
private final double turretMin = 0.05;
|
||||||
private final double turretMax = 0.95;
|
private final double turretMax = 0.95;
|
||||||
|
public static boolean limelightUsed = true;
|
||||||
|
public static double B_PID_P = 0.0003, B_PID_I = 0.0, B_PID_D = 0.00003;
|
||||||
|
LLResult result;
|
||||||
|
PIDController bearingPID;
|
||||||
|
boolean bearingAligned = false;
|
||||||
|
public int LL_COAST_TICKS = 60;
|
||||||
|
public static double TARGET_POSITION_TOLERANCE = 0.5;
|
||||||
|
public static double alphaTX = 0.5;
|
||||||
|
private double targetTx = 0;
|
||||||
|
private double currentTrackOffset = 0;
|
||||||
|
private double llCoast = 0;
|
||||||
|
private double servoAngle = 0.51;
|
||||||
|
double tx = 0.0;
|
||||||
private final double hVelK = 0; // TODO: Tune
|
private final double hVelK = 0; // TODO: Tune
|
||||||
private final double xVelK = 0; // TODO: Tune
|
private final double xVelK = 0; // TODO: Tune
|
||||||
private final double xAccK = 0; // TODO: Tune
|
private final double xAccK = 0; // TODO: Tune
|
||||||
@@ -28,6 +45,7 @@ public class Turret {
|
|||||||
|
|
||||||
public Turret(Robot rob) {
|
public Turret(Robot rob) {
|
||||||
this.robot = rob;
|
this.robot = rob;
|
||||||
|
bearingPID = new PIDController(B_PID_P, B_PID_I, B_PID_D);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double wrapAngle(double angle) {
|
private double wrapAngle(double angle) {
|
||||||
@@ -36,6 +54,42 @@ public class Turret {
|
|||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void limelightRead() { // only for tracking purposes, not general reads
|
||||||
|
switchPipeline(PipelineMode.TRACKING);
|
||||||
|
result = robot.limelight.getLatestResult();
|
||||||
|
tx = 1000;
|
||||||
|
if (result != null) {
|
||||||
|
if (result.isValid()) {
|
||||||
|
tx = result.getTx();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTX(){return tx;}
|
||||||
|
|
||||||
|
public enum PipelineMode{
|
||||||
|
OBELISK,
|
||||||
|
TRACKING
|
||||||
|
}
|
||||||
|
|
||||||
|
private int prevPipeline = 0;
|
||||||
|
public void switchPipeline(PipelineMode pipelineMode){
|
||||||
|
int pipeline = 0;
|
||||||
|
if (pipelineMode == PipelineMode.OBELISK){
|
||||||
|
pipeline = 1;
|
||||||
|
} else if (pipelineMode == PipelineMode.TRACKING){
|
||||||
|
if (Color.redAlliance){
|
||||||
|
pipeline = 4;
|
||||||
|
} else {
|
||||||
|
pipeline = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pipeline == 0){prevPipeline = 0;}
|
||||||
|
if (pipeline != prevPipeline){
|
||||||
|
robot.limelight.pipelineSwitch(pipeline);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void trackObelisk(double dx, double dy, double h) {
|
public void trackObelisk(double dx, double dy, double h) {
|
||||||
|
|
||||||
double heading = wrapAngle(h);
|
double heading = wrapAngle(h);
|
||||||
@@ -64,8 +118,8 @@ public class Turret {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int detectObelisk() {
|
private int detectObelisk() {
|
||||||
robot.limelight.pipelineSwitch(1);
|
switchPipeline(PipelineMode.OBELISK);
|
||||||
LLResult result = robot.limelight.getLatestResult();
|
result = robot.limelight.getLatestResult();
|
||||||
if (result != null && result.isValid()) {
|
if (result != null && result.isValid()) {
|
||||||
List<LLResultTypes.FiducialResult> fiducials = result.getFiducialResults();
|
List<LLResultTypes.FiducialResult> fiducials = result.getFiducialResults();
|
||||||
double prevTx = -1000;
|
double prevTx = -1000;
|
||||||
@@ -81,14 +135,14 @@ public class Turret {
|
|||||||
|
|
||||||
public void manual (double pos) {
|
public void manual (double pos) {
|
||||||
robot.setTurretPos(pos);
|
robot.setTurretPos(pos);
|
||||||
|
|
||||||
}
|
}
|
||||||
// 1.545
|
|
||||||
|
|
||||||
public void trackGoal(double dx, double dy, double h, double hVel, double xVel, double xAcc, double yVel, double yAcc) {
|
public void trackGoal(double dx, double dy, double h, double hVel, double xVel, double xAcc, double yVel, double yAcc) {
|
||||||
// dx, dy, dz is target - robot
|
// dx, dy, dz is target - robot
|
||||||
// h is the raw heading where 0 degrees is positive x in the system of x, y
|
// h is the raw heading where 0 degrees is positive x in the system of x, y
|
||||||
|
|
||||||
|
bearingPID = new PIDController(B_PID_P, B_PID_I, B_PID_D); // Keep when debugging/tuning, comment out when doing teleop
|
||||||
|
|
||||||
double predictedDx = dx - (xVel * xVelK) - (0.5 * xAcc * xAccK); // Negative bc dx = target - robot
|
double predictedDx = dx - (xVel * xVelK) - (0.5 * xAcc * xAccK); // Negative bc dx = target - robot
|
||||||
double predictedDy = dy - (yVel * yVelK) - (0.5 * yAcc * yAccK); // Negative bc dy = target - robot
|
double predictedDy = dy - (yVel * yVelK) - (0.5 * yAcc * yAccK); // Negative bc dy = target - robot
|
||||||
double predictedH = h + (hVel * hVelK); // Positive bc h = robot heading
|
double predictedH = h + (hVel * hVelK); // Positive bc h = robot heading
|
||||||
@@ -98,11 +152,34 @@ public class Turret {
|
|||||||
double fieldRelativeHeading = Math.atan2(predictedDy, predictedDx);
|
double fieldRelativeHeading = Math.atan2(predictedDy, predictedDx);
|
||||||
|
|
||||||
double angleDelta = fieldRelativeHeading - predictedH;
|
double angleDelta = fieldRelativeHeading - predictedH;
|
||||||
angleDelta = wrapAngle(angleDelta);
|
angleDelta = wrapAngle(angleDelta) / (2.0 * Math.PI);
|
||||||
|
|
||||||
double servoTicksFromNeutral = (angleDelta / (2.0 * Math.PI)) * (2.0 * servoTicksPer180);
|
double bearingOffset = 0;
|
||||||
|
if (limelightUsed && servoAngle > turretMin && servoAngle < turretMax){
|
||||||
|
limelightRead();
|
||||||
|
if (result.isValid() && tx < 100){
|
||||||
|
targetTx = (tx*alphaTX)+(targetTx*(1-alphaTX));
|
||||||
|
bearingAligned = Math.abs(targetTx) < TARGET_POSITION_TOLERANCE;
|
||||||
|
if (!bearingAligned){
|
||||||
|
bearingOffset = (bearingPID.calculate(targetTx, 0.0));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
targetTx = 0;
|
||||||
|
bearingOffset = 0;
|
||||||
|
}
|
||||||
|
currentTrackOffset += bearingOffset;
|
||||||
|
llCoast = LL_COAST_TICKS;
|
||||||
|
} else {
|
||||||
|
if (llCoast <= 0){
|
||||||
|
currentTrackOffset = 0;
|
||||||
|
} else {
|
||||||
|
llCoast--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double servoAngle = neutralPosition + servoTicksFromNeutral;
|
double servoTicksFromNeutral = (angleDelta+currentTrackOffset) * (2.0 * servoTicksPer180);
|
||||||
|
|
||||||
|
servoAngle = neutralPosition + servoTicksFromNeutral;
|
||||||
|
|
||||||
servoAngle = Range.clip(servoAngle, turretMin, turretMax);
|
servoAngle = Range.clip(servoAngle, turretMin, turretMax);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user