New Coach here- we are having YAGSL drive oscillations and have tried to accomplish debugging based on prior threads, but no joy.
We are running Kraken drive, Neo/spark max turners, pigeon 2.0 imu and rev PDH.
Here is our code:
We have changed the PID settings numerous times, no joy. Is there anything else that we can try to get rid of the oscillations??
We truly appreciate experienced programmers’ responses.
Can you be more specific on “oscillation”? Is the chassis shaking all the time when driving?
You can try disabling the PID of drive motors; go to this file
make the “p” term for drive 0 and see if it works.
The wheels oscillate back and forth by up to 10 degrees at a rate of approx 2/sec. I wish I could post a video, but cannot upload from my iphone. We are still up on blocks, not trusting this robot to lurch off out of control.
I suspect this is a PID tuning error, which is what others seem to be thinking too. The Oscillation is likely too large of a p value, which is why the suggestion was made to disabled it (p=0) and make sure the oscillation stops.
As @Technologyman00 alluded to, the hardware you are using is not a common combination (rev abs encoders, krakens), and since pid values are tuned based on the scale of the values you are seeing this could be an issue. You may need to change the values pretty drastically. Have you confirmed all the conversion factors (gear ratios, encoder reporting the angle ranges or tick position you expect etc) make sense ?
Juat for clarification, are the wheels (drive) oscillating? Or are the angle the wheeles are steering to (azimuth) oscillating?
Looking at the configuration tool, it looks like the type for encoder in each module should be “canandmag” with canbus as “null”. In the code you shared you have it as “attached” which is why others assumed you were using the Rev absolute encoders.
Set the offsets for the absolute encoder in the jsons to 0. Either use the offset on the encoder or use the offset on the sparkmax. You can do this in code later but it’s a good troubleshooting step.
Hey y’all, student update. Here is what we did to diagnose and fix the swerve.
First of all, we received a ton of help from @nstrike and other members of the YAGSL discord server → YAGSL
We used ShuffleBoard and FRC Web Components to diagnose what exactly the issue was.
The first thing we noticed was that turning the modules counterclockwise gave us a negative angleSetpoint value which should have been positive. Our encoders were already inverted as per @nstrike ’s advice and their values correctly increased with the same counterclockwise rotation as did the angle motor’s built in encoder.
We told @nstrike this exact info and he told us an incorrect angle motor inversion might cause the exact symptoms our drive base was suffering from, so we inverted the angle motors in code.
And,
it worked. Completely and immediately. All we had to do left was PID tuning. That’s all!
Thank you all for the help and advice! We appreciate everyone’s input.