Skip to content

Commit

Permalink
FIXED TURRET LOGIC IT WAS INSANELY STUPID BEFORE
Browse files Browse the repository at this point in the history
  • Loading branch information
Cancelable committed Dec 13, 2023
1 parent 166d48e commit fde7999
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class TurretPoint extends CommandBase {
private final Turret turret;
private final Odometry odometry;

// private Translation2d target;
private Translation2d target;

public TurretPoint(Translation2d target) {
//this.target = target;
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/com/stuypulse/robot/subsystems/turret/Turret.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public Turret() {

public void setTargetAngle(double angle, double maxTarget, double minTarget) {
// closest to current angle as possible
double realTargetAngle = getTurretAngle() + (angle);

if (realTargetAngle > maxTarget) {
targetAngle.set(realTargetAngle - (360 * (Math.ceil(realTargetAngle / 360))));
} else if (realTargetAngle < minTarget) {
targetAngle.set(realTargetAngle + (360 * (Math.ceil(realTargetAngle / 360))));
} else {
// targetAngle.set(angle % 360); // originally 360
targetAngle.set(realTargetAngle);

if (angle > maxTarget) {
targetAngle.set(angle % maxTarget);
}
if (angle < minTarget) {
targetAngle.set(angle % minTarget);
}
else {
targetAngle.set(angle % 360);
}
}

Expand Down

0 comments on commit fde7999

Please sign in to comment.