Python Swerve Code help

We’re trying to get swerve code written in Python and have been having problems with our turning motors that just keep oscillating. We see that the desired angle is oscillating which I assume is what is making the actual turn motors oscillate. We are using Neos for both the drive and turn motors with this as our turning encoder: MA3 Absolute Encoder with Cable - AndyMark, Inc. We have verified multiple times things like CAN ids, analog ports, etc.

Our code is posted here: GitHub - olentangyfrc/Python-Swerve-Code-Testing

Does anybody have some suggestions of things to look at?

I see that you log your states to smart dashboard. Do the rotations in those states oscillate as well?

Op, could you update the thread title to have a few more details if you can? For example, “python swerve, turning motor oscillations”

This will help get eyes on the thread better.

:slight_smile:

As far as this issue is concerned: I would look into the PID tuning and if the D term is tuned correctly/enough.

It is possible the D term isn’t sufficient for the range of input values the encoder is providing.

Tuning PIDF
Another good way to describe it from CTRE is
Manual tuning typically follows this process:
Set , and to zero.
Increase until the output starts to oscillate around the setpoint.
Increase as much as possible without introducing jittering to the response.

TURNING_P is 2.0 in that code. I would turn that way down and start working back up.

2 Likes