Hello, I am a programmer on Team 7826 and we are having an issue with our swerve drive. The velocity of our robot while rotating/spinning oscillates. The velocity PID used for our drive motors work well for strafing and driving and our turning motors always go to the correct location so these PIDs seem to be tuned well. The velocity oscillation seems to behave the same way a poorly tuned velocity PID would, however. This is probably not relevant but we are using MK4i swerve modules with Neos and CANCoders for the absolute encoders.
Any advice on how to fix this would be greatly appreciated.
(The experimental branch is the most up to date branch)
public static final double kFModuleDriveController = 0.0;
Your drive motors will need a feed-forward term, since as velocity approaches the set point, error goes to 0 and kP becomes inactive. You have a kI which will help some, but you should do a simple test to calculate the kF term and feed that in. That should help keep the velocity at the setpoint
if you’re moving full speed and trying to spin at the same time, the desaturation will have this effect: when the robot-relative direction is diagonal, then the rotation will require a bit more wheel speed than when the direction is aligned with the x or y axis.
it could also just be feedback. try turning all the pid constants to zero and driving on feed forward alone.
The issue is happening when we are not driving as well as when we are. Would this still be an effective fix? Currently, we are not using a feed-forward controller only a PID Loop, should we add one? Or are you referring to the F term of the PID?
ah, yeah, when we tried to drive without feedforward, we found there wasn’t much room in the P parameter between “it can’t keep up” and “it oscillates”.
you should be able to drive on feedforward alone reasonably well.
The solution ended up being decreasing the p and I values of the pid and added slew rate limiters to the joystick values this also helped with browning out.