Skip to content

Commit

Permalink
Merge pull request #143 from Robocubs/patches
Browse files Browse the repository at this point in the history
Fixed shoot while move tolerance and moved passing point
  • Loading branch information
mpulte authored Apr 13, 2024
2 parents 3aef8be + dbf1ea2 commit d21c3e0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/team1701/lib/util/GeometryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public static Rotation2d angleModulus(Rotation2d rotation, Rotation2d minimumInp
MathUtil.inputModulus(rotation.getRadians(), minimumInput.getRadians(), maximumInput.getRadians()));
}

public static boolean isBetween(Rotation2d actual, Rotation2d expected1, Rotation2d expected2) {
var maxDiff = Math.abs(MathUtil.angleModulus(expected1.getRadians() - expected2.getRadians()));
var diff1 = Math.abs(MathUtil.angleModulus(actual.getRadians() - expected1.getRadians()));
var diff2 = Math.abs(MathUtil.angleModulus(actual.getRadians() - expected2.getRadians()));
return diff1 < maxDiff && diff2 < maxDiff;
}

public static boolean isNear(Rotation2d expected, Rotation2d actual, Rotation2d tolerance) {
var difference = MathUtil.angleModulus(expected.minus(actual).getRadians());
return MathUtil.isNear(difference, 0.0, tolerance.getRadians());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/team1701/robot/FieldConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ public final class FieldConstants {
public static final Pose2d kBluePassingTarget =
new Pose2d(new Translation2d(1.5, 6.5), GeometryUtil.kRotationIdentity);
public static final Pose2d kRedPassingTarget =
new Pose2d(new Translation2d(kFieldLongLengthMeters - 1.5, 5.8), GeometryUtil.kRotationIdentity);
new Pose2d(new Translation2d(kFieldLongLengthMeters - 1.5, 6.5), GeometryUtil.kRotationIdentity);
}
5 changes: 2 additions & 3 deletions src/main/java/com/team1701/robot/commands/ShootAndMove.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,9 @@ public void execute() {
var atAngle = GeometryUtil.isNear(
mShooter.getAngle(), mLastSetpoint.angle(), Rotation2d.fromRadians(kAngleToleranceRadians.get()));

var stationaryTargetHeading = FieldUtil.getHeadingToSpeaker(currentPose);

var stationaryTargetHeading = FieldUtil.getHeadingToSpeaker(currentPose).minus(shooterSetpoint.releaseAngle());
var atHeading = GeometryUtil.isNear(mLastTargetHeading, mRobotState.getHeading(), headingTolerance)
|| GeometryUtil.isNear(stationaryTargetHeading, mRobotState.getHeading(), headingTolerance);
|| GeometryUtil.isBetween(mRobotState.getHeading(), mLastTargetHeading, stationaryTargetHeading);

var atSpeed = mLastSetpoint
.speeds()
Expand Down

0 comments on commit d21c3e0

Please sign in to comment.