-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shooting while driving 😵 #83
Comments
oh interesting you can only have one assignee :( |
can someone link the #73 swd branch |
tru (only on private repos) but we can @GalexY727 them if we want them to be subscribed to the notifs for that issue |
Why is this not already complete because of |
I was thinking only because it hasn't been tested in real life to work, but what the heck with it we can just merge if you are excited and ready for fun |
If you truly want to test it, I think that we may be able to use #109 to test just how good this is; all I need to do is edit the params so you can implement angle and speed into the shooting. I'll do that now...(unless we should wait?) |
It works phenomenally in sim, I have tested it. Feel free to integrate #109 into it |
I'm fine for the PR for this to be drafted |
From here to main?? If you mean #110 I've already made it and asked for your review |
idk why but i thought #110 was just a draft pr and wasn't ready for review. I'll do that now. |
what else need to get done for this besides testing, can this be closed @GalexY727? (make a task list) |
The second task was already complete... public Rotation2d calculateSWDAngleToSpeaker(Pose2d robotPose, ChassisSpeeds robotVelocity) {
// Calculate the robot's pose relative to the speaker
Pose2d poseRelativeToSpeaker = robotPose.relativeTo(FieldConstants.GET_SPEAKER_POSITION());
// Calculate the current angle to the speaker
currentAngleToSpeaker = new Rotation2d(poseRelativeToSpeaker.getX(), poseRelativeToSpeaker.getY());
// Convert the robot's velocity to a Rotation2d object
Rotation2d velocityRotation2d = new Rotation2d(robotVelocity.vxMetersPerSecond, robotVelocity.vyMetersPerSecond);
// Calculate the total speed of the robot
double totalSpeed = Math.hypot(robotVelocity.vxMetersPerSecond, robotVelocity.vyMetersPerSecond);
// Calculate the component of the velocity that is tangent to the speaker
double velocityTangentToSpeaker = totalSpeed * Math.sin(velocityRotation2d.getRadians() - currentAngleToSpeaker.getRadians());
// Calculate the desired rotation to the speaker, taking into account the tangent velocity
Rotation2d desiredRotation2d = Rotation2d.fromRadians(
currentAngleToSpeaker.getRadians() - Math.atan2(
velocityTangentToSpeaker,
rpmToVelocity(calculateSpeed(robotPose, true).getSpeeds())
)
);
// Update the robot's pose with the desired rotation
desiredSWDPose = new Pose2d(robotPose.getTranslation(), desiredRotation2d);
// Return the desired rotation
return desiredRotation2d;
}
/**
* This method is averaging the speeds to make a rough estimate of the speed of the note (or the edge of the wheels).
* The formula used is V = 2π * D/2 * RPM/60.
* First, it converts from Rotations per Minute to Rotations per Second.
* Then, it converts from Rotations per Second to Radians per Second.
* Finally, it multiplies by the radius of the wheel contacting it.
* As v = rw (w = omega | angular velocity of wheel).
*
* Converts RPM (Revolutions Per Minute) to velocity in meters per second.
* @param speeds a pair of RPM values representing the speeds of two shooter wheels
* @return the velocity in meters per second
*/
public double rpmToVelocity(Pair<Double, Double> speeds) {
double rotationsPerMinute = (speeds.getFirst() + speeds.getSecond()) / 2.0;
double rotationsPerSecond = rotationsPerMinute / 60.0;
double radiansPerSecond = rotationsPerSecond * Math.PI;
double diameter = ShooterConstants.WHEEL_DIAMETER_METERS;
desiredMPSForNote = diameter * radiansPerSecond;
// Normally this is 1 radius * 2 pi
// but we are doing 2 radius * 1 pi
// because we are given a diameter
return diameter * radiansPerSecond;
}
``` |
That only marks the first checkbox as complete. We need to use the component of our velocity that is normal (perpendicular) to the speaker to figure out how we should modify the speeds of the shooter to compensate for already having some velocity getting closer to further from the speaker. |
Oh, I forgot to comment abt this, but the second checkbox should now be resolved. Because of the following: private SpeedAngleTriplet calculateSWDSpeedAngleTripletToSpeaker(Supplier<Pose2d> pose, Supplier<ChassisSpeeds> speeds){
double dt = DriverUI.currentTimestamp - DriverUI.previousTimestamp;
return new SpeedAngleTriplet(
calculateSWDShooterSpeedsToSpeaker(pose, speeds, dt),
calculateSWDPivotAngleToSpeaker(pose, speeds, dt).getDegrees()
);
} |
I think this can finally be closed with the addition of #142 |
this is good |
Discussed in #73
Originally posted by GalexY727 January 26, 2024
Oh boy, where do we start...
where do we start, indeed... 💀
EDIT: Task list
The text was updated successfully, but these errors were encountered: