For some test code, on a test bot, I’m setting PID values of 30, 0.005, 0.25. When I have the Jaguars in kPosition the values work fine with a ± of 0.01 of the SetPoint.
Now when I set the jaguar control mode to kSpeed the motors spaz-out barely moving, but when I have my P value negative(-30, 0.005, 0.25) it works fine.
Is this normal? I would have thought the same PID values would work for both kSpeed and kPosition, am I wrong?
I used different values for position and speed, but not hugely different Ps. Do you disableControl() and switch modes (and change any parameters) and then enableControl()? You also probably want to change the encoder CountsPerRev to get sensible values in both modes (counts per inch vs. per rev). Could you be sending a very small value relative to what you are trying to do?
Code?
Right now I’m just setting the kSpeed or kPosition on start-up and sticking with it for the rest of the code. I did graph the Speed from the motors when in kSpeed and what happend was the motors would get up near the speed i would want then would drop to a really low RPM, some times even in the opposite direction, then jump back up past the speed only to drop again. I could post a graph later today if it would help you or anyone understand what I’m seeing.
There are many threads on tuning PID so I won’t repeat them.
You are using the exact same motor and controller and code that works in kPosition and you are only changing to kSpeed?
Or do you have a similar setup but not the exact same HW and SW?
Everything is the same, I’m just changing the kPosition to kSpeed.
I would be very surprised if the same values worked for both.
Here’s a post that I wrote a bit ago about how to tune the Jaguar velocity loop, since changing the constants doesn’t have the same effect on the output as they do in a position loop. (If you are really interested, I worked out the math on the previous page for why all of this is true, but the math is a bit advanced)