-
Notifications
You must be signed in to change notification settings - Fork 13
Add Why Run To Position Mode Is Not A Good Idea #38
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch!
This overall looks great and I really appreciate adding this to cookbook; this is something that would have directly saved my team at state this year.
I have individual comments with some nitpickier changes and expansions I'd love to see as well.
When using a PID(F) controller to move a motor to a certain position, it is often tempting | ||
to use the `RUN_TO_POSITION` mode, especially since it appears in many examples. | ||
This motor run mode is built into the FTC SDK and is designed to move a motor to a certain encoder position autonomously. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explain why RTP is so weird here; it's because it runs on the expansion hub/control hub's internal expansion hub
then explain how the other errors connect to that (it's the cause of them)
* This is known as sample rate: Here's a [demo](https://www.youtube.com/watch?v=fusr9eTceEo&t=133s) of its effect | ||
|
||
### Why going Custom PID(F) is better: | ||
With a custom PID(F) controller, you can update the motor's position every loop. Since most FTC loops run at higher than 20hz, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to every loop of your OpMode, also give an example of what rate FTC loops run at (such as 100-200hz) and compare it to RTP
Imagine a scenario where you are trying to move a motor to a certain position. | ||
If the motor is moving too fast, it will overshoot the target position and then have to correct itself. | ||
However, if the motor is only updating its position 20 times per second, it will not be able to correct itself quickly enough, | ||
leading to overshoots and even oscillations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mention that this can especially be a problem with arms but RTP can sometimes work well on slides
``` | ||
|
||
First, this syntax is required to be followed exactly. This means that if you want to switch between manual and automatic control, | ||
you will have to change the motor mode every time you switch. Programming any FSM or even any complex auto becomes quite difficult. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "Programming any FSM" to "This can add significant complexity to coding autonomous" or something like it
First, this syntax is required to be followed exactly. This means that if you want to switch between manual and automatic control, | ||
you will have to change the motor mode every time you switch. Programming any FSM or even any complex auto becomes quite difficult. | ||
|
||
While this seems like a minor inconvenience, if done in the wrong order, it **crashes the entire bot without outputting any useful error messages**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "if done in the wrong order, it" to "messing it up"
|
||
- https://www.ctrlaltftc.com/feedforward-control | ||
- https://www.youtube.com/watch?v=E6H6Nqe6qJo | ||
# Sooo, how do I solve it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sooo -> so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or remove entirely "How do I solve this?" / "What are some better approaches?"
PID(F) controllers seem scary, but they really aren't. All they do is try to get a motor to a certain position and hold it there. | ||
Here's a [guide](https://www.ctrlaltftc.com/pidf_controllers/integrating_a_custom_PIDF_controller) on not only how to implement one but the logic. | ||
|
||
And of course, if you don't wanna do that or code your own, there are libraries like [FTCLib](https://ftclib.org/) and [Homeostasis](https://www.ctrlaltftc.com/homeostasis-by-thermal-equilibrium/what-is-homeostasis) that have PID(F) controllers that are just plug-n-play (with tuning of course). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wanna do that or code your own -> want to code your own
- https://www.youtube.com/watch?v=E6H6Nqe6qJo | ||
# Sooo, how do I solve it? | ||
PID(F) controllers seem scary, but they really aren't. All they do is try to get a motor to a certain position and hold it there. | ||
Here's a [guide](https://www.ctrlaltftc.com/pidf_controllers/integrating_a_custom_PIDF_controller) on not only how to implement one but the logic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to something like Here's a guide explaining both the implementation and the math behind them.
|
||
And of course, if you don't wanna do that or code your own, there are libraries like [FTCLib](https://ftclib.org/) and [Homeostasis](https://www.ctrlaltftc.com/homeostasis-by-thermal-equilibrium/what-is-homeostasis) that have PID(F) controllers that are just plug-n-play (with tuning of course). | ||
|
||
If you're using Roadrunner, you can use this [recipe](https://cookbook.dairy.foundation/roadrunner_056/how_to_integrate_a_PIDF_controller_with_roadrunner/how_to_integrate_a_PIDF_controller_with_roadrunner.html#pidf-controller-and-gains) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like "this recipe shows how to integrate them into your Road Runner autonomous"
PID(F) controllers seem scary, but they really aren't. All they do is try to get a motor to a certain position and hold it there. | ||
Here's a [guide](https://www.ctrlaltftc.com/pidf_controllers/integrating_a_custom_PIDF_controller) on not only how to implement one but the logic. | ||
|
||
And of course, if you don't wanna do that or code your own, there are libraries like [FTCLib](https://ftclib.org/) and [Homeostasis](https://www.ctrlaltftc.com/homeostasis-by-thermal-equilibrium/what-is-homeostasis) that have PID(F) controllers that are just plug-n-play (with tuning of course). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mention dairy, potentially don't mention homeostasis? is it updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing an entry in src/SUMMARY.md
@@ -0,0 +1,57 @@ | |||
# Why Run To Position Is Not A Good Idea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This title could be better phrased.
"Not A Good Idea" is fairly weakly worded, I think a simple "Why Not Use RTP" or "Do Not Use RTP" is more direct and better.
- https://www.youtube.com/watch?v=E6H6Nqe6qJo | ||
# Sooo, how do I solve it? | ||
PID(F) controllers seem scary, but they really aren't. All they do is try to get a motor to a certain position and hold it there. | ||
Here's a [guide](https://www.ctrlaltftc.com/pidf_controllers/integrating_a_custom_PIDF_controller) on not only how to implement one but the logic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the gm0 page as well.
PID(F) controllers seem scary, but they really aren't. All they do is try to get a motor to a certain position and hold it there. | ||
Here's a [guide](https://www.ctrlaltftc.com/pidf_controllers/integrating_a_custom_PIDF_controller) on not only how to implement one but the logic. | ||
|
||
And of course, if you don't wanna do that or code your own, there are libraries like [FTCLib](https://ftclib.org/) and [Homeostasis](https://www.ctrlaltftc.com/homeostasis-by-thermal-equilibrium/what-is-homeostasis) that have PID(F) controllers that are just plug-n-play (with tuning of course). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a line recommending that students try programming one at least once.
docs: explain limitations of RUN_TO_POSITION and benefits of custom PID(F) controllers
This recipe provides a comprehensive understanding for teams transitioning from
RUN_TO_POSITION
to custom solutions.