stash
This commit is contained in:
@@ -18,6 +18,7 @@ import com.acmerobotics.dashboard.config.Config;
|
|||||||
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
import com.acmerobotics.roadrunner.ParallelAction;
|
import com.acmerobotics.roadrunner.ParallelAction;
|
||||||
import com.acmerobotics.roadrunner.Pose2d;
|
import com.acmerobotics.roadrunner.Pose2d;
|
||||||
|
import com.acmerobotics.roadrunner.SequentialAction;
|
||||||
import com.acmerobotics.roadrunner.TrajectoryActionBuilder;
|
import com.acmerobotics.roadrunner.TrajectoryActionBuilder;
|
||||||
import com.acmerobotics.roadrunner.TranslationalVelConstraint;
|
import com.acmerobotics.roadrunner.TranslationalVelConstraint;
|
||||||
import com.acmerobotics.roadrunner.Vector2d;
|
import com.acmerobotics.roadrunner.Vector2d;
|
||||||
@@ -62,6 +63,12 @@ public class Auto_LT_Close extends LinearOpMode {
|
|||||||
public static double shoot3Time = 2.5;
|
public static double shoot3Time = 2.5;
|
||||||
public static double colorSenseTime = 1.2;
|
public static double colorSenseTime = 1.2;
|
||||||
public int motif = 0;
|
public int motif = 0;
|
||||||
|
public static double xShoot0 = 40, yShoot0 = 0.1, hShoot0 = 0.1;
|
||||||
|
public static double waitToShoot0 = 1.1;
|
||||||
|
public static double waitToPickupGate2 = 0.5;
|
||||||
|
public static double pickupStackGateSpeed = 23;
|
||||||
|
public static double intake2TimeGate = 6;
|
||||||
|
public static double xShootGate = 40, yShootGate = 0.2, hShootGate = 0.2;
|
||||||
|
|
||||||
Robot robot;
|
Robot robot;
|
||||||
MultipleTelemetry TELE;
|
MultipleTelemetry TELE;
|
||||||
@@ -93,6 +100,7 @@ public class Auto_LT_Close extends LinearOpMode {
|
|||||||
|
|
||||||
int ballCycles = 3;
|
int ballCycles = 3;
|
||||||
int prevMotif = 0;
|
int prevMotif = 0;
|
||||||
|
boolean gateCycle = true;
|
||||||
|
|
||||||
|
|
||||||
// initialize path variables here
|
// initialize path variables here
|
||||||
@@ -103,6 +111,7 @@ public class Auto_LT_Close extends LinearOpMode {
|
|||||||
TrajectoryActionBuilder shoot2 = null;
|
TrajectoryActionBuilder shoot2 = null;
|
||||||
TrajectoryActionBuilder pickup3 = null;
|
TrajectoryActionBuilder pickup3 = null;
|
||||||
TrajectoryActionBuilder shoot3 = null;
|
TrajectoryActionBuilder shoot3 = null;
|
||||||
|
TrajectoryActionBuilder shoot0ToPickup2 = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runOpMode() throws InterruptedException {
|
public void runOpMode() throws InterruptedException {
|
||||||
@@ -274,7 +283,7 @@ public class Auto_LT_Close extends LinearOpMode {
|
|||||||
.strafeToLinearHeading(new Vector2d(x3b, y3b), Math.toRadians(h3b),
|
.strafeToLinearHeading(new Vector2d(x3b, y3b), Math.toRadians(h3b),
|
||||||
new TranslationalVelConstraint(pickup1Speed));
|
new TranslationalVelConstraint(pickup1Speed));
|
||||||
|
|
||||||
if (ballCycles < 3){
|
if (ballCycles < 3 || gateCycle){
|
||||||
shoot2 = drive.actionBuilder(new Pose2d(x3b, y3b, Math.toRadians(h3b)))
|
shoot2 = drive.actionBuilder(new Pose2d(x3b, y3b, Math.toRadians(h3b)))
|
||||||
.strafeToLinearHeading(new Vector2d(xLeave, yLeave), Math.toRadians(hLeave));
|
.strafeToLinearHeading(new Vector2d(xLeave, yLeave), Math.toRadians(hLeave));
|
||||||
} else {
|
} else {
|
||||||
@@ -290,6 +299,13 @@ public class Auto_LT_Close extends LinearOpMode {
|
|||||||
shoot3 = drive.actionBuilder(new Pose2d(x4b, y4b, Math.toRadians(h4b)))
|
shoot3 = drive.actionBuilder(new Pose2d(x4b, y4b, Math.toRadians(h4b)))
|
||||||
.strafeToLinearHeading(new Vector2d(xLeave, yLeave), Math.toRadians(hLeave));
|
.strafeToLinearHeading(new Vector2d(xLeave, yLeave), Math.toRadians(hLeave));
|
||||||
|
|
||||||
|
shoot0ToPickup2 = drive.actionBuilder(new Pose2d(0,0,0))
|
||||||
|
.strafeToLinearHeading(new Vector2d(xShoot0, yShoot0), Math.toRadians(hShoot0))
|
||||||
|
.waitSeconds(waitToPickupGate2)
|
||||||
|
.strafeToLinearHeading(new Vector2d(x3a, y3a), Math.toRadians(h3a))
|
||||||
|
.strafeToLinearHeading(new Vector2d(x3b, y3b), Math.toRadians(h3b),
|
||||||
|
new TranslationalVelConstraint(pickupStackGateSpeed));
|
||||||
|
|
||||||
TELE.addData("Red?", redAlliance);
|
TELE.addData("Red?", redAlliance);
|
||||||
TELE.addData("Turret Default", turrDefault);
|
TELE.addData("Turret Default", turrDefault);
|
||||||
TELE.addData("Ball Cycles", ballCycles);
|
TELE.addData("Ball Cycles", ballCycles);
|
||||||
@@ -305,22 +321,26 @@ public class Auto_LT_Close extends LinearOpMode {
|
|||||||
|
|
||||||
robot.transfer.setPower(1);
|
robot.transfer.setPower(1);
|
||||||
|
|
||||||
startAuto();
|
if (gateCycle){
|
||||||
shoot();
|
shoot0Gate();
|
||||||
|
} else {
|
||||||
if (ballCycles > 0){
|
startAuto();
|
||||||
cycleStackClose();
|
|
||||||
shoot();
|
shoot();
|
||||||
}
|
|
||||||
|
|
||||||
if (ballCycles > 1){
|
if (ballCycles > 0){
|
||||||
cycleStackMiddle();
|
cycleStackClose();
|
||||||
shoot();
|
shoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ballCycles > 2){
|
if (ballCycles > 1){
|
||||||
cycleStackFar();
|
cycleStackMiddle();
|
||||||
shoot();
|
shoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ballCycles > 2){
|
||||||
|
cycleStackFar();
|
||||||
|
shoot();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (opModeIsActive()) {
|
while (opModeIsActive()) {
|
||||||
@@ -515,4 +535,30 @@ public class Auto_LT_Close extends LinearOpMode {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void shoot0Gate(){
|
||||||
|
Actions.runBlocking(
|
||||||
|
new ParallelAction(
|
||||||
|
shoot0ToPickup2.build(),
|
||||||
|
new SequentialAction(
|
||||||
|
new ParallelAction(
|
||||||
|
autoActions.Wait(waitToShoot0),
|
||||||
|
autoActions.manageShooterAuto(
|
||||||
|
waitToShoot0,
|
||||||
|
xShoot0,
|
||||||
|
yShoot0,
|
||||||
|
hShoot0
|
||||||
|
)
|
||||||
|
),
|
||||||
|
autoActions.shootAllAuto(shootAllTime, spindexerSpeedIncrease),
|
||||||
|
autoActions.intake(
|
||||||
|
intake2TimeGate,
|
||||||
|
xShootGate,
|
||||||
|
yShootGate,
|
||||||
|
hShootGate
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -439,6 +439,23 @@ public class AutoActions{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Action Wait(double time){
|
||||||
|
return new Action() {
|
||||||
|
boolean ticker = false;
|
||||||
|
double stamp = 0.0;
|
||||||
|
@Override
|
||||||
|
public boolean run(@NonNull TelemetryPacket telemetryPacket) {
|
||||||
|
if (!ticker){
|
||||||
|
stamp = System.currentTimeMillis();
|
||||||
|
ticker = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (System.currentTimeMillis() - stamp < time * 1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user