Closed slylockfox closed 2 years ago
We are using the C++ example. We looked at the Java version, and it doesn't appear to be any different.
@NoahAndrews
Thanks for reaching out.
Unfortunately, we have not been able to reproduce this behavior ourselves with similar gains and output levels. The motor runs to the setpoint when changed on shuffleboard as expected without any external intervention or nudging.
I have a couple of questions to try and diagnose what is happening here:
Thanks for looking into it. We set up to reproduce it, and could not reproduce it ourselves. Perhaps the PID had become confused in our first test.
Using the Position PID Control example as-is, we observed some strange behavior that is serious if we can't find a workaround. When we set a value for target rotations in shuffleboard, the motor moves to that position and holds. If we then change the target rotations in shuffleboard, the motor does not immediately move. It continues to hold the previous setpoint. If we manually rotate the motor shaft a tiny bit, then it immediately acts like it should, and spins to the new setpoint.
We adjusted the P value down a little bit, and we are using a min/max range of -0.1 to 0.1. The same behavior happens with I and D both set to 0. It is almost as if the motor controller is optimized to not check the position against the setpoint unless the motor moves, which is a good optimization if you assume the setpoint will not change. Of course, in our autonomous code, we want to give multiple setpoints. Is the example code missing something that would cause the motor controller to check its status after a setpoint change?
A second minor problem is that the example code generates errors to the driver station about not updating the motor frequently enough. We determined this was because the call to SetReference was happening every time through the loop, and we changed it to be more like the other set lines, so that it executes only when the target rotations is changed from the dashboard, and the error went away. But the above weird behavior of the motor not moving until we nudge it happens with or without our change.