public static final double RED_BORDER = FIELD_LENGTH/2 + Units.inchesToMeters(167.0);
public static final double BLUE_BORDER = FIELD_LENGTH/2 - Units.inchesToMeters(167.0);
- public static final double LEFT_SIDE_TARGET = FIELD_WIDTH * 0.25;
- public static final double RIGHT_SIDE_TARGET = FIELD_WIDTH * 0.75;
+ public static final double LEFT_SIDE_TARGET = FIELD_WIDTH * 0.10;
+ public static final double RIGHT_SIDE_TARGET = FIELD_WIDTH * 0.90;
/**The coordinate of the climb position */
public static final Pose2d BLUE_CLIMB_LOCATION = new Pose2d(1.5, FIELD_WIDTH/2 - 2.0, new Rotation2d()); // TODO: find this
}
}
+ /**
+ *
+ * @return Whether Y coordinate is in the upper half (left side on blue alliance)
+ */
+ public static boolean isOnLeftSideOfField(Translation2d drivepose){
+ if (drivepose.getY() > FIELD_WIDTH/2){
+ return true;
+ }
+ return false;
+ }
+
public static Translation3d getOppositionTranslation(boolean sideLeft) {
if (sideLeft) {
if (Robot.getAlliance() == Alliance.Blue) {
return ALLIANCE_LEFT_RED;
} else {
// Reversed it so we shoot same side, but probably need to change this
- return ALLIANCE_RIGHT_BLUE;
+ return ALLIANCE_LEFT_BLUE;
}
} else {
if (Robot.getAlliance() == Alliance.Blue) {
return ALLIANCE_RIGHT_RED;
} else {
- return ALLIANCE_LEFT_BLUE;
+ return ALLIANCE_RIGHT_BLUE;
}
}
}
// }));
// Set the hood down -- for safety measures under trench
- controller.get(DPad.LEFT).whileTrue(new InstantCommand(()->{
- hood.setFieldRelativeTarget(Rotation2d.fromDegrees(HoodConstants.MAX_ANGLE), 0.0);
- }, hood));
+ controller.get(DPad.LEFT).onTrue(new InstantCommand(()->{
+ hood.forceHoodDown(true);
+ }, hood)).onFalse(new InstantCommand(()->{
+ hood.forceHoodDown(false);
+ }));
}
}
private boolean calibrating = false;
private Debouncer calibrateDebouncer = new Debouncer(0.5, DebounceType.kRising);
+ private boolean forceHoodDown = false;
+
private HoodIOInputsAutoLogged inputs = new HoodIOInputsAutoLogged();
public Hood(){
return Units.rotationsToDegrees(motor.getPosition().getValueAsDouble()) / HoodConstants.HOOD_GEAR_RATIO;
}
+ public void forceHoodDown(boolean taranNathan){
+ forceHoodDown = taranNathan;
+ }
+
@Override
public void periodic() {
updateInputs();
Logger.processInputs("Hood", inputs);
+ if (forceHoodDown){
+ goalAngle = Rotation2d.fromDegrees(HoodConstants.MAX_ANGLE);
+ goalVelocityRadPerSec = 0.0;
+ }
+
double setpointRad = goalAngle.getRadians();
// calculate shortest angular delta
return !(currentState == CurrentState.TURNING_AROUND) && !(currentState == CurrentState.UNDER_TRENCH); //&& !(currentState == CurrentState.STARTING_UP);
}
- public Translation2d getTarget() {
- return wantedState == WantedState.SHOOTING ?
- FieldConstants.getHubTranslation().toTranslation2d()
- : FieldConstants.getAllianceSideTranslation(true).toTranslation2d();
+ public Translation2d getTarget(Pose2d drivePose) {
+ return wantedState == WantedState.SHOOTING ? FieldConstants.getHubTranslation().toTranslation2d()
+ : (FieldConstants.isOnLeftSideOfField(drivePose.getTranslation())
+ ? FieldConstants.getAllianceSideTranslation(true).toTranslation2d()
+ : FieldConstants.getAllianceSideTranslation(false).toTranslation2d());
}
}
\ No newline at end of file