YAGSL oscillations

Continuing the discussion from YAGSL Having Erratic Motion and Many Errors:

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.

What swerve modules are you using? It appears you are using Rev Absolute Encoders and Krakens that’s a pretty unusual combination for a swerve module

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?

2 Likes

We are using Redux Canandmag encoders with krakens.

“Just for clarification, are the wheels (drive) oscillating? Or are the angle the wheeles are steering to (azimuth) oscillating?”

Hmm, I’m pretty sure its just the steering mechanism 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.

It shouldn’t matter but a canandmag makes a lot more sense for a possible swerve configuration. YAGSL/swervelib/parser/json/DeviceJson.java at main · BroncBotz3481/YAGSL · GitHub

1 Like

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.

1 Like

I went back and looked at the video. I was mistaken.
Both the drive motor and the steering motor are oscillating with no input from controller.

Just to put this out there, due to the mechanics of the module the wheel will spin slightly with steering input if the drive motor is not moving.

This movement is small, like an inch total for an entire revolution of the wheel.

I am not saying the drive isn’t oscillating. But the two are not entirely independent.

Can you resend the video?

Preferably with a view of a swerve widget and your controller.

1 Like

I think that should be a PID issue, can you turn the “p” term of the drive PID to 0 to disable it?

Have you gotten it to work?

Yes! However, I am out of town and haven’t yet been told what the fix was. I will post the solution by 10/7/24.

2 Likes

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.

3 Likes