Swerve YAGSL Spazzing

Hello, Im in team 9028 and our team started to use swerve drive for the first time. We uses mk4i L2, CANcoders, Neo’s and Navx MXP. And our wheels started to Spazz when i opened teleop mode. Even if im not touching the joystick.
Thank you in advance,
G-Force 9028 Programmer.

Can you post a GitHub link to your code?

Have you opened a dashboard to try and troubleshoot what is going on? What do you see? Is all of the hardware responding reasonably?

1 Like

We encountered this when using YAGSL for our swerve, iirc what we did to fix it was just to tune the PID values for rotation

1 Like

Unstable PID values, as others have said.

1 Like

We encountered something similar on our journey this year. For us, it turned out to be a matter of inversions. We chased it for a while and got it to quiet down with PID tuning but the underlying functions were wrong - we saw on FRC Web Components arrows not lining up or jumping 12 o’clock to 6 o’clock.

Try installing this

Then look at Shuffleboard values without enabling and look at angles while you move the wheels. Once our angle inversions were fixed, we could actually drive without the spazzing. Joystick forward resulted in back motion so we then fixed the drive inversions. As I recall, we may also have had to fix the IMU invert. Once all was fixed, the original/suggested PID values worked fine.

We’re in the same district - if you continue to have problems, reach out to us and we’d be glad to talk you through a few things.

1 Like

Did you get your swerve working? We have the identical setup (mk4i, L2, billet wheels, neo, spark max, cancorder, NavX) and having similar issues. Can you post your configuration setup of the working system (I.e motor inversions, Imu inversion, conversion factors, pidf values, etc)?

1 Like

https://drive.google.com/drive/folders/1MPFfVqvRDDHDYAz1xQrwlAkC5OJ16cfG?usp=drive_link
here you go

It says I need permission.

Google drive is not really an ideal way to store code. I would highly recommend GitHub

That article shows how to use the command line but using the integration in VSCode is fine for 99% of tasks

thank you a lot for sharing the article now I’m able to use github
Here is the link to my code

Why do you have all of your joystick deadbands set to 0?

Can you verify the strength of the signal actually being sent to the motors?

In closedFieldRel it looks like you are using the same axis twice. Instead of using getRawAxis why don’t you use the built in stuff for PS4Controller. In this case like getLeftX. Same thing for your buttons and your Xbox controller stuff. You should never have to refer to a button or Axis by its number these days it just makes it harder to read and error prone.

Hello, i changed them but i still have the problem. Also whats joystick headband ?
updated github link GitHub - Legenderyguy/G-Force-YAGSL

Input deadband

Basically if your joystick wasn’t perfectly centered it would apply a small signal to your drivetrain making it move. That is why I asked for how much voltage was going to the motors. I still need to know this.

There is lots of great knowledge on FRC-docs and you can search to find things you are curious about.

I still see the deadband as 0 what did you change to? 0.1 is safe but 0.05 will probably work fine

12 Volts are being sen’t i think, also I switched the headbands to 0.1. it helped a bit but still the turning motors are spazzing when I give input and they stop on the wrong setpoint.

Sounds like you were having 2 different problems first was the deadband second sounds like the turn motors are oscillating. Are the drive motors moving properly?

yep. Drive motors are moving fine but because the angle motors are oscillating the drivetrain acts strange.

And do you want me to send a video of our robot So I can clarify the problem better ?

I don’t see any need for a video. It sounds like you either don’t have the right inverts or that the PID settings may be too aggressive for your bot.

Have you gone through the YAGSL set up docs?

Yes, I checked the docs and did the steps on there and now my swerve wheels are aligning better, thank you. And now the only problem left is this https://youtube.com/shorts/njR7srBW5uw?feature=share

So know the angle wheels are pausing when they are changing their state, but I will try different PID values and check if they are the problem.