frc5567 / 2022-Robot

Other
3 stars 0 forks source link

Flywheel RPM PIDF Controller #284

Closed MikasaSucasa closed 2 years ago

MikasaSucasa commented 2 years ago

Make an RPM error based PIDF Controller for our launcher class. This is needed for more consistent shooting.

MikasaSucasa commented 2 years ago

Here is an example of another team using the integrated PID for falcons... https://github.com/frc1444/robot2020/blob/master/wpi/src/main/java/com/first1444/frc/robot2020/MotorBallShooter.java

MikasaSucasa commented 2 years ago

Along with the PID implementation, we will need to add a liveWindow to our shuffleboard so that we can observe how well our control strategy is working. Here is the tutorial from frist: https://docs.wpilib.org/en/stable/docs/software/dashboards/shuffleboard/getting-started/shuffleboard-graphs.html

MikasaSucasa commented 2 years ago

Another great example of a shooter class which uses talonFX controllers and PID https://github.com/Team254/FRC-2020-Public/blob/master/src/main/java/com/team254/frc2020/subsystems/Shooter.java

MikasaSucasa commented 2 years ago

https://github.com/CrossTheRoadElec/Phoenix-Examples-Languages/blob/master/Java%20Talon%20FX%20(Falcon%20500)/VelocityClosedLoop_ArbFeedForward/src/main/java/frc/robot/Robot.java

coverbeek commented 2 years ago

Here is the Cubic Regression Polynomial formula from our curve-fitted values: y = 3119.8 + 19.002x - 0.1949171x^2 + 0.000954319*x^3

y is RPM x is distance in inches

EDIT: Updated after adjusting PID coefficients. y = 0.0047x3 - 1.2642x2 + 121.27x - 127.68

Can curve fit in Excel -- https://www.got-it.ai/solutions/excel-chat/excel-tutorial/curve-fitting/curve-fitting-in-excel

coverbeek commented 2 years ago

I committed the spreadsheet with the datapoints and curve fit to the base folder of the 2022 robot code. DistanceVelocityPolynomial.xlsx

MikasaSucasa commented 2 years ago

https://github.com/FRC-Sonic-Squirrels/Flywheel-Tuner/blob/main/src/main/java/frc/robot/Robot.java for future reference. Handles all the things we'd want to do.

coverbeek commented 2 years ago

3rd order polynomial after Tuesday's practice: y = 0.0078x^3 - 2.3105x^2 + 236.44x - 4384.4