My team is having a problem when trying to tune a PID algorithm for turning the drivebase to a specified relative angle.
The following autonomous code (using only P control) will work as intended, turning the robot approximately 180 degrees and staying there until the robot is disabled:
What we find strange is that any non-zero kI will cause the robot to turn toward the setpoint (as expected) and then oscillate vigorously around the setpoint for eternity. This works with kI as low as 1e-12, i.e., nothing.
We would like to use PI control for our autonomous turning VI, but are perplexed by this behavior. As we decrease kI down to zero, we expect that the program’s behavior should approach that of pure P control. Perhaps this is a floating point issue?
I remember in high school when programming in LabVIEW we ran into the same problem, but worked around it. Since we only needed to vary the robot’s heading by a few degrees in 2010, we opted to set a very high kP and only use P control. This year is different, and we would like to have a turn VI that can reliably turn the robot any amount.
Besides providing us with a solution to this specific problem, what would really help us is some very good example code for turning to a specified relative angle autonomously. Any pointers, advice, or examples are appreciated!
Is it worth it to start with a non-zero kI and kP of zero, then add kP later? We have not tried that yet. However, the confusion still stands about the fact that there is such a difference between a kI of zero and a kI of 0.000000000001 (1e-12).
*Here’s a slightly off-topic question related to the PNG in the OP.
Is it best to hard-code the control period (0.020 as shown in the PNG) or would it be better to leave that blank and let LabVIEW compute the actual period each iteration (especially with Teleop)? Or doesn’t it matter that much in actual practice?