Skip to content

Commit

Permalink
refined validRobotPosition checker for shooting note
Browse files Browse the repository at this point in the history
added a checker the ensure that the hub opening is wide enough for the note from the robot's shooting position
  • Loading branch information
Bluewaves54 committed Feb 19, 2024
1 parent f301636 commit 935fed7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/frc/robot/subsystems/shooter/ShooterDynamics.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ShooterDynamics {

private static final double NOTE_WIDTH_METERS = Units.inchesToMeters(14.0);
private static final double MAX_NOTE_DRIFT_RAD = Math.toRadians(2.0);
private static final double HUB_WIDTH_METERS = 1.05;

// Max distance the shooter can physically attain with a still trackable trajectory (2D)
private static final double MAX_SHOOTER_DISTANCE = Units.feetToMeters(25.0); // TODO
Expand Down Expand Up @@ -42,10 +43,6 @@ public static Optional<Pair<Rotation2d, ShooterState>> calculateSpeaker(
// Ensure that the shooter could possibly make the shot with a reasonable trajectory
if (distToTarget > MAX_SHOOTER_DISTANCE) return Optional.empty();

// TODO calculate note intersection points. Should allow for bank-shots on the inside sides of
// the speaker as well.
// If the note cant make it in at all angles within the angle bound, return empty Optional.

double x = robotPose.getX();
double y = robotPose.getY();

Expand Down Expand Up @@ -79,6 +76,11 @@ public static Optional<Pair<Rotation2d, ShooterState>> calculateSpeaker(
// Calculate angle of robot based on robot position and aim location
Rotation2d botAngle = Rotation2d.fromRadians(-Math.atan(x - hubX / y - hubY));

// Ensure the apparent width of the hub from the robot's vantage point is large enough for the
// note
double apparentHubWidthMeters = HUB_WIDTH_METERS * Math.cos(botAngle.getRadians());
if (apparentHubWidthMeters + 0.1 < NOTE_WIDTH_METERS) return Optional.empty();

// Offset shooter velocity by robot's x velocity
velocity += robotVel.getData()[0];

Expand Down

0 comments on commit 935fed7

Please sign in to comment.