Skip to content
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

Update introduction-to-pid.rst with DigiKey PID Video #2609

Closed
wants to merge 1 commit into from

Conversation

horner
Copy link
Contributor

@horner horner commented Mar 18, 2024

No description provided.

@calcmogul
Copy link
Member

calcmogul commented Mar 26, 2024

This video is good until the 10 minute mark when it starts talking about the integral and derivative terms.

Integral control

I disagree with its assertion that integral control is better than a constant offset (aka feedforward). A model-based feedforward + P controller gives superior performance compared to a PI controller, and an accurate feedforward is usually easy to make; u = Kₛsgn(v) + Kᵥv works for most things with a DC motor.

Also, there's better ways to compensate for unmodeled disturbances like input error estimation, which only integrates if the system is deviating from its model. That is, you integrate a model of the system, then output a corrective action based on the difference between the expected position and actual position¹. The model is reasonably easy to get in FRC with SysId because most FRC systems fit into dx/dt = Ax + Bu -> dx/dt = −Kᵥ/Kₐx + 1/Kₐu. In any case, pure integrators should have exceedingly small controller contributions, if any.

¹ I started but did not complete an input error estimator class. A low tech way to do the same thing is basically:

// x is state, xEst is state estimate, y is measurement, u is control input, r is setpoint
xEst = Math.exp(A * dt) * xEst + 1/A * (Math.exp(A * dt) - 1)  * B * uₖ₋₁;
uₖ = feedforward(rₖ, rₖ₊₁) + PD(yₖ, rₖ) - Ki * (yₖ - xEst);

Derivative control

The video's interpretation of derivative control does nothing to explain how the controller behaves with a moving position setpoint (e.g., motion profiles, which are common in FRC). That's why our existing docs use the alternate interpretation that for a position system, Kp is proportional control of position, and Kd is proportional control of velocity (the velocity setpoint is implicitly set by the rate of change of the position setpoint). This gives the gains accurate physical meaning in more cases that better informs how to tune them.

The video's audience

I am aware many students these days prefer videos to text, but the videos need to have the right information for our audience. This video seems aimed at PLC users who don't have a system model, and if they do start modeling, they'll do so with transfer functions (classical control theory). FRC can take advantage of feedforwards and modern control theory² instead, so I think this video is counterproductive for the rest of our docs.

² Modern control theory is easier to learn and more powerful than classical. The only place you'd use classical is for frequency shaping, like EE power circuit design or rocket vibrational dampening.

@sciencewhiz
Copy link
Collaborator

Thanks for the contribution! Besides those issues, I think the overall length of the video may also be an issue. We're definitely open to other learning mediums, but we need to make sure they're consistent with the rest of the content. I'm going to close this but if you have another suggestion, feel free to open a new PR.

@horner
Copy link
Contributor Author

horner commented Apr 5, 2024

@calcmogul Thanks for your feedback on the video. I appreciate you taking the time to explain the befits of a PD over a PID and modern control theory. I also learned a lot based on the PDF article you shared input error estimation. I found that document to be very helpful. I edited my PR to include that link. There is a lot of good videos in the PDF but none for the PID or control theory so I am going to make some PR's over there!

I think it's worth pointing out that the video page on wpilib ( src ) is similar to the DigiKey PID Video in that it does not cover the modern control theory.

Check out this video (particularly 6:45 where feedforward is introduced)
https://www.youtube.com/watch?v=FW_ay7K4jPE

Curious if you think it would be a better resource.

Thanks again for sharing !

@horner
Copy link
Contributor Author

horner commented Apr 5, 2024

#2631

@horner horner mentioned this pull request Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants