-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRotateTurret.java
47 lines (39 loc) · 1.08 KB
/
RotateTurret.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.Constants;
import frc.robot.Util;
import frc.robot.subsystems.Limelight;
import frc.robot.subsystems.Turret;
public class RotateTurret extends CommandBase {
private Turret turret;
private Limelight lime;
public RotateTurret() {
addRequirements(turret, lime);
}
@Override
public void initialize(){
lime.turnOn();
}
@Override
public void execute() {
/*
if (lime.canSeeTarget() && lime.getHorizontalAngle() > 1.5) {
turret.set(lime.getHorizontalAngle() > 0 ? 0.5 : -0.5);
}*/
if(lime.canSeeTarget()){
double eps = lime.getHorizontalAngle();
if(eps != 0 && !Util.eps(eps, 0, 1.5)){
turret.set(Constants.TURRT_ROTATION_SPEED);
}else{
turret.stop();
}
}else{
turret.stop();
}
}
@Override
public void end(boolean interrupted) {
turret.stop();
lime.turnOff();
}
}