Drive
The Drive PIDF manages acceleration and braking along a path, ensuring smooth motion and minimizing overshoot.
Setup
- Open Panels. If you haven't used Panels before, you can read the documentation on the Panels Configurables.
- On your Driver Hub or Driver Station, and connect a gamepad to it. Make sure to press "start" + "a" on the gamepad.
- Select the
Tuning
Opmode. Use your gamepad to select theManual
folder. Then, selectDrive Tuner
. - Run the run the OpMode.
Warning!
Immediately after running the Drive Tuner
Opmode, the robot will move straight back and forth 40 inches. Make sure you have enough space before running this opmode.
You can adjust the distance the robot drives back and forth through Panels.
Tuning Process
Setting the BrakingStrength
Before tuning the Drive PIDF, we will need to set the BrakingStrength. Head over to the deceleration page to learn more about it.
The BrakingStrength you set in the Constants
class will be the default BrakingStrength for all paths the robot follows.
- Observe how the robot moves back and forth through its path.
- Adjust the PIDF constants (
coefficientsDrivePIDF
) in theTuning
->Follower
->Constants
tab of Panels Configurables to ensure that the robot smoothly and accurately drives straight back and forth.
Tuning Tips
- Increasing your drive PIDF will make the robot move more quickly along the path, at the risk of more overshoot at the end of the path.
- Decreasing your drive PIDF will make the robot move more slowly and reduce the overshoot at the end of the path.
- Adjusting the
BrakingStrength
can significantly help manage how smoothly the robot decelerates as it reaches the end of its path. - If the robot drives quickly during the middle of the path but abruptly slows down as it reaches the end of the path, this may be caused by the transition between the main and secondary PIDs. This problem may also be addressed through lowering the BrakingStrength.
If you do not have prior experience with tuning PIDFs, we recommend that you check out the resources provided at the bottom of the PIDF Tuners page to learn more about tuning these.
If you have a dual PIDF system enabled, it is recommended to first tune the main PIDF, coefficientsDrivePIDF
before tuning the secondary PIDF, coefficientsSecondaryDrivePIDF
.
Tuning Tips
PedroPathing now no longer integrates heading and translational PIDF correction for drive tuning, if you would like to test all three of them, navigate yourself to the LineTest
.
Warning: After adjusting a value in Panels, hit "enter" in order to save it and cause the robot to correct differently. However, any values you modify through Panels are not saved into your code! In order to transfer the values you just tuned on Panels into your code, go to the Update Tuned Values section to learn more.
Braking Start (Optional)
Braking Start determines when the robot starts breaking when global deceleration (deceleration upon the entire PathChain) is active. Braking Start can be adjusted just like BrakingStrength.
Feedforward Adjustments (Optional)
If additional feedforward is needed, use the feedforward term directly in the coefficientsDrivePIDF
and/or coefficientsSecondaryDrivePIDF
if
you are using dual PID.
- The feedforward term applies a minimum power output to the motors to compensate for the friction between the motors, wheels, and the ground.
- To tune the feedforward, set all other PIDF values to 0 and increase the Feedforward value up until the robot starts moving/jittering.
Kalman Filter Adjustments (Optional)
The drive PID uses a Kalman filter to smooth error responses:
- Model Covariance: Default is
6
. - Data Covariance: Default is
1
. - A higher model covariance to data covariance ratio will cause the filter to rely on the previous output rather than the data (raw drive error).
- A lower model covariance to data covariance ratio will cause the filter to rely on the data rather than the previous output
- To modify these values, add the line
FollowerConstants.driveKalmanFilterParameters(6, 1)
in yourConstants
file and replace the parameters with the desired ones.
The drive PID also has a filter such that the derivative term is a weighted average of the current derivative and the previous derivative.
- The default time constant
T
for the drive filtered PID is 0.6, meaning that the derivative output is 0.6 times the previous derivative plus 0.4 times the current derivative. - You can modify this value by changing the fourth parameter in the
drivePIDFCoefficients(P, I, D, T, F)
.
Feel free to experiment with these settings for optimal performance.
Update Tuned values Into Your Code
- Once you are satisfied with your drivePIDF values, head over to the
Constants
file, and navigate to theFollowerConstants
instantiation. - Navigate to or add the line
.drivePIDFCoefficients(new FilteredPIDFCoefficients(0.1,0.0,0.01,0.6,0.0))
- Update the parameters in
new FilteredPIDFCoefficients(P, I, D, T, F)
with thedrivePIDFCoefficients
values,P, I, D, F
, you tuned on Panels. - If you are using the dual PIDF system, add the line
.secondaryDrivePIDFCoefficients(new FilteredPIDFCoefficients(0.1,0,0.01,0.6,0.01))
and update thesecondaryDrivePIDF
values you tuned on Panels.
Troubleshooting
If you encounter a problem while tuning the Drive PIDF, check out the troubleshooting page.
Last updated on