private Drivetrain drivetrain;
private TurretVision turretVision;
- public boolean SOTM;
-
double fieldAngleRad;
double turretSetpoint;
double adjustedSetpoint;
double yawToTag;
private boolean turretVisionEnabled = false;
+ private boolean SOTM = true;
- public TurretAutoShoot(Turret turret, Drivetrain drivetrain, TurretVision turretVision, boolean SOTM){
+ public TurretAutoShoot(Turret turret, Drivetrain drivetrain, TurretVision turretVision){
this.turret = turret;
this.drivetrain = drivetrain;
this.turretVision = turretVision;
- this.SOTM = SOTM;
-
addRequirements(turret);
}
- public TurretAutoShoot(Turret turret, Drivetrain drivetrain, boolean SOTM){
- this(turret, drivetrain, null, SOTM);
- this.SOTM = SOTM;
+ public TurretAutoShoot(Turret turret, Drivetrain drivetrain){
+ this(turret, drivetrain, null);
}
public void updateTurretSetpoint() {
double D_x;
if (SOTM) {
ChassisSpeeds robotRelVel = drivetrain.getChassisSpeeds();
- fieldRelVel = ChassisSpeeds.fromRobotRelativeSpeeds(robotRelVel, drivetrain.getYaw());
- double xVel = chassisSpeed.vxMetersPerSecond;
- double yVel = chassisSpeed.vyMetersPerSecond;
+ ChassisSpeeds fieldRelVel = ChassisSpeeds.fromRobotRelativeSpeeds(robotRelVel, drivetrain.getYaw());
+ double xVel = fieldRelVel.vxMetersPerSecond;
+ double yVel = fieldRelVel.vyMetersPerSecond;
- D_y = target.getY() - drivepose.getY() + (0.92) * yVel;
- D_x = target.getX() - drivepose.getX() + (0.92) * xVel;
+ D_y = target.getY() - drivepose.getY() - (0.92) * yVel;
+ D_x = target.getX() - drivepose.getX() - (0.92) * xVel;
} else {
D_y = target.getY() - drivepose.getY();
D_x = target.getX() - drivepose.getX();
@Override
public void end(boolean interrupted) {
-
+ turret.setSetpoint(0, 0);
}
private Command turretAutoShoot;
private TurretJoyStickAim turretJoyStickAim;
- private boolean SOTM;
-
public PS5ControllerDriverConfig(Drivetrain drive, Shooter shooter, Turret turret) {
super(drive);
this.shooter = shooter;
this.turret = turret;
- SOTM = false;
}
public void configureControls() {
new Rotation2d(Robot.getAlliance() == Alliance.Blue ? 0 : Math.PI)
)));
- driver.get(PS5Button.MUTE).onTrue(new InstantCommand(() -> toggleSOTM()));
-
// Cancel commands
driver.get(PS5Button.RIGHT_TRIGGER).onTrue(new InstantCommand(()->{
getDrivetrain().setIsAlign(false);
if (turretAutoShoot != null && turretAutoShoot.isScheduled()){
turretAutoShoot.cancel();
} else{
- turretAutoShoot = new TurretAutoShoot(turret, getDrivetrain(), SOTM);
+ turretAutoShoot = new TurretAutoShoot(turret, getDrivetrain());
CommandScheduler.getInstance().schedule(turretAutoShoot);
}
})
public void endRumble(){
driver.rumbleOff();
}
-
- public void toggleSOTM() {
- if (SOTM) {
- SOTM = false;
- } else {
- SOTM = true;
- }
- }
}