Working right auto
This commit is contained in:
parent
cc8cf18ff0
commit
3f9e39e45b
|
@ -23,15 +23,18 @@ import org.firstinspires.ftc.teamcode.vision.Detection;
|
||||||
public abstract class AutoBase extends LinearOpMode {
|
public abstract class AutoBase extends LinearOpMode {
|
||||||
public static int DEPOSIT_HEIGHT = 100;
|
public static int DEPOSIT_HEIGHT = 100;
|
||||||
public static double SCORING_DURATION_S = 5f;
|
public static double SCORING_DURATION_S = 5f;
|
||||||
|
public static double APRIL_TAG_RIGHT_DELTA = -8.5;
|
||||||
|
public static double APRIL_TAG_LEFT_DELTA = 4.0;
|
||||||
|
|
||||||
protected Robot robot;
|
protected Robot robot;
|
||||||
protected FtcDashboard dashboard;
|
protected FtcDashboard dashboard;
|
||||||
protected Telemetry dashboardTelemetry;
|
protected Telemetry dashboardTelemetry;
|
||||||
protected CenterStageCommon.PropLocation propLocation;
|
protected CenterStageCommon.PropLocation propLocation;
|
||||||
protected final Pose2d initialPosition;
|
protected final Pose2d initialPosition;
|
||||||
protected final CenterStageCommon.Alliance alliance;
|
protected final CenterStageCommon.Alliance alliance;
|
||||||
protected final Vector2d rendezvous;
|
protected final Pose2d rendezvous;
|
||||||
|
|
||||||
protected AutoBase(CenterStageCommon.Alliance alliance, Pose2d initialPosition, Vector2d rendezvous) {
|
protected AutoBase(CenterStageCommon.Alliance alliance, Pose2d initialPosition, Pose2d rendezvous) {
|
||||||
this.alliance = alliance;
|
this.alliance = alliance;
|
||||||
this.initialPosition = initialPosition;
|
this.initialPosition = initialPosition;
|
||||||
this.rendezvous = rendezvous;
|
this.rendezvous = rendezvous;
|
||||||
|
@ -53,17 +56,26 @@ public abstract class AutoBase extends LinearOpMode {
|
||||||
// If the prop is visible at this point, then it must be in the center (2) position
|
// If the prop is visible at this point, then it must be in the center (2) position
|
||||||
determinePropLocation();
|
determinePropLocation();
|
||||||
|
|
||||||
|
TrajectorySequenceBuilder builder;
|
||||||
switch (this.propLocation) {
|
switch (this.propLocation) {
|
||||||
case Left:
|
case Left:
|
||||||
// TODO Tommy: Place the pixel on the left tape and move to rendezvous position
|
// TODO Tommy: Place the pixel on the left tape and move to rendezvous position
|
||||||
return;
|
return;
|
||||||
case Unknown:
|
case Unknown:
|
||||||
case Center:
|
case Center:
|
||||||
dislodgePropAndPlacePixel();
|
dislodgePropAndPlacePixelCenter();
|
||||||
|
|
||||||
|
builder = this.robot.getTrajectorySequenceBuilder();
|
||||||
|
builder.turn(Math.toRadians(90));
|
||||||
|
this.robot.getDrive().followTrajectorySequence(builder.build());
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
// TODO Tommy: Place the pixel on the right tape and move to rendezvous position
|
dislodgePropAndPlacePixelRight();
|
||||||
return;
|
|
||||||
|
builder = this.robot.getTrajectorySequenceBuilder();
|
||||||
|
builder.lineToLinearHeading(this.rendezvous);
|
||||||
|
this.robot.getDrive().followTrajectorySequence(builder.build());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveToBackstage();
|
moveToBackstage();
|
||||||
|
@ -73,6 +85,19 @@ public abstract class AutoBase extends LinearOpMode {
|
||||||
// TODO Tommy: Park
|
// TODO Tommy: Park
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void dislodgePropAndPlacePixelRight() {
|
||||||
|
TrajectorySequenceBuilder builder = this.robot.getTrajectorySequenceBuilder();
|
||||||
|
builder.lineToLinearHeading(new Pose2d(-54, 17, Math.toRadians(-123)));
|
||||||
|
builder.addDisplacementMarker(10, () -> {
|
||||||
|
this.robot.getClaw().setArmPosition(PICKUP_ARM_MIN);
|
||||||
|
});
|
||||||
|
this.robot.getDrive().followTrajectorySequence(builder.build());
|
||||||
|
this.robot.getClaw().openSync();
|
||||||
|
this.sleep(100);
|
||||||
|
this.robot.getClaw().setArmPosition(PICKUP_ARM_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
private void scorePreloadedPixel() {
|
private void scorePreloadedPixel() {
|
||||||
this.robot.getGantry().setSlideTarget(DEPOSIT_HEIGHT);
|
this.robot.getGantry().setSlideTarget(DEPOSIT_HEIGHT);
|
||||||
this.robot.getGantry().armOut();
|
this.robot.getGantry().armOut();
|
||||||
|
@ -92,23 +117,40 @@ public abstract class AutoBase extends LinearOpMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareToScore() {
|
private void prepareToScore() {
|
||||||
|
// At this point we know that Y = 38
|
||||||
|
// For 2 -> Ydelta = 0
|
||||||
|
// For 3 -> 3 5/8
|
||||||
|
// For 1 -> - 3 5/8
|
||||||
|
double delta = 0;
|
||||||
|
switch (this.propLocation) {
|
||||||
|
case Left:
|
||||||
|
delta = APRIL_TAG_LEFT_DELTA;
|
||||||
|
break;
|
||||||
|
case Unknown:
|
||||||
|
case Center:
|
||||||
|
delta = 0;
|
||||||
|
break;
|
||||||
|
case Right:
|
||||||
|
delta = APRIL_TAG_RIGHT_DELTA;
|
||||||
|
break;
|
||||||
|
}
|
||||||
double distance = this.robot.getCamera().getDistanceToAprilTag(2, 25, 5);
|
double distance = this.robot.getCamera().getDistanceToAprilTag(2, 25, 5);
|
||||||
|
Vector2d target = new Vector2d(this.robot.getDrive().getPoseEstimate().getX() + (distance - SCORING_DISTANCE_FROM_APRIL_TAG), this.robot.getDrive().getPoseEstimate().getY() + delta);
|
||||||
TrajectorySequenceBuilder builder = this.robot.getTrajectorySequenceBuilder();
|
TrajectorySequenceBuilder builder = this.robot.getTrajectorySequenceBuilder();
|
||||||
builder.forward(distance - SCORING_DISTANCE_FROM_APRIL_TAG);
|
builder.lineToConstantHeading(target);
|
||||||
this.robot.getDrive().followTrajectorySequence(builder.build());
|
this.robot.getDrive().followTrajectorySequence(builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveToBackstage() {
|
private void moveToBackstage() {
|
||||||
TrajectorySequenceBuilder builder = this.robot.getTrajectorySequenceBuilder();
|
TrajectorySequenceBuilder builder = this.robot.getTrajectorySequenceBuilder();
|
||||||
builder.turn(Math.toRadians(90));
|
|
||||||
builder.lineToLinearHeading(new Pose2d(36, 11, 0));
|
builder.lineToLinearHeading(new Pose2d(36, 11, 0));
|
||||||
builder.lineToLinearHeading(new Pose2d(36, 38, 0));
|
builder.lineToLinearHeading(new Pose2d(36, 38, 0));
|
||||||
this.robot.getDrive().followTrajectorySequence(builder.build());
|
this.robot.getDrive().followTrajectorySequence(builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dislodgePropAndPlacePixel() {
|
private void dislodgePropAndPlacePixelCenter() {
|
||||||
TrajectorySequenceBuilder builder = this.robot.getTrajectorySequenceBuilder();
|
TrajectorySequenceBuilder builder = this.robot.getTrajectorySequenceBuilder();
|
||||||
builder.lineToConstantHeading(rendezvous);
|
builder.lineToLinearHeading(rendezvous);
|
||||||
builder.addDisplacementMarker(10, () -> {
|
builder.addDisplacementMarker(10, () -> {
|
||||||
this.robot.getClaw().setArmPosition(PICKUP_ARM_MIN);
|
this.robot.getClaw().setArmPosition(PICKUP_ARM_MIN);
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class LeftAuto extends AutoBase {
|
||||||
super(
|
super(
|
||||||
CenterStageCommon.Alliance.Blue,
|
CenterStageCommon.Alliance.Blue,
|
||||||
new Pose2d(-36, 63, Math.toRadians(-90)),
|
new Pose2d(-36, 63, Math.toRadians(-90)),
|
||||||
new Vector2d(-36, 11));
|
new Pose2d(-36, 11));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class Robot {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TrajectorySequenceBuilder getTrajectorySequenceBuilder() {
|
public TrajectorySequenceBuilder getTrajectorySequenceBuilder() {
|
||||||
|
this.drive.update();
|
||||||
return this.drive.trajectorySequenceBuilder(this.drive.getPoseEstimate());
|
return this.drive.trajectorySequenceBuilder(this.drive.getPoseEstimate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,5 +66,5 @@ public class RobotConfig {
|
||||||
public static double DETECTION_LEFT_X = 0;
|
public static double DETECTION_LEFT_X = 0;
|
||||||
public static double DETECTION_CENTER_X = .5;
|
public static double DETECTION_CENTER_X = .5;
|
||||||
public static double DETECTION_RIGHT_X = 1;
|
public static double DETECTION_RIGHT_X = 1;
|
||||||
public static double SCORING_DISTANCE_FROM_APRIL_TAG = 6.5;
|
public static double SCORING_DISTANCE_FROM_APRIL_TAG = 6f;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue