Pedro Pathing 1.1.0 has released! If you haven't already, migrate now.
Pedro Pathing LogoPedro Pathing

Heading

Tuning the heading PID

Purpose

The heading PID corrects for the robot's heading while following the path.

Setup

  1. Open Panels. If you haven't used Panels before, you can read their documentation on this website.
  2. On your Driver Hub or Driver Station, select the Tuning Opmode and then choose HeadingTuner. Run the run the HeadingTuner autonomous OpMode.
  3. Ensure that the timer for autonomous OpModes is disabled. Otherwise, the OpMode will automatically stop after 30 seconds.

Note that while running the HeadingTuner OpMode, the robot will stay in place. This is intentional.

Tuning Process

Follow this video to help you tune the PID: TODO

  1. Turn the robot left or right at varying amounts and observe how the robot turns back to its starting heading.
  2. Adjust the PID constants (headingPIDFCoefficients) in the FollowerConstants tab of Panels to ensure that the robot can accurately correct back to its starting position with minimal oscillations. For example, if the robot has too many oscillations while correcting back to its starting position, lower the P value. On the other hand, if the robot corrects back to its starting location too slowly, increase the P value. If you do not have prior experience with tuning PIDs, we reccommend that you check out the resources provided at the bottom of the PID Tuners page to learn more about tuning PIDs.

If you have a dual PID system enabled, it is recommended to first tune the main PID, headingPIDFCoefficients, to ensure that the robot can smoothly correct back from large errors. Then, tune the secondary PID, secondaryHeadingPIDFCoefficients, so the robot can smoothly correct from smaller errors.

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.

Feedforward Adjustments (Optional)

If additional feedforward is needed, use headingPIDFFeedForward for corrections in the robot’s movement direction. Avoid modifying the feedforward term directly in the PIDF.

Update Tuned values Into Your Code

  1. Once you are satisfied with your headingPIDF values, head over to the Constants file.
  2. Navigate to the line .headingPIDFCoefficients(new PIDFCoefficients(0.1, 0, 0.01, 0))
  3. Update the parameters in new PIDFCoefficients(0.1, 0, 0.01, 0) with the headingPIDFCoefficients values, P, I, D, F, you tuned on Panels in that order.
  4. If you are using the dual PID system, add the line .secondaryHeadingPIDFCoefficients(new PIDFCoefficients(0.1,0,0.01,0)) and update the secondaryHeadingPIDF values you tuned on Panels.

Congratulations, you’ve completed the heading PIDF tuning!

Troubleshooting

If you encounter a problem while tuning the heading PID, check out the troubleshooting page.

Last updated on