Swerve drive Oscillations

I have been trying to program Swerve drive. Our modules have a Falcon 500 for drive and a Neo for turning. The modules also have CANcoders. The modules go to the module state but once they reach the positon they begin oscillating. To convert the CANcoder from rotations I multiplied its output by 2PI. With a PID of 0.01, 0, 0 it oscillates pretty quickly. I changed the PID loop to a profiled PID and gave it feedforward. I had some pretty good secsess with turning the P term way down low and using the feedforward but it still wasn’t very good. Its very possible that I just don’t know how to tune this but I guess thats kinda my question. I included a video with it tuned like this: new ProfilePIDController(0.03, 0, 0, new TrapezoidProfile.Constraints(Math.PI, 2*Math.PI));
new Simple MotorFeedForward(0.02, 0.001);

PID tuning, likely you need to adjust the Derivative term to stabilize it. Proportional alone won’t be enough. The system has inertia and the oscillating you are seeing is the PID proportional taking it past the setpoint and then reversing past the setpoint, repeat.

See also here, don’t rely on feed forward too much, you are just making the PID useless with those small values:

Similar issues also here: Swerve YAGSL Spazzing

With respect, I’d suggest kinda the opposite? The profile velocity feedforward alone should work pretty well, if your feedforward is tuned well. One thing that jumps out at me is that your profile velocity is very low; ours is 10X yours. Your feedforward values are also very different from ours: your kS value is enormous, and your kV value is very small. if you use a large kS, then you will produce chatter – imagine this as sort of the opposite of a deadband.

My advice is to work the problem from the bottom up. You’ll never tune it correctly as a unit, twiddling numbers and watching the robot. First start by making your steering motors work correctly using feed kV alone: give them a velocity command (say 1 rotation/sec) and verify that your feedforward actually produces this behavior (with wheels on the ground). Then tune kS by giving the motors very low velocities. Then tune the profile by measuring the maximum rotational velocity and acceleration, by looking at your logs (with wheels on the ground). Only then should you think about the feedback (PID) part.

hope this helps!

I fixed the ossolations by replacing the WPI pid libraries with REV’s own libraries and using the internal encoders on the neos.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.