a lot of changes happened in a galaxy far far away
This commit is contained in:
@@ -133,8 +133,8 @@ public class AutoClose_V3 extends LinearOpMode {
|
|||||||
robot.shooter2.setPower(powPID);
|
robot.shooter2.setPower(powPID);
|
||||||
|
|
||||||
spinPID = servo.setSpinPos(spindexer);
|
spinPID = servo.setSpinPos(spindexer);
|
||||||
robot.spin1.setPower(spinPID);
|
robot.spin1.setPosition(spinPID);
|
||||||
robot.spin2.setPower(-spinPID);
|
robot.spin2.setPosition(-spinPID);
|
||||||
TELE.addData("Velocity", velo);
|
TELE.addData("Velocity", velo);
|
||||||
TELE.addLine("spindex");
|
TELE.addLine("spindex");
|
||||||
TELE.update();
|
TELE.update();
|
||||||
@@ -143,8 +143,8 @@ public class AutoClose_V3 extends LinearOpMode {
|
|||||||
teleStart = drive.localizer.getPose();
|
teleStart = drive.localizer.getPose();
|
||||||
|
|
||||||
if (servo.spinEqual(spindexer)){
|
if (servo.spinEqual(spindexer)){
|
||||||
robot.spin1.setPower(0);
|
robot.spin1.setPosition(0);
|
||||||
robot.spin2.setPower(0);
|
robot.spin2.setPosition(0);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@@ -224,8 +224,8 @@ public class AutoClose_V3 extends LinearOpMode {
|
|||||||
|
|
||||||
if (!servo.spinEqual(position)){
|
if (!servo.spinEqual(position)){
|
||||||
double spinPID = servo.setSpinPos(position);
|
double spinPID = servo.setSpinPos(position);
|
||||||
robot.spin1.setPower(spinPID);
|
robot.spin1.setPosition(spinPID);
|
||||||
robot.spin2.setPower(-spinPID);
|
robot.spin2.setPosition(-spinPID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s1D < 43 && servo.spinEqual(position) && getRuntime() - stamp > 0.5){
|
if (s1D < 43 && servo.spinEqual(position) && getRuntime() - stamp > 0.5){
|
||||||
@@ -259,8 +259,8 @@ public class AutoClose_V3 extends LinearOpMode {
|
|||||||
|
|
||||||
robot.intake.setPower(1);
|
robot.intake.setPower(1);
|
||||||
if ((s1D < 43.0 && s2D < 60.0 && s3D < 33.0) || getRuntime() - stamp > intakeTime) {
|
if ((s1D < 43.0 && s2D < 60.0 && s3D < 33.0) || getRuntime() - stamp > intakeTime) {
|
||||||
robot.spin1.setPower(0);
|
robot.spin1.setPosition(0);
|
||||||
robot.spin2.setPower(0);
|
robot.spin2.setPosition(0);
|
||||||
if (getRuntime() - stamp - intakeTime < 1){
|
if (getRuntime() - stamp - intakeTime < 1){
|
||||||
pow = -2*(getRuntime() - stamp - intakeTime);
|
pow = -2*(getRuntime() - stamp - intakeTime);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ import org.firstinspires.ftc.teamcode.utils.Servos;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Config
|
|
||||||
@Autonomous(preselectTeleOp = "TeleopV3")
|
|
||||||
public class AutoFar_V1 extends LinearOpMode {
|
public class AutoFar_V1 extends LinearOpMode {
|
||||||
Robot robot;
|
Robot robot;
|
||||||
MultipleTelemetry TELE;
|
MultipleTelemetry TELE;
|
||||||
@@ -133,8 +132,8 @@ public class AutoFar_V1 extends LinearOpMode {
|
|||||||
robot.shooter2.setPower(powPID);
|
robot.shooter2.setPower(powPID);
|
||||||
|
|
||||||
spinPID = servo.setSpinPos(spindexer);
|
spinPID = servo.setSpinPos(spindexer);
|
||||||
robot.spin1.setPower(spinPID);
|
robot.spin1.setPosition(spinPID);
|
||||||
robot.spin2.setPower(-spinPID);
|
robot.spin2.setPosition(-spinPID);
|
||||||
TELE.addData("Velocity", velo);
|
TELE.addData("Velocity", velo);
|
||||||
TELE.addLine("spindex");
|
TELE.addLine("spindex");
|
||||||
TELE.update();
|
TELE.update();
|
||||||
@@ -143,8 +142,8 @@ public class AutoFar_V1 extends LinearOpMode {
|
|||||||
teleStart = drive.localizer.getPose();
|
teleStart = drive.localizer.getPose();
|
||||||
|
|
||||||
if (servo.spinEqual(spindexer)){
|
if (servo.spinEqual(spindexer)){
|
||||||
robot.spin1.setPower(0);
|
robot.spin1.setPosition(0);
|
||||||
robot.spin2.setPower(0);
|
robot.spin2.setPosition(0);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@@ -224,8 +223,8 @@ public class AutoFar_V1 extends LinearOpMode {
|
|||||||
|
|
||||||
if (!servo.spinEqual(position)){
|
if (!servo.spinEqual(position)){
|
||||||
double spinPID = servo.setSpinPos(position);
|
double spinPID = servo.setSpinPos(position);
|
||||||
robot.spin1.setPower(spinPID);
|
robot.spin1.setPosition(spinPID);
|
||||||
robot.spin2.setPower(-spinPID);
|
robot.spin2.setPosition(-spinPID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s1D < 43 && servo.spinEqual(position) && getRuntime() - stamp > 0.5){
|
if (s1D < 43 && servo.spinEqual(position) && getRuntime() - stamp > 0.5){
|
||||||
@@ -259,8 +258,8 @@ public class AutoFar_V1 extends LinearOpMode {
|
|||||||
|
|
||||||
robot.intake.setPower(1);
|
robot.intake.setPower(1);
|
||||||
if ((s1D < 43.0 && s2D < 60.0 && s3D < 33.0) || getRuntime() - stamp > intakeTime) {
|
if ((s1D < 43.0 && s2D < 60.0 && s3D < 33.0) || getRuntime() - stamp > intakeTime) {
|
||||||
robot.spin1.setPower(0);
|
robot.spin1.setPosition(0);
|
||||||
robot.spin2.setPower(0);
|
robot.spin2.setPosition(0);
|
||||||
if (getRuntime() - stamp - intakeTime < 1){
|
if (getRuntime() - stamp - intakeTime < 1){
|
||||||
pow = -2*(getRuntime() - stamp - intakeTime);
|
pow = -2*(getRuntime() - stamp - intakeTime);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -182,8 +182,8 @@ public class ProtoAutoClose_V3 extends LinearOpMode {
|
|||||||
velo = flywheel.getVelo();
|
velo = flywheel.getVelo();
|
||||||
|
|
||||||
spinPID = servo.setSpinPos(spindexer);
|
spinPID = servo.setSpinPos(spindexer);
|
||||||
robot.spin1.setPower(spinPID);
|
robot.spin1.setPosition(spinPID);
|
||||||
robot.spin2.setPower(-spinPID);
|
robot.spin2.setPosition(-spinPID);
|
||||||
TELE.addData("Velocity", velo);
|
TELE.addData("Velocity", velo);
|
||||||
TELE.addLine("spindex");
|
TELE.addLine("spindex");
|
||||||
TELE.update();
|
TELE.update();
|
||||||
@@ -192,8 +192,8 @@ public class ProtoAutoClose_V3 extends LinearOpMode {
|
|||||||
teleStart = drive.localizer.getPose();
|
teleStart = drive.localizer.getPose();
|
||||||
|
|
||||||
if (servo.spinEqual(spindexer)) {
|
if (servo.spinEqual(spindexer)) {
|
||||||
robot.spin1.setPower(0);
|
robot.spin1.setPosition(0);
|
||||||
robot.spin2.setPower(0);
|
robot.spin2.setPosition(0);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -240,8 +240,8 @@ public class ProtoAutoClose_V3 extends LinearOpMode {
|
|||||||
|
|
||||||
robot.transferServo.setPosition(transferServo_in);
|
robot.transferServo.setPosition(transferServo_in);
|
||||||
|
|
||||||
robot.spin1.setPower(-spinPow);
|
robot.spin1.setPosition(-spinPow);
|
||||||
robot.spin2.setPower(spinPow);
|
robot.spin2.setPosition(spinPow);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -271,12 +271,12 @@ public class ProtoAutoClose_V3 extends LinearOpMode {
|
|||||||
|
|
||||||
if (ticker % 12 < 6) {
|
if (ticker % 12 < 6) {
|
||||||
|
|
||||||
robot.spin1.setPower(-1);
|
robot.spin1.setPosition(-1);
|
||||||
robot.spin2.setPower(1);
|
robot.spin2.setPosition(1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
robot.spin1.setPower(1);
|
robot.spin1.setPosition(1);
|
||||||
robot.spin2.setPower(-1);
|
robot.spin2.setPosition(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getRuntime() - stamp > jamTime+0.4) {
|
if (getRuntime() - stamp > jamTime+0.4) {
|
||||||
@@ -317,20 +317,20 @@ public class ProtoAutoClose_V3 extends LinearOpMode {
|
|||||||
|
|
||||||
if (ticker % 60 < 12) {
|
if (ticker % 60 < 12) {
|
||||||
|
|
||||||
robot.spin1.setPower(-1);
|
robot.spin1.setPosition(-1);
|
||||||
robot.spin2.setPower(1);
|
robot.spin2.setPosition(1);
|
||||||
|
|
||||||
} else if (ticker % 60 < 30) {
|
} else if (ticker % 60 < 30) {
|
||||||
robot.spin1.setPower(-0.5);
|
robot.spin1.setPosition(-0.5);
|
||||||
robot.spin2.setPower(0.5);
|
robot.spin2.setPosition(0.5);
|
||||||
}
|
}
|
||||||
else if (ticker % 60 < 42) {
|
else if (ticker % 60 < 42) {
|
||||||
robot.spin1.setPower(1);
|
robot.spin1.setPosition(1);
|
||||||
robot.spin2.setPower(-1);
|
robot.spin2.setPosition(-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
robot.spin1.setPower(0.5);
|
robot.spin1.setPosition(0.5);
|
||||||
robot.spin2.setPower(-0.5);
|
robot.spin2.setPosition(-0.5);
|
||||||
}
|
}
|
||||||
robot.intake.setPower(1);
|
robot.intake.setPower(1);
|
||||||
TELE.addData("Reverse?", reverse);
|
TELE.addData("Reverse?", reverse);
|
||||||
@@ -338,11 +338,11 @@ public class ProtoAutoClose_V3 extends LinearOpMode {
|
|||||||
|
|
||||||
if (getRuntime() - stamp > intakeTime) {
|
if (getRuntime() - stamp > intakeTime) {
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
robot.spin1.setPower(-1);
|
robot.spin1.setPosition(-1);
|
||||||
robot.spin2.setPower(1);
|
robot.spin2.setPosition(1);
|
||||||
} else {
|
} else {
|
||||||
robot.spin1.setPower(1);
|
robot.spin1.setPosition(1);
|
||||||
robot.spin2.setPower(-1);
|
robot.spin2.setPosition(-1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,4 +2,5 @@ package org.firstinspires.ftc.teamcode.constants;
|
|||||||
|
|
||||||
public class Color {
|
public class Color {
|
||||||
public static boolean redAlliance = true;
|
public static boolean redAlliance = true;
|
||||||
|
public static double Light0 = 0.28, Light1 = 0.67, Light2 = 0.36, Light3 = 0.5;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,16 +5,18 @@ import com.acmerobotics.dashboard.config.Config;
|
|||||||
@Config
|
@Config
|
||||||
public class ServoPositions {
|
public class ServoPositions {
|
||||||
|
|
||||||
public static double spindexer_intakePos1 = 0.18;
|
public static double spindexer_intakePos1 = 0.13;
|
||||||
|
|
||||||
public static double spindexer_intakePos2 = 0.36;//0.5;
|
public static double spindexer_intakePos2 = 0.33;//0.5;
|
||||||
|
|
||||||
public static double spindexer_intakePos3 = 0.54;//0.66;
|
public static double spindexer_intakePos3 = 0.53;//0.66;
|
||||||
|
|
||||||
public static double spindexer_outtakeBall3 = 0.47;
|
public static double spindexer_outtakeBall3 = 0.8;
|
||||||
|
|
||||||
|
public static double spindexer_outtakeBall2 = 0.6;
|
||||||
|
public static double spindexer_outtakeBall1 = 0.4;
|
||||||
|
public static double spinStartPos = spindexer_outtakeBall1 - 0.08;
|
||||||
|
|
||||||
public static double spindexer_outtakeBall2 = 0.31;
|
|
||||||
public static double spindexer_outtakeBall1 = 0.15;
|
|
||||||
|
|
||||||
public static double transferServo_out = 0.15;
|
public static double transferServo_out = 0.15;
|
||||||
|
|
||||||
|
|||||||
@@ -162,11 +162,11 @@ public class TeleopV2 extends LinearOpMode {
|
|||||||
//TODO: make sure changing position works throughout opmode
|
//TODO: make sure changing position works throughout opmode
|
||||||
if (!servo.spinEqual(spindexPos)){
|
if (!servo.spinEqual(spindexPos)){
|
||||||
spindexPID = servo.setSpinPos(spindexPos);
|
spindexPID = servo.setSpinPos(spindexPos);
|
||||||
robot.spin1.setPower(spindexPID);
|
robot.spin1.setPosition(spindexPID);
|
||||||
robot.spin2.setPower(-spindexPID);
|
robot.spin2.setPosition(-spindexPID);
|
||||||
} else{
|
} else{
|
||||||
robot.spin1.setPower(0);
|
robot.spin1.setPosition(0);
|
||||||
robot.spin2.setPower(0);
|
robot.spin2.setPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//INTAKE:
|
//INTAKE:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.firstinspires.ftc.teamcode.teleop;
|
package org.firstinspires.ftc.teamcode.teleop;
|
||||||
|
|
||||||
import static org.firstinspires.ftc.teamcode.constants.Poses.teleStart;
|
import static org.firstinspires.ftc.teamcode.constants.Poses.teleStart;
|
||||||
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spinStartPos;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_intakePos1;
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_intakePos1;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.transferServo_in;
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.transferServo_in;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.transferServo_out;
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.transferServo_out;
|
||||||
@@ -121,6 +122,7 @@ public class TeleopV3 extends LinearOpMode {
|
|||||||
private int tickerA = 1;
|
private int tickerA = 1;
|
||||||
private boolean transferIn = false;
|
private boolean transferIn = false;
|
||||||
boolean turretInterpolate = false;
|
boolean turretInterpolate = false;
|
||||||
|
public static double spinSpeedIncrease = 0.04;
|
||||||
|
|
||||||
public static double velPrediction(double distance) {
|
public static double velPrediction(double distance) {
|
||||||
if (distance < 30) {
|
if (distance < 30) {
|
||||||
@@ -139,13 +141,15 @@ public class TeleopV3 extends LinearOpMode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runOpMode() throws InterruptedException {
|
public void runOpMode() throws InterruptedException {
|
||||||
|
robot = new Robot(hardwareMap);
|
||||||
|
robot.light.setPosition(0);
|
||||||
List<LynxModule> allHubs = hardwareMap.getAll(LynxModule.class);
|
List<LynxModule> allHubs = hardwareMap.getAll(LynxModule.class);
|
||||||
|
|
||||||
for (LynxModule hub : allHubs) {
|
for (LynxModule hub : allHubs) {
|
||||||
hub.setBulkCachingMode(LynxModule.BulkCachingMode.MANUAL);
|
hub.setBulkCachingMode(LynxModule.BulkCachingMode.MANUAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
robot = new Robot(hardwareMap);
|
|
||||||
TELE = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry());
|
TELE = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry());
|
||||||
servo = new Servos(hardwareMap);
|
servo = new Servos(hardwareMap);
|
||||||
flywheel = new Flywheel(hardwareMap);
|
flywheel = new Flywheel(hardwareMap);
|
||||||
@@ -167,14 +171,16 @@ public class TeleopV3 extends LinearOpMode {
|
|||||||
// robot.limelight.start();
|
// robot.limelight.start();
|
||||||
|
|
||||||
Turret turret = new Turret(robot, TELE, robot.limelight);
|
Turret turret = new Turret(robot, TELE, robot.limelight);
|
||||||
waitForStart();
|
robot.light.setPosition(1);
|
||||||
|
|
||||||
waitForStart();
|
waitForStart();
|
||||||
if (isStopRequested()) return;
|
if (isStopRequested()) return;
|
||||||
|
|
||||||
robot.transferServo.setPosition(transferServo_out);
|
robot.transferServo.setPosition(transferServo_out);
|
||||||
|
|
||||||
while (opModeIsActive()) {
|
while (opModeIsActive()) {
|
||||||
|
// LIGHT COLORS
|
||||||
|
spindexer.ballCounterLight();
|
||||||
|
|
||||||
//DRIVETRAIN:
|
//DRIVETRAIN:
|
||||||
|
|
||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
@@ -233,37 +239,43 @@ public class TeleopV3 extends LinearOpMode {
|
|||||||
|
|
||||||
//TODO: Use color sensors to switch between positions...switch after ball detected in
|
//TODO: Use color sensors to switch between positions...switch after ball detected in
|
||||||
|
|
||||||
|
if (gamepad1.right_bumper){
|
||||||
|
shootAll = false;
|
||||||
|
robot.transferServo.setPosition(transferServo_out);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (autoSpintake) {
|
if (autoSpintake) {
|
||||||
|
|
||||||
if (!servo.spinEqual(spindexPos) && !gamepad1.right_bumper) {
|
if (!servo.spinEqual(spindexPos) && !gamepad1.right_bumper) {
|
||||||
spinCurrentPos = servo.getSpinPos();
|
|
||||||
|
|
||||||
double spindexPID = spinPID.calculate(spinCurrentPos, spindexPos);
|
|
||||||
|
|
||||||
robot.spin1.setPower(spindexPID);
|
robot.spin1.setPosition(spindexPos);
|
||||||
robot.spin2.setPower(-spindexPID);
|
robot.spin2.setPosition(1-spindexPos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamepad1.right_bumper) {
|
if (gamepad1.right_bumper) {
|
||||||
|
|
||||||
|
shootAll = false;
|
||||||
|
|
||||||
intakeTicker++;
|
intakeTicker++;
|
||||||
|
|
||||||
if (intakeTicker % 20 < 2) {
|
// if (intakeTicker % 20 < 2) {
|
||||||
|
//
|
||||||
robot.spin1.setPower(-1);
|
// robot.spin1.setPower(-1);
|
||||||
robot.spin2.setPower(1);
|
// robot.spin2.setPower(1);
|
||||||
|
//
|
||||||
} else if (intakeTicker % 20 < 10) {
|
// } else if (intakeTicker % 20 < 10) {
|
||||||
robot.spin1.setPower(-0.5);
|
// robot.spin1.setPower(-0.5);
|
||||||
robot.spin2.setPower(0.5);
|
// robot.spin2.setPower(0.5);
|
||||||
} else if (intakeTicker % 20 < 12) {
|
// } else if (intakeTicker % 20 < 12) {
|
||||||
robot.spin1.setPower(1);
|
// robot.spin1.setPower(1);
|
||||||
robot.spin2.setPower(-1);
|
// robot.spin2.setPower(-1);
|
||||||
} else {
|
// } else {
|
||||||
robot.spin1.setPower(0.5);
|
// robot.spin1.setPower(0.5);
|
||||||
robot.spin2.setPower(-0.5);
|
// robot.spin2.setPower(-0.5);
|
||||||
}
|
// }
|
||||||
|
|
||||||
robot.intake.setPower(1);
|
robot.intake.setPower(1);
|
||||||
intakeStamp = getRuntime();
|
intakeStamp = getRuntime();
|
||||||
@@ -271,17 +283,9 @@ public class TeleopV3 extends LinearOpMode {
|
|||||||
TELE.update();
|
TELE.update();
|
||||||
} else {
|
} else {
|
||||||
if (!servo.spinEqual(spindexPos)) {
|
if (!servo.spinEqual(spindexPos)) {
|
||||||
spinCurrentPos = servo.getSpinPos();
|
robot.spin1.setPosition(spindexPos);
|
||||||
|
robot.spin2.setPosition(1-spindexPos);
|
||||||
|
|
||||||
double spindexPID = spinPID.calculate(spinCurrentPos, spindexPos);
|
|
||||||
|
|
||||||
robot.spin1.setPower(spindexPID);
|
|
||||||
robot.spin2.setPower(-spindexPID);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
robot.spin1.setPower(0);
|
|
||||||
robot.spin2.setPower(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spindexPos = spindexer_intakePos1;
|
spindexPos = spindexer_intakePos1;
|
||||||
@@ -506,76 +510,76 @@ public class TeleopV3 extends LinearOpMode {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (gamepad1.left_bumper && !enableSpindexerManager) {
|
//if (gamepad1.left_bumper && !enableSpindexerManager) {
|
||||||
|
|
||||||
robot.transferServo.setPosition(transferServo_out);
|
// robot.transferServo.setPosition(transferServo_out);
|
||||||
|
|
||||||
autoSpintake = false;
|
// autoSpintake = false;
|
||||||
|
//
|
||||||
intakeTicker++;
|
// intakeTicker++;
|
||||||
|
//
|
||||||
if (intakeTicker % 10 < 1) {
|
// if (intakeTicker % 10 < 1) {
|
||||||
|
//
|
||||||
robot.spin1.setPower(-1);
|
// robot.spin1.setPower(-1);
|
||||||
robot.spin2.setPower(1);
|
// robot.spin2.setPower(1);
|
||||||
|
//
|
||||||
} else if (intakeTicker % 10 < 5) {
|
// } else if (intakeTicker % 10 < 5) {
|
||||||
robot.spin1.setPower(-0.5);
|
// robot.spin1.setPower(-0.5);
|
||||||
robot.spin2.setPower(0.5);
|
// robot.spin2.setPower(0.5);
|
||||||
} else if (intakeTicker % 10 < 6) {
|
// } else if (intakeTicker % 10 < 6) {
|
||||||
robot.spin1.setPower(1);
|
// robot.spin1.setPower(1);
|
||||||
robot.spin2.setPower(-1);
|
// robot.spin2.setPower(-1);
|
||||||
} else {
|
// } else {
|
||||||
robot.spin1.setPower(0.5);
|
// robot.spin1.setPower(0.5);
|
||||||
robot.spin2.setPower(-0.5);
|
// robot.spin2.setPower(-0.5);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
intake = false;
|
// intake = false;
|
||||||
reject = false;
|
// reject = false;
|
||||||
|
//
|
||||||
robot.intake.setPower(0.5);
|
// robot.intake.setPower(0.5);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (gamepad1.leftBumperWasReleased() && !enableSpindexerManager) {
|
// if (gamepad1.leftBumperWasReleased() && !enableSpindexerManager) {
|
||||||
shootStamp = getRuntime();
|
// shootStamp = getRuntime();
|
||||||
shootAll = true;
|
// shootAll = true;
|
||||||
|
//
|
||||||
shooterTicker = 0;
|
// shooterTicker = 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (shootAll && !enableSpindexerManager) {
|
// if (shootAll && !enableSpindexerManager) {
|
||||||
|
//
|
||||||
TELE.addData("100% works", shootOrder);
|
// TELE.addData("100% works", shootOrder);
|
||||||
|
//
|
||||||
intake = false;
|
// intake = false;
|
||||||
reject = false;
|
// reject = false;
|
||||||
|
//
|
||||||
shooterTicker++;
|
// shooterTicker++;
|
||||||
|
//
|
||||||
spindexPos = spindexer_intakePos1;
|
// spindexPos = spindexer_intakePos1;
|
||||||
|
//
|
||||||
if (getRuntime() - shootStamp < 3.5) {
|
// if (getRuntime() - shootStamp < 3.5) {
|
||||||
|
//
|
||||||
robot.transferServo.setPosition(transferServo_in);
|
// robot.transferServo.setPosition(transferServo_in);
|
||||||
|
//
|
||||||
autoSpintake = false;
|
// autoSpintake = false;
|
||||||
|
//
|
||||||
robot.spin1.setPower(-spinPow);
|
// robot.spin1.setPower(-spinPow);
|
||||||
robot.spin2.setPower(spinPow);
|
// robot.spin2.setPower(spinPow);
|
||||||
|
//
|
||||||
} else {
|
// } else {
|
||||||
robot.transferServo.setPosition(transferServo_out);
|
// robot.transferServo.setPosition(transferServo_out);
|
||||||
spindexPos = spindexer_intakePos1;
|
// spindexPos = spindexer_intakePos1;
|
||||||
|
//
|
||||||
shootAll = false;
|
// shootAll = false;
|
||||||
|
//
|
||||||
autoSpintake = true;
|
// autoSpintake = true;
|
||||||
|
//
|
||||||
robot.transferServo.setPosition(transferServo_out);
|
// robot.transferServo.setPosition(transferServo_out);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (enableSpindexerManager) {
|
if (enableSpindexerManager) {
|
||||||
if (!shootAll) {
|
if (!shootAll) {
|
||||||
@@ -599,6 +603,8 @@ public class TeleopV3 extends LinearOpMode {
|
|||||||
shootAll = true;
|
shootAll = true;
|
||||||
|
|
||||||
shooterTicker = 0;
|
shooterTicker = 0;
|
||||||
|
spindexPos = spinStartPos;// TODO: Change starting position based on desired order to shoot green ball
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shootAll) {
|
if (shootAll) {
|
||||||
@@ -606,17 +612,18 @@ public class TeleopV3 extends LinearOpMode {
|
|||||||
intake = false;
|
intake = false;
|
||||||
reject = false;
|
reject = false;
|
||||||
|
|
||||||
shooterTicker++;
|
|
||||||
|
|
||||||
// TODO: Change starting position based on desired order to shoot green ball
|
|
||||||
spindexPos = spindexer_intakePos1;
|
|
||||||
|
|
||||||
if (getRuntime() - shootStamp < 3.5) {
|
if (getRuntime() - shootStamp < 3.5) {
|
||||||
|
|
||||||
robot.transferServo.setPosition(transferServo_in);
|
if (shooterTicker == 0 && !servo.spinEqual(spindexPos)){
|
||||||
|
robot.spin1.setPosition(spindexPos);
|
||||||
robot.spin1.setPower(-spinPow);
|
robot.spin2.setPosition(1-spindexPos);
|
||||||
robot.spin2.setPower(spinPow);
|
} else {
|
||||||
|
robot.transferServo.setPosition(transferServo_in);
|
||||||
|
shooterTicker++;
|
||||||
|
double prevSpinPos = robot.spin1.getPosition();
|
||||||
|
robot.spin1.setPosition(prevSpinPos + spinSpeedIncrease);
|
||||||
|
robot.spin2.setPosition(1 - prevSpinPos - spinSpeedIncrease);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
robot.transferServo.setPosition(transferServo_out);
|
robot.transferServo.setPosition(transferServo_out);
|
||||||
@@ -624,12 +631,19 @@ public class TeleopV3 extends LinearOpMode {
|
|||||||
|
|
||||||
shootAll = false;
|
shootAll = false;
|
||||||
|
|
||||||
robot.transferServo.setPosition(transferServo_out);
|
|
||||||
|
|
||||||
spindexer.resetSpindexer();
|
spindexer.resetSpindexer();
|
||||||
spindexer.processIntake();
|
spindexer.processIntake();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gamepad1.left_stick_button){
|
||||||
|
robot.transferServo.setPosition(transferServo_out);
|
||||||
|
//spindexPos = spindexer_intakePos1;
|
||||||
|
|
||||||
|
shootAll = false;
|
||||||
|
spindexer.resetSpindexer();
|
||||||
|
spindexer.processIntake();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ import org.firstinspires.ftc.teamcode.utils.Servos;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Config
|
|
||||||
@TeleOp
|
|
||||||
public class IntakeTest extends LinearOpMode {
|
public class IntakeTest extends LinearOpMode {
|
||||||
Robot robot;
|
Robot robot;
|
||||||
MultipleTelemetry TELE;
|
MultipleTelemetry TELE;
|
||||||
@@ -72,19 +71,19 @@ public class IntakeTest extends LinearOpMode {
|
|||||||
initPos = currentPos;
|
initPos = currentPos;
|
||||||
}
|
}
|
||||||
if (reverse){
|
if (reverse){
|
||||||
robot.spin1.setPower(manualPow);
|
robot.spin1.setPosition(manualPow);
|
||||||
robot.spin2.setPower(-manualPow);
|
robot.spin2.setPosition(-manualPow);
|
||||||
} else {
|
} else {
|
||||||
robot.spin1.setPower(-manualPow);
|
robot.spin1.setPosition(-manualPow);
|
||||||
robot.spin2.setPower(manualPow);
|
robot.spin2.setPosition(manualPow);
|
||||||
}
|
}
|
||||||
robot.intake.setPower(1);
|
robot.intake.setPower(1);
|
||||||
stamp = getRuntime();
|
stamp = getRuntime();
|
||||||
TELE.addData("Reverse?", reverse);
|
TELE.addData("Reverse?", reverse);
|
||||||
TELE.update();
|
TELE.update();
|
||||||
} else {
|
} else {
|
||||||
robot.spin1.setPower(0);
|
robot.spin1.setPosition(0);
|
||||||
robot.spin2.setPower(0);
|
robot.spin2.setPosition(0);
|
||||||
|
|
||||||
if (getRuntime() - stamp < 1) {
|
if (getRuntime() - stamp < 1) {
|
||||||
robot.intake.setPower(-(getRuntime() - stamp)*2);
|
robot.intake.setPower(-(getRuntime() - stamp)*2);
|
||||||
@@ -191,15 +190,15 @@ public class IntakeTest extends LinearOpMode {
|
|||||||
|
|
||||||
if (!atTarget) {
|
if (!atTarget) {
|
||||||
powPID = servo.setSpinPos(spindexerPos);
|
powPID = servo.setSpinPos(spindexerPos);
|
||||||
robot.spin1.setPower(powPID);
|
robot.spin1.setPosition(powPID);
|
||||||
robot.spin2.setPower(-powPID);
|
robot.spin2.setPosition(-powPID);
|
||||||
|
|
||||||
steadySpin = false;
|
steadySpin = false;
|
||||||
wasMoving = true; // remember we were moving
|
wasMoving = true; // remember we were moving
|
||||||
stamp = getRuntime();
|
stamp = getRuntime();
|
||||||
} else {
|
} else {
|
||||||
robot.spin1.setPower(0);
|
robot.spin1.setPosition(0);
|
||||||
robot.spin2.setPower(0);
|
robot.spin2.setPosition(0);
|
||||||
steadySpin = true;
|
steadySpin = true;
|
||||||
wasMoving = false;
|
wasMoving = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
|||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.utils.Robot;
|
import org.firstinspires.ftc.teamcode.utils.Robot;
|
||||||
|
|
||||||
@TeleOp
|
|
||||||
@Config
|
|
||||||
public class PIDServoTest extends LinearOpMode {
|
public class PIDServoTest extends LinearOpMode {
|
||||||
|
|
||||||
public static double p = 2, i = 0, d = 0, f = 0;
|
public static double p = 2, i = 0, d = 0, f = 0;
|
||||||
@@ -47,8 +45,8 @@ public class PIDServoTest extends LinearOpMode {
|
|||||||
|
|
||||||
double pid = controller.calculate(pos, target);
|
double pid = controller.calculate(pos, target);
|
||||||
|
|
||||||
robot.spin1.setPower(pid);
|
robot.spin1.setPosition(pid);
|
||||||
robot.spin2.setPower(-pid);
|
robot.spin2.setPosition(-pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
telemetry.addData("pos", pos);
|
telemetry.addData("pos", pos);
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package org.firstinspires.ftc.teamcode.tests;
|
package org.firstinspires.ftc.teamcode.tests;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spinStartPos;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_intakePos1;
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_intakePos1;
|
||||||
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_outtakeBall1;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.transferServo_in;
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.transferServo_in;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.transferServo_out;
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.transferServo_out;
|
||||||
|
import static org.firstinspires.ftc.teamcode.teleop.TeleopV3.spinSpeedIncrease;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
@@ -13,6 +16,7 @@ import com.qualcomm.robotcore.hardware.DcMotorEx;
|
|||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.utils.Flywheel;
|
import org.firstinspires.ftc.teamcode.utils.Flywheel;
|
||||||
import org.firstinspires.ftc.teamcode.utils.Robot;
|
import org.firstinspires.ftc.teamcode.utils.Robot;
|
||||||
|
import org.firstinspires.ftc.teamcode.utils.Servos;
|
||||||
import org.firstinspires.ftc.teamcode.utils.Spindexer;
|
import org.firstinspires.ftc.teamcode.utils.Spindexer;
|
||||||
|
|
||||||
@Config
|
@Config
|
||||||
@@ -36,6 +40,7 @@ public class ShooterTest extends LinearOpMode {
|
|||||||
public static boolean intake = false;
|
public static boolean intake = false;
|
||||||
Robot robot;
|
Robot robot;
|
||||||
Flywheel flywheel;
|
Flywheel flywheel;
|
||||||
|
Servos servo;
|
||||||
|
|
||||||
double shootStamp = 0.0;
|
double shootStamp = 0.0;
|
||||||
boolean shootAll = false;
|
boolean shootAll = false;
|
||||||
@@ -45,6 +50,7 @@ public class ShooterTest extends LinearOpMode {
|
|||||||
public static boolean enableHoodAutoOpen = false;
|
public static boolean enableHoodAutoOpen = false;
|
||||||
public double hoodAdjust = 0.0;
|
public double hoodAdjust = 0.0;
|
||||||
public static double hoodAdjustFactor = 1.0;
|
public static double hoodAdjustFactor = 1.0;
|
||||||
|
private int shooterTicker = 0;
|
||||||
Spindexer spindexer ;
|
Spindexer spindexer ;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,6 +61,7 @@ public class ShooterTest extends LinearOpMode {
|
|||||||
DcMotorEx rightShooter = robot.shooter2;
|
DcMotorEx rightShooter = robot.shooter2;
|
||||||
flywheel = new Flywheel(hardwareMap);
|
flywheel = new Flywheel(hardwareMap);
|
||||||
spindexer = new Spindexer(hardwareMap);
|
spindexer = new Spindexer(hardwareMap);
|
||||||
|
servo = new Servos(hardwareMap);
|
||||||
|
|
||||||
MultipleTelemetry TELE = new MultipleTelemetry(
|
MultipleTelemetry TELE = new MultipleTelemetry(
|
||||||
telemetry, FtcDashboard.getInstance().getTelemetry()
|
telemetry, FtcDashboard.getInstance().getTelemetry()
|
||||||
@@ -95,6 +102,7 @@ public class ShooterTest extends LinearOpMode {
|
|||||||
shootAll = true;
|
shootAll = true;
|
||||||
shoot = false;
|
shoot = false;
|
||||||
robot.transfer.setPower(transferPower);
|
robot.transfer.setPower(transferPower);
|
||||||
|
shooterTicker = 0;
|
||||||
}
|
}
|
||||||
if (shootAll) {
|
if (shootAll) {
|
||||||
|
|
||||||
@@ -103,24 +111,31 @@ public class ShooterTest extends LinearOpMode {
|
|||||||
|
|
||||||
// TODO: Change starting position based on desired order to shoot green ball
|
// TODO: Change starting position based on desired order to shoot green ball
|
||||||
//spindexPos = spindexer_intakePos1;
|
//spindexPos = spindexer_intakePos1;
|
||||||
|
|
||||||
if (getRuntime() - shootStamp < 3.5) {
|
if (getRuntime() - shootStamp < 3.5) {
|
||||||
|
|
||||||
robot.transferServo.setPosition(transferServo_in);
|
if (shooterTicker == 0 && !servo.spinEqual(spinStartPos)){
|
||||||
|
robot.spin1.setPosition(spinStartPos);
|
||||||
|
robot.spin2.setPosition(1-spinStartPos);
|
||||||
|
} else {
|
||||||
|
robot.transferServo.setPosition(transferServo_in);
|
||||||
|
shooterTicker++;
|
||||||
|
double prevSpinPos = robot.spin1.getPosition();
|
||||||
|
robot.spin1.setPosition(prevSpinPos + spinSpeedIncrease);
|
||||||
|
robot.spin2.setPosition(1 - prevSpinPos - spinSpeedIncrease);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
robot.spin1.setPower(-spinPow);
|
|
||||||
robot.spin2.setPower(spinPow);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
robot.transferServo.setPosition(transferServo_out);
|
robot.transferServo.setPosition(transferServo_out);
|
||||||
//spindexPos = spindexer_intakePos1;
|
//spindexPos = spindexer_intakePos1;
|
||||||
|
|
||||||
shootAll = false;
|
shootAll = false;
|
||||||
|
shooterTicker = 0;
|
||||||
|
|
||||||
robot.transferServo.setPosition(transferServo_out);
|
robot.transferServo.setPosition(transferServo_out);
|
||||||
robot.transfer.setPower(0);
|
robot.transfer.setPower(0);
|
||||||
robot.spin1.setPower(0);
|
|
||||||
robot.spin2.setPower(0);
|
|
||||||
|
|
||||||
spindexer.resetSpindexer();
|
spindexer.resetSpindexer();
|
||||||
spindexer.processIntake();
|
spindexer.processIntake();
|
||||||
|
|||||||
@@ -18,14 +18,10 @@ public class PositionalServoProgrammer extends LinearOpMode {
|
|||||||
Servos servo;
|
Servos servo;
|
||||||
|
|
||||||
public static double spindexPos = 0.501;
|
public static double spindexPos = 0.501;
|
||||||
public static double spindexPow = 0.0;
|
|
||||||
public static double spinHoldPow = 0.0;
|
|
||||||
public static double turretPos = 0.501;
|
public static double turretPos = 0.501;
|
||||||
public static double turretPow = 0.0;
|
|
||||||
public static double turrHoldPow = 0.0;
|
|
||||||
public static double transferPos = 0.501;
|
public static double transferPos = 0.501;
|
||||||
public static double hoodPos = 0.501;
|
public static double hoodPos = 0.501;
|
||||||
public static int mode = 0; //0 for positional, 1 for power
|
public static double light = 0.501;
|
||||||
|
|
||||||
Turret turret;
|
Turret turret;
|
||||||
|
|
||||||
@@ -35,22 +31,13 @@ public class PositionalServoProgrammer extends LinearOpMode {
|
|||||||
TELE = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry());
|
TELE = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry());
|
||||||
servo = new Servos(hardwareMap);
|
servo = new Servos(hardwareMap);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
turret = new Turret(robot, TELE, robot.limelight );
|
turret = new Turret(robot, TELE, robot.limelight );
|
||||||
waitForStart();
|
waitForStart();
|
||||||
if (isStopRequested()) return;
|
if (isStopRequested()) return;
|
||||||
while (opModeIsActive()){
|
while (opModeIsActive()){
|
||||||
if (spindexPos != 0.501 && !servo.spinEqual(spindexPos) && mode == 0){
|
if (spindexPos != 0.501 && !servo.spinEqual(spindexPos)){
|
||||||
double pos = servo.setSpinPos(spindexPos);
|
robot.spin1.setPosition(spindexPos);
|
||||||
robot.spin1.setPower(pos);
|
robot.spin2.setPosition(1-spindexPos);
|
||||||
robot.spin2.setPower(-pos);
|
|
||||||
} else if (mode == 0){
|
|
||||||
robot.spin1.setPower(spinHoldPow);
|
|
||||||
robot.spin2.setPower(spinHoldPow);
|
|
||||||
} else {
|
|
||||||
robot.spin1.setPower(spindexPow);
|
|
||||||
robot.spin2.setPower(-spindexPow);
|
|
||||||
}
|
}
|
||||||
if (turretPos != 0.501){
|
if (turretPos != 0.501){
|
||||||
robot.turr1.setPosition(turretPos);
|
robot.turr1.setPosition(turretPos);
|
||||||
@@ -62,6 +49,9 @@ public class PositionalServoProgrammer extends LinearOpMode {
|
|||||||
if (hoodPos != 0.501){
|
if (hoodPos != 0.501){
|
||||||
robot.hood.setPosition(hoodPos);
|
robot.hood.setPosition(hoodPos);
|
||||||
}
|
}
|
||||||
|
if (light !=0.501){
|
||||||
|
robot.light.setPosition(light);
|
||||||
|
}
|
||||||
// To check configuration of spindexer:
|
// To check configuration of spindexer:
|
||||||
// Set "mode" to 1 and spindexPow to 0.1
|
// Set "mode" to 1 and spindexPow to 0.1
|
||||||
// If the spindexer is turning clockwise, the servos are reversed. Swap the configuration of the two servos, DO NOT TOUCH THE ACTUAL CODE
|
// If the spindexer is turning clockwise, the servos are reversed. Swap the configuration of the two servos, DO NOT TOUCH THE ACTUAL CODE
|
||||||
@@ -79,7 +69,6 @@ public class PositionalServoProgrammer extends LinearOpMode {
|
|||||||
TELE.addData("spindexer voltage 2", robot.spin2Pos.getVoltage());
|
TELE.addData("spindexer voltage 2", robot.spin2Pos.getVoltage());
|
||||||
TELE.addData("hood pos", robot.hood.getPosition());
|
TELE.addData("hood pos", robot.hood.getPosition());
|
||||||
TELE.addData("transferServo voltage", robot.transferServoPos.getVoltage());
|
TELE.addData("transferServo voltage", robot.transferServoPos.getVoltage());
|
||||||
TELE.addData("spindexer pow", robot.spin1.getPower());
|
|
||||||
TELE.addData("tpos ", turret.getTurrPos() );
|
TELE.addData("tpos ", turret.getTurrPos() );
|
||||||
TELE.update();
|
TELE.update();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,10 @@ public class Robot {
|
|||||||
public Servo transferServo;
|
public Servo transferServo;
|
||||||
public Servo turr1;
|
public Servo turr1;
|
||||||
public Servo turr2;
|
public Servo turr2;
|
||||||
public CRServo spin1;
|
|
||||||
public CRServo spin2;
|
public Servo spin1;
|
||||||
|
|
||||||
|
public Servo spin2;
|
||||||
public AnalogInput spin1Pos;
|
public AnalogInput spin1Pos;
|
||||||
public AnalogInput spin2Pos;
|
public AnalogInput spin2Pos;
|
||||||
public AnalogInput turr1Pos;
|
public AnalogInput turr1Pos;
|
||||||
@@ -52,6 +54,7 @@ public class Robot {
|
|||||||
public RevColorSensorV3 color2;
|
public RevColorSensorV3 color2;
|
||||||
public RevColorSensorV3 color3;
|
public RevColorSensorV3 color3;
|
||||||
public Limelight3A limelight;
|
public Limelight3A limelight;
|
||||||
|
public Servo light;
|
||||||
|
|
||||||
public Robot(HardwareMap hardwareMap) {
|
public Robot(HardwareMap hardwareMap) {
|
||||||
|
|
||||||
@@ -93,17 +96,14 @@ public class Robot {
|
|||||||
turr1Pos = hardwareMap.get(AnalogInput.class, "t1Pos"); // Encoder of turret plugged in intake port
|
turr1Pos = hardwareMap.get(AnalogInput.class, "t1Pos"); // Encoder of turret plugged in intake port
|
||||||
|
|
||||||
//TODO: check spindexer configuration (both servo and analog input) - check comments in PositionalServoProgrammer
|
//TODO: check spindexer configuration (both servo and analog input) - check comments in PositionalServoProgrammer
|
||||||
spin1 = hardwareMap.get(CRServo.class, "spin1");
|
spin1 = hardwareMap.get(Servo.class, "spin2");
|
||||||
|
|
||||||
spin1Pos = hardwareMap.get(AnalogInput.class, "spin1Pos");
|
spin1Pos = hardwareMap.get(AnalogInput.class, "spin1Pos");
|
||||||
|
|
||||||
spin2 = hardwareMap.get(CRServo.class, "spin2");
|
spin2 = hardwareMap.get(Servo.class, "spin1");
|
||||||
|
|
||||||
spin2Pos = hardwareMap.get(AnalogInput.class, "spin2Pos");
|
spin2Pos = hardwareMap.get(AnalogInput.class, "spin2Pos");
|
||||||
|
|
||||||
spin1.setDirection(DcMotorSimple.Direction.REVERSE);
|
|
||||||
spin2.setDirection(DcMotorSimple.Direction.REVERSE);
|
|
||||||
|
|
||||||
transfer = hardwareMap.get(DcMotorEx.class, "transfer");
|
transfer = hardwareMap.get(DcMotorEx.class, "transfer");
|
||||||
|
|
||||||
transferServo = hardwareMap.get(Servo.class, "transferServo");
|
transferServo = hardwareMap.get(Servo.class, "transferServo");
|
||||||
@@ -125,5 +125,7 @@ public class Robot {
|
|||||||
webcam = hardwareMap.get(WebcamName.class, "Webcam 1");
|
webcam = hardwareMap.get(WebcamName.class, "Webcam 1");
|
||||||
aprilTagProcessor = AprilTagProcessor.easyCreateWithDefaults();
|
aprilTagProcessor = AprilTagProcessor.easyCreateWithDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
light = hardwareMap.get(Servo.class, "light");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ public class Servos {
|
|||||||
// TODO: get PIDF constants
|
// TODO: get PIDF constants
|
||||||
public static double spinP = 2.0, spinI = 0, spinD = 0.3, spinF = 0.02;
|
public static double spinP = 2.0, spinI = 0, spinD = 0.3, spinF = 0.02;
|
||||||
public static double turrP = 1.1, turrI = 0.25, turrD = 0.0625, turrF = 0;
|
public static double turrP = 1.1, turrI = 0.25, turrD = 0.0625, turrF = 0;
|
||||||
public static double spin_scalar = 1.0086;
|
public static double spin_scalar = 1.112;
|
||||||
public static double spin_restPos = 0.0;
|
public static double spin_restPos = 0.155;
|
||||||
public static double turret_scalar = 1.009;
|
public static double turret_scalar = 1.009;
|
||||||
public static double turret_restPos = 0.0;
|
public static double turret_restPos = 0.0;
|
||||||
Robot robot;
|
Robot robot;
|
||||||
@@ -27,16 +27,14 @@ public class Servos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// In the code below, encoder = robot.servo.getVoltage()
|
// In the code below, encoder = robot.servo.getVoltage()
|
||||||
|
// TODO: set the restPos and scalar
|
||||||
public double getSpinPos() {
|
public double getSpinPos() {
|
||||||
return spin_scalar * ((robot.spin1Pos.getVoltage() - spin_restPos) / 3.3);
|
return spin_scalar * ((robot.spin1Pos.getVoltage() - spin_restPos) / 3.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: PID warp so 0 and 1 are usable positions
|
|
||||||
public double setSpinPos(double pos) {
|
public double setSpinPos(double pos) {
|
||||||
spinPID.setPIDF(spinP, spinI, spinD, spinF);
|
|
||||||
|
|
||||||
return spinPID.calculate(this.getSpinPos(), pos);
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean spinEqual(double pos) {
|
public boolean spinEqual(double pos) {
|
||||||
@@ -45,7 +43,6 @@ public class Servos {
|
|||||||
|
|
||||||
public double getTurrPos() {
|
public double getTurrPos() {
|
||||||
return 1.0;
|
return 1.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double setTurrPos(double pos) {
|
public double setTurrPos(double pos) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
|||||||
import com.arcrobotics.ftclib.controller.PIDFController;
|
import com.arcrobotics.ftclib.controller.PIDFController;
|
||||||
import com.qualcomm.robotcore.hardware.HardwareMap;
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.constants.Color.*;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_intakePos1;
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_intakePos1;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_intakePos2;
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_intakePos2;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_intakePos3;
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_intakePos3;
|
||||||
@@ -67,7 +68,7 @@ public class Spindexer {
|
|||||||
SHOOTWAIT,
|
SHOOTWAIT,
|
||||||
SHOOT_ALL_PREP,
|
SHOOT_ALL_PREP,
|
||||||
SHOOT_ALL_READY
|
SHOOT_ALL_READY
|
||||||
};
|
}
|
||||||
|
|
||||||
public IntakeState currentIntakeState = IntakeState.UNKNOWN_START;
|
public IntakeState currentIntakeState = IntakeState.UNKNOWN_START;
|
||||||
public int unknownColorDetect = 0;
|
public int unknownColorDetect = 0;
|
||||||
@@ -75,7 +76,7 @@ public class Spindexer {
|
|||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
GREEN,
|
GREEN,
|
||||||
PURPLE
|
PURPLE
|
||||||
};
|
}
|
||||||
|
|
||||||
class BallPosition {
|
class BallPosition {
|
||||||
boolean isEmpty = true;
|
boolean isEmpty = true;
|
||||||
@@ -247,17 +248,34 @@ public class Spindexer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void moveSpindexerToPos(double pos) {
|
public void moveSpindexerToPos(double pos) {
|
||||||
spinCurrentPos = servos.getSpinPos();
|
robot.spin1.setPosition(pos);
|
||||||
|
robot.spin2.setPosition(1-pos);
|
||||||
double spindexPID = spinPID.calculate(spinCurrentPos, pos);
|
|
||||||
|
|
||||||
robot.spin1.setPower(spindexPID);
|
|
||||||
robot.spin2.setPower(-spindexPID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopSpindexer() {
|
public void stopSpindexer() {
|
||||||
robot.spin1.setPower(0);
|
|
||||||
robot.spin2.setPower(0);
|
}
|
||||||
|
|
||||||
|
public void ballCounterLight(){
|
||||||
|
int counter = 0;
|
||||||
|
if (!ballPositions[0].isEmpty){
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
if (!ballPositions[1].isEmpty){
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
if (!ballPositions[2].isEmpty){
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
if (counter == 3){
|
||||||
|
robot.light.setPosition(Light3);
|
||||||
|
} else if (counter == 2){
|
||||||
|
robot.light.setPosition(Light2);
|
||||||
|
} else if (counter == 1){
|
||||||
|
robot.light.setPosition(Light1);
|
||||||
|
} else {
|
||||||
|
robot.light.setPosition(Light0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFull () {
|
public boolean isFull () {
|
||||||
|
|||||||
Reference in New Issue
Block a user