Yes reset the integral to 0, especially when close to target. When you were last computing the integral, you may have been way far away from the target setting and it built up to a high value. If you are close in, the I will be too high and you will end up overshooting the target. Setting to 0 though will make it reset the PID.
Last error should be reset too to clear the D as well.
But if you can live with the overshoot, then it is optional. It should settle down eventually.
Hey, I just had a question about using PID to keep the robot straight. To do this with encoders, I start a PID loop with the slower side and the aim and angle. And then I simultaniously start another PID loop with faster sideâs encoder to the slower sides encoder. Is this right? Also, how do you keep the robot straight with only a gyro? If i start a PID loop with the gyro and the aim angle, then I canât move forward at the same time. What is the solution for this? I know this is two questions, thank you.
Two ways to attack this. Assuming forward facing wheels.
Keep the gyro angle constant. Use PID to keep that set to the correct heading angle.
Keep the delta from left/right side to 0. Your PID manages the delta to 0.
They each have a slight drawback to be aware of. The gyro can drift slightly so what you think is your heading may change over time as the gyro drifts.
The left/right may occasionally have wheel slip which makes left right different. The sticky tires and foam tiles makes that less likely.
For each of these, based upon the error, you can be off a bit if you donât keep track of how far off in the Y direction you have traveled. (forward is X direction) As you go off a bit to left, you correct right until same direction heading if using the gyro. However, you drifted left a little bit which make you off target (like getting a skyrise piece into the base or aligning to grab the next one). So you may want to go back that amount of drift versus just correcting the heading.
Holonomic drive changes this a bit to manage both X and Y and possibly angle as well with their own error calculations.
I have used this code in our robot, and am actively using robotCâs integrated PID. My team was wondering if there is any way to âturn offâ this PID when we push a button? for example, we launch all our full court shots with the PID on, but can i push a button that will then turn off the PID and set the motors to a crude value of 50/127 lets say? Without using the slave motor function at all? iâm assuming i could add the slave function to the actual button if statement, but im not sure how to make sure that the IME is no longer controlling the motor value of even that one singular motor. To me it seems like if im not running the slave motor code, then the IME will adjust its speed, but my other motors will run at that set value of 50⌠any ideas on how to toggle this PId code on and off? thanks