private Turret turret;
private PS5ControllerDriverConfig driver;
- public TurretJoyStickAim(Turret turret){
+ public TurretJoyStickAim(Turret turret, PS5ControllerDriverConfig driver){
this.turret = turret;
+ this.driver = driver;
}
Rotation2d rotation2d = new Rotation2d(driver.getRawSideTranslation(), driver.getRawForwardTranslation());
driver.get(PS5Button.CROSS).onTrue(
new InstantCommand(()->{
- if (turretJoyStickAim == null || !turretJoyStickAim.isScheduled()){
- turretJoyStickAim = new TurretJoyStickAim(turret, this.driver);
- CommandScheduler.getInstance().schedule(turretAutoShoot);
- }
- })
+ if (turretJoyStickAim == null || !turretJoyStickAim.isScheduled()){
+ turretJoyStickAim = new TurretJoyStickAim(turret, this);
+ CommandScheduler.getInstance().schedule(turretAutoShoot);
+ }
+ })
).onFalse(
new InstantCommand(()->{
- turretJoyStickAim.cancel();
+ if(turretJoyStickAim.isScheduled()){
+ turretJoyStickAim.cancel();
+ }
})
);
}