Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Team334/R2024
Browse files Browse the repository at this point in the history
  • Loading branch information
PGgit08 committed Jan 26, 2024
2 parents a0e7b26 + b6d3371 commit f5798f2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/frc/robot/subsystems/SwerveDriveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,15 @@ public double[] anglesToSpeaker() {


Rotation2d currentRotation = getHeading();
double rotateDifference = Math.atan((getPose().getY() - Constants.FIELD_CONSTANTS.SPEAKER_POSE.getY()) / (getPose().getX() - Constants.FIELD_CONSTANTS.SPEAKER_POSE.getX()));

double angleX = currentRotation.getDegrees() - rotateDifference;
double angleX = 0;

if (getPose().getY() > Constants.FIELD_CONSTANTS.SPEAKER_POSE.getY()){
angleX = -currentRotation.getDegrees() + Math.atan((getPose().getY() - Constants.FIELD_CONSTANTS.SPEAKER_POSE.getY()) / (getPose().getX() - Constants.FIELD_CONSTANTS.SPEAKER_POSE.getX()));
}
else{
angleX = -currentRotation.getDegrees() - Math.atan((Constants.FIELD_CONSTANTS.SPEAKER_POSE.getY() - getPose().getY()) / (getPose().getX() - Constants.FIELD_CONSTANTS.SPEAKER_POSE.getX()));
}

double[] angles = {angleX, angleY};

return angles;
Expand Down

0 comments on commit f5798f2

Please sign in to comment.