frc2399 / 2023-Season

Other
2 stars 2 forks source link

Enhance motion profiling with ProfiledPIDSubsystem #34

Closed edf42001 closed 1 year ago

edf42001 commented 1 year ago

Alice, Alison, and Maisie will remember the weird hack required to make the arm work. https://github.com/frc2399/2023-Season/blob/4119f34568a9420d0a4b7ac8e87d3d1440dc44a0/src/main/java/frc/robot/commands/auton/TwoPieceAuton.java#L87-L90 Turns out, WPIlib has a solution: https://docs.wpilib.org/en/stable/docs/software/commandbased/profilepid-subsystems-commands.html

By putting motion profiling in the subsystem, it automatically runs all the time. You add some wpi magic to the arm or elevator subsytem, copy some code from the motion profiling command into the subsytem, then you can get rid of the command and update the autonomous routines.

It also comes with enable and disable functions so you can turn motion profiling on and off if you want to control the output directly with a joystick for example.

Check out the link it has a full example and tutorial. ProfiledPIDCommand is something different you can ignore it